private void FormatPage(object sender, PrintPageEventArgs e)
        {
            graphics = e.Graphics;
            Font minifont   = new Font("Arial", 5);
            Font itemfont   = new Font("Arial", 6);
            Font smallfont  = new Font("Arial", 10);
            Font mediumfont = new Font("Arial", 14);
            Font largefont  = new Font("Arial", 16);

            int Offset = 10;
            int smallinc = 10, mediuminc = 12, largeinc = 17;

            //Getting Receipt data
            List <ProductWiseSalesReportModel> productWiseSalesReportModels = new List <ProductWiseSalesReportModel>();

            ReportViewModel reportViewModel = new ReportViewModel();

            productWiseSalesReportModels = reportViewModel.GetProductWiseSales(FromDate, Todate, "");

            Offset = Offset + Offset;
            graphics.DrawString(LoginDetail.ClientName, smallfont, new SolidBrush(Color.Black), 14, Offset);
            Offset = Offset + mediuminc;

            InsertItemList(LoginDetail.OutletName, "", Offset, 5);
            Offset = Offset + mediuminc;
            Offset = Offset + mediuminc;

            //InsertItemList("DETAILED DAILY REPORT", "", Offset, 5);
            //Offset = Offset + mediuminc;
            //Offset = Offset + mediuminc;

            //InsertItemList("DATE: " + FromDate, "", Offset, 5);
            //Offset = Offset + mediuminc;

            foreach (var item in productWiseSalesReportModels)
            {
                InsertItemList(item.FoodMenuCategoryName.ToString(), "", Offset, 5);

                if (item.FoodMenuCategoryName.Contains("DATE"))
                {
                }
                else if (item.FoodMenuCategoryName.Contains("SNo"))
                {
                }
                else
                {
                    Offset = Offset + mediuminc;
                }

                //  InsertItemList(item.FoodMenuName.ToString(), "", Offset, 15);
                InsertItemList(item.SalesPrice.ToString(), "", Offset, 70 + (50 - (item.SalesPrice.ToString().Length * 4)));
                InsertItemList(item.FoodMenuQty.ToString(), "", Offset, 100 + (50 - (item.FoodMenuQty.ToString().Length * 4)));
                InsertItemList(item.Total.ToString(), "", Offset, 175 + (50 - (item.Total.ToString().Length * 4)));

                Offset = Offset + mediuminc;
            }
            Offset = Offset + mediuminc;

            Offset = Offset + mediuminc;
        }
示例#2
0
        private void btnProductWiseExcel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DateTime dtFrom = new DateTime();
                DateTime dtTo   = new DateTime();

                dtFrom = (DateTime)dpProductwiseFromDate.Value;
                dtTo   = (DateTime)dpProductWiseToDate.Value;

                List <ProductWiseSalesReportModel> productWiseSalesReportModels = new List <ProductWiseSalesReportModel>();
                ReportViewModel reportViewModel = new ReportViewModel();

                productWiseSalesReportModels = reportViewModel.GetProductWiseSales(dtFrom.ToString("yyyy-MM-dd HH:mi:ss"), dtTo.ToString("yyyy-MM-dd HH:mi:ss"), "Excel");

                CommonMethods commonMethods = new CommonMethods();
                string        path = string.Empty, firstLine = string.Empty;

                string fileName       = "ProductWiseSalesReport_" + DateTime.Now.ToString("MM-dd-yyyy_HHmmss");
                var    saveFileDialog = new SaveFileDialog
                {
                    FileName   = fileName != "" ? fileName : "gpmfca-exportedDocument",
                    DefaultExt = ".xlsx",
                    Filter     = "Common Seprated Documents (.xlsx)|*.xlsx"
                };

                if (saveFileDialog.ShowDialog() == true)
                {
                    path = saveFileDialog.FileName;
                    DataTable table = new DataTable();

                    table     = commonMethods.ConvertToDataTable(productWiseSalesReportModels);
                    firstLine = "Productwise Sales List for " + dtFrom.ToString("yyyy-MM-dd HH:mi:ss") + " to " + dtTo.ToString("yyyy-MM-dd HH:mi:ss");
                    commonMethods.WriteExcelProductWiseSaleFile(table, path, firstLine);
                }
            }
            catch (Exception ex)
            {
                SystemError.Register(ex);
            }
        }