Beispiel #1
0
        public ActionResult Print1(DateTime?from, DateTime?to, int itmid = 0, string itmName = "", int SupId = 0, string SupName = "")
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "PurchaseBillSummary.rpt"));

            DataSet ds = new DataSet();

            ds.Tables.Add("Head");
            ds.Tables.Add("Items");

            //    //-------HEAD
            ds.Tables["Head"].Columns.Add("From");
            ds.Tables["Head"].Columns.Add("To");
            ds.Tables["Head"].Columns.Add("SupplierHead");
            ds.Tables["Head"].Columns.Add("ItemHead");
            ds.Tables["Head"].Columns.Add("OrganizationName");
            ds.Tables["Head"].Columns.Add("Image1");

            //-------DT

            ds.Tables["Items"].Columns.Add("Datewise");
            ds.Tables["Items"].Columns.Add("Amount");
            SupplyOrderRegisterRepository repo = new SupplyOrderRegisterRepository();
            var Head = repo.GetSupplyOrderRegisterHD(from, to, OrganizationId);

            DataRow dr = ds.Tables["Head"].NewRow();

            dr["From"]             = from.Value.ToShortDateString();
            dr["To"]               = to.Value.ToShortDateString();
            dr["SupplierHead"]     = SupName;
            dr["ItemHead"]         = itmName;
            dr["OrganizationName"] = Head.OrganizationName;
            dr["Image1"]           = Server.MapPath("~/App_images/") + Head.Image1;
            ds.Tables["Head"].Rows.Add(dr);


            PurchaseBillRegisterRepository repo1 = new PurchaseBillRegisterRepository();
            var Items = repo1.PurchaseBillSummaryDataDTPrint(from, to, SupId, itmid, OrganizationId);

            foreach (var item in Items)
            {
                var SupplyOrderRegItem = new PurchaseBillRegister
                {
                    PurchaseBillDate = item.PurchaseBillDate,
                    Amount           = item.Amount,
                };

                DataRow dri = ds.Tables["Items"].NewRow();
                dri["Datewise"] = SupplyOrderRegItem.PurchaseBillDate;
                dri["Amount"]   = SupplyOrderRegItem.Amount;
                ds.Tables["Items"].Rows.Add(dri);
            }

            ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "PurchaseBillSummary.xml"), XmlWriteMode.WriteSchema);

            rd.SetDataSource(ds);

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf", String.Format("PurchaseBillSummary.pdf")));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #2
0
        public ActionResult Print(DateTime?from, DateTime?to, int id = 0, int itmid = 0)
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "SupplyOrderRegister.rpt"));

            DataSet ds = new DataSet();

            ds.Tables.Add("Head");
            ds.Tables.Add("Items");

            //    //-------HEAD
            ds.Tables["Head"].Columns.Add("From");
            ds.Tables["Head"].Columns.Add("To");
            ds.Tables["Head"].Columns.Add("OrganizationName");
            ds.Tables["Head"].Columns.Add("Image1");

            //-------DT
            ds.Tables["Items"].Columns.Add("SO.No.");
            ds.Tables["Items"].Columns.Add("Date");
            ds.Tables["Items"].Columns.Add("Supplier");
            ds.Tables["Items"].Columns.Add("Material");
            ds.Tables["Items"].Columns.Add("Quantity");
            ds.Tables["Items"].Columns.Add("Unit");
            ds.Tables["Items"].Columns.Add("rate");
            ds.Tables["Items"].Columns.Add("Amount");
            ds.Tables["Items"].Columns.Add("TotalAmount");

            //ds.Tables["Head"].Columns.Add("OrganizationName");
            //ds.Tables["Head"].Columns.Add("Image1");

            SupplyOrderRegisterRepository repo = new SupplyOrderRegisterRepository();
            var Head = repo.GetSupplyOrderRegisterHD(from, to, OrganizationId);

            DataRow dr = ds.Tables["Head"].NewRow();

            dr["From"]             = from.Value.ToShortDateString();
            dr["To"]               = to.Value.ToShortDateString();
            dr["OrganizationName"] = Head.OrganizationName;
            dr["Image1"]           = Server.MapPath("~/App_images/") + Head.Image1;
            ds.Tables["Head"].Rows.Add(dr);


            SupplyOrderRegisterRepository repo1 = new SupplyOrderRegisterRepository();
            var Items = repo1.GetSupplyOrderRegisterDT(from, to, id, itmid, OrganizationId);

            foreach (var item in Items)
            {
                var SupplyOrderRegItem = new SupplyOrderRegister
                {
                    SupplyOrderNo   = item.SupplyOrderNo,
                    SupplyOrderDate = item.SupplyOrderDate,
                    SupplierName    = item.SupplierName,
                    ItemName        = item.ItemName,
                    OrderedQty      = item.OrderedQty,
                    UnitName        = item.UnitName,
                    Rate            = item.Rate,
                    Amount          = item.Amount,
                    TotalAmount     = item.TotalAmount
                };

                DataRow dri = ds.Tables["Items"].NewRow();
                dri["SO.No."]      = SupplyOrderRegItem.SupplyOrderNo;
                dri["Date"]        = SupplyOrderRegItem.SupplyOrderDate.ToString("dd-MMM-yyyy");
                dri["Supplier"]    = SupplyOrderRegItem.SupplierName;
                dri["Material"]    = SupplyOrderRegItem.ItemName;
                dri["Quantity"]    = SupplyOrderRegItem.OrderedQty;
                dri["Unit"]        = SupplyOrderRegItem.UnitName;
                dri["rate"]        = SupplyOrderRegItem.Rate;
                dri["Amount"]      = SupplyOrderRegItem.Amount;
                dri["TotalAmount"] = SupplyOrderRegItem.TotalAmount;
                ds.Tables["Items"].Rows.Add(dri);
            }

            ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "SupplyOrderRegister.xml"), XmlWriteMode.WriteSchema);

            rd.SetDataSource(ds);

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf", String.Format("SupplyOrderRegister.pdf")));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public ActionResult Print(int?project, DateTime?from, DateTime?to, int id = 0, string name = "")
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "SalesRegister.rpt"));

            DataSet ds = new DataSet();

            ds.Tables.Add("Head");
            ds.Tables.Add("Items");

            //    //-------HEAD
            ds.Tables["Head"].Columns.Add("From");
            ds.Tables["Head"].Columns.Add("To");
            ds.Tables["Head"].Columns.Add("Customer");
            ds.Tables["Head"].Columns.Add("type");
            ds.Tables["Head"].Columns.Add("OrganizationName");
            ds.Tables["Head"].Columns.Add("Image1");

            //-------DT
            ds.Tables["Items"].Columns.Add("SalesInvoiceRefNo");
            ds.Tables["Items"].Columns.Add("Date");
            ds.Tables["Items"].Columns.Add("CustomerName");
            ds.Tables["Items"].Columns.Add("WorkDescr");
            ds.Tables["Items"].Columns.Add("Quantity");
            ds.Tables["Items"].Columns.Add("Rate");
            ds.Tables["Items"].Columns.Add("Amount");
            ds.Tables["Items"].Columns.Add("Discount");
            ds.Tables["Items"].Columns.Add("Unit");
            ds.Tables["Items"].Columns.Add("TotalAmount");


            SupplyOrderRegisterRepository repo = new SupplyOrderRegisterRepository();
            var Head = repo.GetSupplyOrderRegisterHD(from, to, OrganizationId);

            DataRow dr = ds.Tables["Head"].NewRow();

            dr["From"]             = from.Value.ToShortDateString();
            dr["To"]               = to.Value.ToShortDateString();
            dr["Customer"]         = name;
            dr["type"]             = project == null ? "All" : project == 1 ? "Project" : "Transport";
            dr["OrganizationName"] = Head.OrganizationName;
            dr["Image1"]           = Server.MapPath("~/App_images/") + Head.Image1;
            ds.Tables["Head"].Rows.Add(dr);


            SalesRegisterRepository repo1 = new SalesRegisterRepository();
            //var Items = repo1.GetSalesRegisterDTPrint(from, to, id, OrganizationId);
            var Items = repo1.GetSalesRegister(from, to, id, OrganizationId, project);

            foreach (var item in Items)
            {
                var SupplyOrderRegItem = new SalesRegister
                {
                    SalesInvoiceRefNo = item.SalesInvoiceRefNo,
                    SalesInvoiceDate  = item.SalesInvoiceDate,
                    CustomerName      = item.CustomerName,
                    WorkDescr         = item.WorkDescr,
                    Quantity          = item.Quantity,
                    Rate        = item.Rate,
                    Amount      = item.Amount,
                    Discount    = item.Discount,
                    TotalAmount = item.TotalAmount,
                    UnitName    = item.UnitName
                };

                DataRow dri = ds.Tables["Items"].NewRow();
                dri["SalesInvoiceRefNo"] = SupplyOrderRegItem.SalesInvoiceRefNo;
                dri["Date"]         = SupplyOrderRegItem.SalesInvoiceDate.ToString("dd-MMM-yyyy");
                dri["CustomerName"] = SupplyOrderRegItem.CustomerName;
                dri["WorkDescr"]    = SupplyOrderRegItem.WorkDescr;
                dri["Quantity"]     = SupplyOrderRegItem.Quantity;
                dri["Discount"]     = SupplyOrderRegItem.Discount;
                dri["Unit"]         = SupplyOrderRegItem.UnitName;
                dri["rate"]         = SupplyOrderRegItem.Rate;
                dri["Amount"]       = SupplyOrderRegItem.Amount;
                dri["TotalAmount"]  = SupplyOrderRegItem.TotalAmount;
                ds.Tables["Items"].Rows.Add(dri);
            }

            ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "SalesRegister.xml"), XmlWriteMode.WriteSchema);

            rd.SetDataSource(ds);

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf"));//, String.Format("SalesRegister.pdf"));
            }
            catch (Exception ex)
            {
                throw;
            }
        }