Click here to Skip to main content
15,030,781 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data;
using ProfitPlus.Models;
using ProfitPlus.Helpers;
using System.Web.SessionState;

namespace ProfitPlus.Controllers
    public class RADTPrintController : Controller
        // GET: /Cash/
        //GenHelper g = new GenHelper();
        public ActionResult Index()
            //if (!g.HasPermission()) return Redirect("/Login");
            //int divid = Convert.ToInt32(Session["divid"]);
            //int senctionid = Convert.ToInt32(Session["sectionid"]);
            return View("RADTPrint");
        /*public ActionResult findbpo()
            Cash c = new Cash();
            GenHelper g = new GenHelper();
            DataTable dt = c.FindBpo(Convert.ToInt32(Session["divid"]), Convert.ToInt32(Session["sectionid"]));
            DataSet ds = new DataSet();
            return PartialView("_Findvouchers", ds);
        public ActionResult printradt(string strdate,string endate)
            //Int32 sum = 0;
            //string strdate;
            //string endate;
            Int32 userid = Convert.ToInt32(Session["userid"]);
            Users user = new Users();
            DataTable userdt = user.GetUserRecord(userid);
            DataTable sect = DBClass.GetData("select sectionname from section_master where sectionid=" + userdt.Rows[0]["sectionid"]);
            ViewBag.sectName = Convert.ToString(sect.Rows[0]["sectionname"]);
            DataTable div = DBClass.GetData("select divname from div_master where divid=" + userdt.Rows[0]["divid"]);
            ViewBag.divName = Convert.ToString(div.Rows[0]["divname"]);
            RADTPrint pb = new RADTPrint();
            DataTable pdt = pb.printmisradt(strdate, endate, Convert.ToInt32(Session["divid"]));
            //DataTable pdt = c.printbpo(BpoNumber, Convert.ToString(Session["divname"]), Convert.ToString(Session["sectionname"]));
            foreach (DataColumn col in pdt.Columns)
                col.ReadOnly = false;
            Session["Misdata"] = pdt;
            //DataTable dt1 = DBClass.GetData("select de.depotname from depot_master as de inner join div_master div on de.divid=div.divid where div.divid='" + divid + "'");
            //ViewBag.value = Convert.ToInt64((dt1.Rows[0]["depotname"]));
            return View("RADTMISREP", pdt);
        /*public ActionResult bpopdf(FormCollection fc)
            GenHelper g = new GenHelper();
            Int32 userid = Convert.ToInt32(Session["userid"]);
            Users user = new Users();
            DataTable userdt = user.GetUserRecord(userid);
            DataTable sect = DBClass.GetData("select sectionname from section_master where sectionid=" + userdt.Rows[0]["sectionid"]);
            DataSet ds = new DataSet();
            Reports rs = new Reports();
            float[] cols = new float[] { 60f, 220f, 60f, 60f };
            String path = Server.MapPath("/pdfs/printbpo.pdf");
            DateTime stBydate = DateTime.Parse(fc["stdate"]).Date;
            var strdate = stBydate.ToString("dd-MM-yyyy");
            DateTime edBydate = DateTime.Parse(fc["edate"]).Date;
            var endate = edBydate.ToString("dd-MM-yyyy");

            //String[] rephead = new String[] { "N.W.K.R.T.C", sect.Rows[0]["sectionname"] + " DRAWING ACCOUNT FROM " + fc["stdate"] + " To " + fc["edate"] };
            String[] rephead = new String[] { "N.W.K.R.T.C", sect.Rows[0]["sectionname"] + " BPO FROM " + strdate + " To " + endate };
            String[] tblhead = new string[] { "VOUCHER.NO", "PARTYNAME", "DEBIT ACCT.HEAD", "DUE AMOUNT", "REMARKS", "CHEQUE.NO & DATE" };
            DataTable dt = rs.GetRpData(fc["stdate"], fc["edate"], Convert.ToInt32(userdt.Rows[0]["sectionid"]), Convert.ToInt32(userdt.Rows[0]["divid"]));
            pdf ph = new pdf(ds, cols, rephead, tblhead, path);
            // return File(path, "application/pdf");
            return File(path, "BpoPrint/pdf");

What I have tried:

plz suggest me to solve the problem
Updated 14-Jul-21 22:17pm
Richard Deeming 15-Jul-21 4:23am
Beyond that, if you want someone to help you fix an error, you need to provide the full details of the error. Simply saying "an error occurred" and dumping your code isn't enough - we can't run your code, we don't have access to your database, and we can't access your server.

1 solution

Read the error message: it tells you what happened and what to do to start finding out why:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
So start with the stack trace which will tell you the file, method, and line that caused the exception.

Then you can look at that code and see what caused that specific exception.

We can't do that for you: we can't run your code with your data - we don't have enough code, or any data - so we can't even tell what the exception message was, much less what line of code it occurred on!

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900