Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ReportViewer1.Reset();
                string id = Request.QueryString["id"];
                int    Id = Decode(id);
                //SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["A2ZRetailConnectionString"].ConnectionString);
                // SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=" + DatabaseName + ";Integrated Security=True");
                SqlConnection           con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RetailManagementConnectionString"].ConnectionString);
                SqlDataAdapter          adp = new SqlDataAdapter("select * from DeliveryChallans where Id=" + Id, con);
                DeliveryChallansDataSet ds  = new DeliveryChallansDataSet();
                adp.Fill(ds);
                double grandtotal = Convert.ToDouble(ds.Tables[1].Rows[0]["GrandTotal"]);
                string Words      = NumberToWords(grandtotal);
                con.Open();
                ReportDataSource rds1 = new ReportDataSource("DataSet2", GetDataSet2(Id));
                ReportDataSource rds  = new ReportDataSource("DataSet1", GetDataSet1());
                ReportDataSource rds2 = new ReportDataSource("DataSet3", GetDs2());
                ReportViewer1.LocalReport.DataSources.Add(rds1);
                ReportViewer1.LocalReport.DataSources.Add(rds);
                ReportViewer1.LocalReport.DataSources.Add(rds2);
                ReportViewer1.LocalReport.ReportPath = "ReportEngine/DeliveryChallanPrePrintedMRP.rdlc";
                ReportParameter parameter = new ReportParameter("AmountInWords", (Words + " Only"));
                ReportViewer1.LocalReport.SetParameters(parameter);
                ReportViewer1.LocalReport.Refresh();


                Warning[] warnings;
                string[]  streamIds;
                string    mimetype  = string.Empty;
                string    encoding  = string.Empty;
                string    extension = string.Empty;
                string    title     = "Retail Bill";
                byte[]    bytes     = ReportViewer1.LocalReport.Render("PDF", null, out mimetype, out encoding, out extension, out streamIds, out warnings);
                Response.Buffer = true;
                Response.Clear();
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(bytes);
                Response.End();
                string     filename = "DeliveryChallanPrePrintedMRP.pdf";
                string     path     = Server.MapPath("C");
                FileStream file     = new FileStream(path + "/" + filename, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                file.Write(bytes, 0, bytes.Length);
                file.Dispose();

                Response.Write(string.Format("<script>window.open('{0}','_blank');</script>", "DeliveryChallanPrePrintedMRP.aspx?file=" + filename));
            }
        }
Exemplo n.º 2
0
        private DataTable GetDataSet2(int Id)
        {
            //SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["A2ZRetailConnectionString"].ConnectionString);
            // SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=" + DatabaseName + ";Integrated Security=True");
            SqlConnection           con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RetailManagementConnectionString"].ConnectionString);
            SqlDataAdapter          adp = new SqlDataAdapter("select * from DeliveryChallans where Id=" + Id, con);
            DeliveryChallansDataSet ds  = new DeliveryChallansDataSet();

            con.Open();
            adp.Fill(ds);
            string ChallanNo = ds.Tables[1].Rows[0]["ChallanNo"].ToString();

            Session["ChallanNo"] = ChallanNo;
            return(ds.Tables[1]);
        }
        private DataTable GetDataSet2(int Id)
        {
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RetailManagementConnectionString"].ConnectionString);
            // SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=" + DatabaseName + ";Integrated Security=True");
            SqlDataAdapter          adp = new SqlDataAdapter("select * from DeliveryChallans where Id=" + Id, con);
            DeliveryChallansDataSet ds  = new DeliveryChallansDataSet();

            con.Open();
            adp.Fill(ds);
            string ChallanNo = ds.Tables[1].Rows[0]["ChallanNo"].ToString();

            Session["ChallanNo"] = ChallanNo;
            GetDataSet1();
            ds.Tables[1].Rows[0]["TotalAmount"]   = Convert.ToDouble(Session["TotalAmount"]).ToString("#,###.00##");
            ds.Tables[1].Rows[0]["TotalDiscount"] = Convert.ToDouble(Session["TotalDiscount"]).ToString("#,###.00##");
            ds.Tables[1].Rows[0]["PackAndForwd"]  = (Convert.ToDouble(ds.Tables[1].Rows[0]["GrandTotal"]) - Convert.ToDouble(Session["TotalAmount"])).ToString("#,###.00##");
            ds.Tables[1].Rows[0]["GrandTotal"]    = Convert.ToDouble(ds.Tables[1].Rows[0]["GrandTotal"]).ToString("#,###.00##");
            return(ds.Tables[1]);
        }