Exemplo n.º 1
0
        public void InitializeWithGeneralNumber(int RefNumber)
        {
            SEMAPHORE = true;
            aAdjustGeneralList = AdjustInventoryGeneralMgmt.SelectAllAdjustsGeneral(RefNumber, string.Empty, string.Empty);
            aItemsTable = AdjustInventoryDetailedMgmt.SelectAllAdjustsDetailed(RefNumber, -1);
            AllItemsTable = ItemsMgmt.SelectAllItems();
            aUserRow = UsersMgmt.SelectUserInfoByID(int.Parse(aAdjustGeneralList.Rows[0]["TellerID"].ToString()));

            if (aItemsTable.Rows.Count > 0)
            {
                aItemsTable.Columns.Add("PhysicalCountColumn", typeof(double));
                aItemsTable.Columns.Add("DifferencesColumn", typeof(double));
                aItemsTable.Columns.Add("DiffValueColumn", typeof(double));

                page(1);
            }
            else
            {
                MatchLbl.Visible = true;
            }

            AdjDatePicker.Text = aAdjustGeneralList.Rows[0]["Date"].ToString();
            ReferenceNumberTxtBox.Text = aAdjustGeneralList.Rows[0]["Number"].ToString();
            SEMAPHORE = false;
        }
Exemplo n.º 2
0
        private void ListItemsBtn_Click(object sender, EventArgs e)
        {
            if (ACTIVE_MODE == AdjustItemsFrmModes.ADDING_MODE)
            {
                aItemsTable = ItemsMgmt.SelectAllItems();
                aItemsTable.Columns.Add("PhysicalCountColumn", typeof(double));
                aItemsTable.Columns.Add("DifferencesColumn", typeof(double));
                aItemsTable.Columns.Add("DiffValueColumn", typeof(double));
                foreach (DataRow aRow in aItemsTable.Rows)/*validating sends error if it is not initialized*/
                {
                    if (aRow["PhysicalCountColumn"].ToString() == string.Empty) aRow["PhysicalCountColumn"] = aRow["Qty"].ToString();
                    if (aRow["DifferencesColumn"].ToString() == string.Empty) aRow["DifferencesColumn"] = "0.00";
                    if (aRow["DiffValueColumn"].ToString() == string.Empty) aRow["DiffValueColumn"] = "0.00";
                }

                AddItemsToDgview();
            }
            else if (ACTIVE_MODE == AdjustItemsFrmModes.EDIT_MODE)
            {
                /* The button will be hidden in this mode*/
            }
        }
Exemplo n.º 3
0
        public static bool InventoryAdjustReport(int ReferenceNumber, bool TableBorder = false, bool Preview = true, bool PrintToThermal = false, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool colored = false)
        {
            bool      GenerateReportIs100Matched = false;
            DataTable InventoryGeneral           = AdjustInventoryGeneralMgmt.SelectAllAdjustsGeneral(ReferenceNumber, string.Empty, string.Empty);

            if (InventoryGeneral == null)
            {
                return(false);
            }
            if (InventoryGeneral.Rows.Count == 0)
            {
                return(false);
            }
            DataTable InventoryDetailedTable = AdjustInventoryDetailedMgmt.SelectAllAdjustsDetailed(ReferenceNumber, -1);

            if (InventoryDetailedTable == null)
            {
                GenerateReportIs100Matched = true;
            }
            if (InventoryDetailedTable.Rows.Count == 0)
            {
                GenerateReportIs100Matched = true;
            }

            List <DataTable> aDataTableList = new List <DataTable>();
            DataTable        aDataTable1    = new DataTable();

            aDataTable1.Columns.Add("[border=true1]" + "<th width=15%>" + ReportsText.BarcodeRepTxt);
            aDataTable1.Columns.Add("<th width=20%>" + ReportsText.DescriptionRepTxt);
            aDataTable1.Columns.Add("<th width=9%>" + ReportsText.AvgCostRepTxt);
            aDataTable1.Columns.Add("<th width=9%>" + ReportsText.AvaQtyRepTxt);
            aDataTable1.Columns.Add(ReportsText.PhysicalCountRepTxt);
            aDataTable1.Columns.Add(ReportsText.DifferencesRepTxt);
            aDataTable1.Columns.Add(ReportsText.DifferenceValueRepTxt);

            double    TotalPositive = 0.00, TotalNegative = 0.00, ParsingTester = 0.00;;
            DataTable ItemsTable = ItemsMgmt.SelectAllItems();

            foreach (DataRow aRow in InventoryDetailedTable.Rows)
            {
                if (double.Parse(aRow["DifferenceQty"].ToString()) == 0)
                {
                    continue;
                }
                DataRow aToAddRow = aDataTable1.Rows.Add();
                aToAddRow[0]  = ReportsHelper.FindData(ItemsTable, "ID", "Barcode", aRow["ItemID"].ToString());
                aToAddRow[1]  = ReportsHelper.FindData(ItemsTable, "ID", "Description", aRow["ItemID"].ToString());
                aToAddRow[2]  = Math.Round(double.Parse(ReportsHelper.FindData(ItemsTable, "ID", "AvgUnitCost", aRow["ItemID"].ToString())), 3);
                aToAddRow[3]  = Math.Round(double.Parse(aRow["OldQty"].ToString()), 3);
                aToAddRow[4]  = aRow["NewQty"];
                aToAddRow[5]  = aRow["DifferenceQty"];
                ParsingTester = double.Parse(aRow["DifferenceValue"].ToString());
                aToAddRow[6]  = ParsingTester;
                if (ParsingTester > 0)
                {
                    TotalPositive += ParsingTester;
                }
                else
                {
                    TotalNegative += ParsingTester;
                }
            }

            if (aDataTable1.Rows.Count == 0 || GenerateReportIs100Matched)
            {
                DataTable aEmptyTable = new DataTable();
                aEmptyTable.Columns.Add("INVENTORY STOCK AVAILABLE QTY MATCHES 100% THE PHYSICAL COUNT");
                aDataTableList.Add(aEmptyTable);
            }
            else
            {
                aDataTableList.Add(aDataTable1);
                DataRow NetRow           = aDataTable1.Rows.Add();
                string  EmptyNoborderRow = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsHelper.MANUAL_TD_END;
                NetRow[0] = EmptyNoborderRow;
                NetRow[1] = EmptyNoborderRow;
                NetRow[2] = EmptyNoborderRow;
                NetRow[3] = EmptyNoborderRow;
                NetRow[4] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsText.TotalRepTxt + ReportsHelper.MANUAL_TD_END;
                NetRow[5] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsText.PosAdjValueRepTxt + ReportsHelper.MANUAL_TD_END;
                NetRow[6] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + TotalPositive + ReportsHelper.MANUAL_TD_END;
                NetRow    = aDataTable1.Rows.Add();
                NetRow[0] = EmptyNoborderRow;
                NetRow[1] = EmptyNoborderRow;
                NetRow[2] = EmptyNoborderRow;
                NetRow[3] = EmptyNoborderRow;
                NetRow[4] = EmptyNoborderRow;
                NetRow[5] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsText.NegAdjValueRepTxt + ReportsHelper.MANUAL_TD_END;
                NetRow[6] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + TotalNegative + ReportsHelper.MANUAL_TD_END;
                NetRow    = aDataTable1.Rows.Add();
                NetRow[0] = EmptyNoborderRow;
                NetRow[1] = EmptyNoborderRow;
                NetRow[2] = EmptyNoborderRow;
                NetRow[3] = EmptyNoborderRow;
                NetRow[4] = EmptyNoborderRow;
                NetRow[5] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + "<b>" + ReportsText.NetValueRepTxt + "<b>" + ReportsHelper.MANUAL_TD_END;
                NetRow[6] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + (TotalNegative + TotalPositive) + ReportsHelper.MANUAL_TD_END;
            }
            List <string> aStringList = ReportsHelper.ImportReportHeader(0, 1);
            List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);

            aStringList.Add(SharedVariables.Line_Solid_10px_Black);
            aStringList.Add(ReportsNames.InventoryStockAdjustRepName);
            aStringList.Add("<h2>" + "Added On" + " " + InventoryGeneral.Rows[0]["Date"].ToString() + "</h2>");
            aStringList.Add("<h2> " + "Added By" + ":&nbsp;&nbsp;" + UsersMgmt.SelectUserNameByID(int.Parse(InventoryGeneral.Rows[0]["TellerID"].ToString())) + "</h2>");

            aStringList.Add("<h2>" + ReceiptText.RctTxtReprintedOn + " " + DateTime.Now.ToShortDateString() + "&nbsp;&nbsp;" + DateTime.Now.ToShortTimeString() + "</h2>");
            aStringList.Add("<h2> " + ReceiptText.RctTxtReprintedBy + ":&nbsp;&nbsp;" + SharedFunctions.ReturnLoggedUserName() + "</h2>");

            aStringList.Add(ReceiptText.RctTxtInvoiceNum + ":&nbsp; " + ReferenceNumber);
            aStringList.Add(SharedVariables.Line_Solid_10px_Black);

            if (Preview)
            {
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", false, "", colored);
                return(true);
            }

            else if (ExportToPdf)
            {
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                return(true);
            }
            else if (ExportToExcel)
            {
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                return(true);
            }
            else if (PrintToThermal)
            {
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true, false, "", false, "", colored);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        private void ListItemsBtn_Click(object sender, EventArgs e)
        {
            try
            {
                ListItemsDgView.Rows.Clear();
                if (RndrPointChkBox.Checked)
                {
                    ItemsDatatable = ItemsMgmt.RenderPoint();
                }
                else
                {
                    ItemsDatatable = ItemsMgmt.SelectAllItems();
                }

                if (ItemsDatatable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListItemsBtn_Click:DB-ERROR  ItemsDatatable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


                TotalITemsTxtBox.Text = ItemsDatatable.Rows.Count.ToString();

                TaxLevelDataTable     = ItemTaxLevelMgmt.SelectAll();
                ItemCategoryDataTable = ItemCategoryMgmt.SelectAll();
                VendorsDataTable      = VendorsMgmt.SelectAllVendors();
                ItemsTypeDataTalbe    = ItemTypeMgmt.SelectAll();
                if (TaxLevelDataTable == null || ItemCategoryDataTable == null || VendorsDataTable == null || ItemsTypeDataTalbe == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListItemsBtn_Click:DB-ERROR  TaxLevelDataTable=null ||ItemCategoryDataTable=null || VendorsDataTable==null ||  ItemsTypeDataTalbe==null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                taxlevelrowsnumber     = TaxLevelDataTable.Rows.Count;
                itemcategoryrowsnumber = ItemCategoryDataTable.Rows.Count;
                vendorrowsnumber       = VendorsDataTable.Rows.Count;
                typerowsnumber         = ItemsTypeDataTalbe.Rows.Count;

                if (ItemsDatatable.Rows.Count > 0)
                {
                    //TestingFor Paging
                    pagesnumber = (int)ItemsDatatable.Rows.Count / ItemsPerPage;
                    if ((double.Parse(ItemsDatatable.Rows.Count.ToString()) / ItemsPerPage - int.Parse(ItemsDatatable.Rows.Count.ToString()) / ItemsPerPage) > 0)
                    {
                        pagesnumber++;
                    }

                    RowNum = 0;
                    ListItemsDgView.Rows.Clear();
                    foreach (DataRow r in ItemsDatatable.Rows)
                    {
                        if (ListItemsDgView.Rows.Count < ItemsPerPage)
                        {
                            ListItemsDgView.Rows.Add();
                            // TRIAL 2 CODE
                            ListItemsDgView.Rows[RowNum].Cells["Barcode"].Value = ItemsDatatable.Rows[RowNum]["Barcode"].ToString();
                            for (int i = 0; i < typerowsnumber; i++)
                            {
                                if (int.Parse(ItemsTypeDataTalbe.Rows[i]["ID"].ToString()) == int.Parse(ItemsDatatable.Rows[RowNum]["Type"].ToString()))
                                {
                                    ListItemsDgView.Rows[RowNum].Cells["Type"].Value = ItemsTypeDataTalbe.Rows[i]["Name"].ToString();
                                    break;
                                }
                            }
                            for (int i = 0; i < itemcategoryrowsnumber; i++)
                            {
                                if (int.Parse(ItemCategoryDataTable.Rows[i]["ID"].ToString()) == int.Parse(ItemsDatatable.Rows[RowNum]["Category"].ToString()))
                                {
                                    ListItemsDgView.Rows[RowNum].Cells["Category"].Value = ItemCategoryDataTable.Rows[i]["Name"].ToString();
                                    break;
                                }
                            }
                            for (int i = 0; i < taxlevelrowsnumber; i++)
                            {
                                if (int.Parse(TaxLevelDataTable.Rows[i]["ID"].ToString()) == int.Parse(ItemsDatatable.Rows[RowNum]["TaxLevel"].ToString()))
                                {
                                    ListItemsDgView.Rows[RowNum].Cells["TaxLevel"].Value = TaxLevelDataTable.Rows[i]["Percentage"].ToString();
                                    break;
                                }
                            }
                            for (int i = 0; i < vendorrowsnumber; i++)
                            {
                                if (int.Parse(VendorsDataTable.Rows[i]["ID"].ToString()) == int.Parse(ItemsDatatable.Rows[RowNum]["Vendor"].ToString()))
                                {
                                    ListItemsDgView.Rows[RowNum].Cells["Vendor"].Value = VendorsDataTable.Rows[i]["Name"].ToString();
                                    break;
                                }
                            }
                            ListItemsDgView.Rows[RowNum].Cells["Description"].Value = ItemsDatatable.Rows[RowNum]["Description"].ToString();
                            ListItemsDgView.Rows[RowNum].Cells["Qty"].Value         = ItemsDatatable.Rows[RowNum]["Qty"].ToString();
                            ListItemsDgView.Rows[RowNum].Cells["AvgUnitCost"].Value = Math.Round(double.Parse(ItemsDatatable.Rows[RowNum]["AvgUnitCost"].ToString()), 3);
                            ListItemsDgView.Rows[RowNum].Cells["SellPrice"].Value   = ItemsDatatable.Rows[RowNum]["SellPrice"].ToString();
                            ListItemsDgView.Rows[RowNum].Cells["RenderPoint"].Value = ItemsDatatable.Rows[RowNum]["RenderPoint"].ToString();
                            ListItemsDgView.Rows[RowNum].Cells["Margincol"].Value   = (Convert.ToDouble(ListItemsDgView.Rows[RowNum].Cells["SellPrice"].Value) - Convert.ToDouble(ListItemsDgView.Rows[RowNum].Cells["AvgUnitCost"].Value)) / Convert.ToDouble(ListItemsDgView.Rows[RowNum].Cells["AvgUnitCost"].Value) * 100;
                            ListItemsDgView.Rows[RowNum].Cells["DateAdded"].Value   = ItemsDatatable.Rows[RowNum]["EntryDate"].ToString();
                            RowNum++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListCustomersBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }

            /* TimeSpan ts = DateTime.Now.Subtract(StartTime);
             * string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
             *       ts.Hours, ts.Minutes, ts.Seconds,
             *       ts.Milliseconds / 10);*/
            PageOfTotalTxtBox.Text = "1/" + pagesnumber.ToString();
            currentpage            = 1;
            // Console.WriteLine(elapsedTime, "RunTime");

            // MessageBox.Show("Elasped Time in Seconds for [[1,300]] items [TRIAL 2 new code] is =" + elapsedTime);
        }
Exemplo n.º 5
0
        public bool InvValuationSummaryStatus(bool PrintToThermal, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool TableBorder = false, bool Preview = false, bool colored = false)
        {
            try
            {
                List <DataTable> aDTlist = new List <DataTable>();

                DataTable ItemsDatatable = ItemsMgmt.SelectAllItems();

                if (ItemsDatatable == null)
                {
                    return(false);
                }
                else
                {
                    if (ItemsDatatable.Rows.Count == 0)
                    {
                        return(false);
                    }
                }


                DataTable ToPrintTable = new DataTable();
                ToPrintTable.Columns.Add("Name");
                ToPrintTable.Columns.Add("Ava Qty");
                ToPrintTable.Columns.Add("Avg Cost");

                ToPrintTable.Columns.Add("Inventory Value");
                ToPrintTable.Columns.Add("% of Tot Inventory");

                ToPrintTable.Columns.Add("Selling Price");
                ToPrintTable.Columns.Add("Retail Value");
                ToPrintTable.Columns.Add("% of Tot Retail");

                double AvgCost = 0.00, AvaQty = 0.00, SellingPrice = 0.00;
                double TotalInvValue    = 0.00; /*this to be used in the second loop*/
                double TotalRetailValue = 0.00; /*this to be used in the second loop*/
                double TotalQty         = 0.00;
                foreach (DataRow r in ItemsDatatable.Rows)
                {
                    AvgCost      = double.Parse(r["AvgUnitCost"].ToString());
                    AvaQty       = double.Parse(r["Qty"].ToString());
                    SellingPrice = double.Parse(r["SellPrice"].ToString());

                    if (AvaQty <= 0)
                    {
                        continue;
                    }

                    TotalRetailValue += (SellingPrice * AvaQty);
                    TotalInvValue    += (AvgCost * AvaQty);
                }

                foreach (DataRow r in ItemsDatatable.Rows)
                {
                    AvgCost   = double.Parse(r["AvgUnitCost"].ToString());
                    AvaQty    = double.Parse(r["Qty"].ToString());
                    TotalQty += AvaQty;
                    if (AvaQty <= 0)
                    {
                        continue;
                    }
                    DataRow aRow = ToPrintTable.Rows.Add();
                    aRow["Name"]               = r["Description"];
                    aRow["Ava Qty"]            = Math.Round(AvaQty, 3);
                    aRow["Avg Cost"]           = Math.Round(AvgCost, 3);
                    aRow["Inventory Value"]    = Math.Round(AvgCost * AvaQty, 3);
                    SellingPrice               = double.Parse(r["SellPrice"].ToString());
                    aRow["Selling Price"]      = Math.Round(SellingPrice, 3);
                    aRow["Retail Value"]       = Math.Round(SellingPrice * AvaQty, 3);
                    aRow["% of Tot Inventory"] = Math.Round(((AvgCost * AvaQty) / TotalInvValue) * 100, 3).ToString() + " %";
                    aRow["% of Tot Retail"]    = Math.Round(((SellingPrice * AvaQty) / TotalRetailValue) * 100, 3).ToString() + " %";
                }

                DataRow FinalRow = ToPrintTable.Rows.Add();
                FinalRow["Name"]               = "<td style=\"text-decoration:underline;\">" + "T O T A L";
                FinalRow["Ava Qty"]            = "<td style=\"text-decoration:underline;\">" + Math.Round(TotalQty, 3);
                FinalRow["Avg Cost"]           = "<td style=\"text-decoration:underline;\">" + " ";
                FinalRow["Selling Price"]      = "<td style=\"text-decoration:underline;\">" + " ";
                FinalRow["Inventory Value"]    = "<td style=\"text-decoration:underline;\">" + Math.Round(TotalInvValue, 3);
                FinalRow["Retail Value"]       = "<td style=\"text-decoration:underline;\">" + Math.Round(TotalRetailValue, 3);
                FinalRow["% of Tot Inventory"] = "<td style=\"text-decoration:underline;\">" + "100%";
                FinalRow["% of Tot Retail"]    = "<td style=\"text-decoration:underline;\">" + "100%";

                if (TableBorder)
                {
                    ToPrintTable.Columns[0].ColumnName = "[Border=true1]" + ToPrintTable.Columns[0].ColumnName;
                }

                aDTlist.Add(ToPrintTable);
                List <string> aHeaderList = ReportsHelper.ImportReportHeader(0, 1);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);

                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);

                aHeaderList.Add("<b><font size=4>" + Text.ReportsNames.InvvaluationSummaryRepNm + " </font>");

                aHeaderList.Add("<b><font size=2>" + Text.ReportsText.DateRepTxt + ": " + DateTime.Now.ToShortDateString() + " </font>");
                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
                if (Preview)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", false, "", colored);
                    return(true);
                }

                else if (ExportToPdf)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                    return(true);
                }
                else if (ExportToExcel)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                    return(true);
                }
                else if (PrintToThermal)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true, false, "", false, "", colored);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 6
0
        public bool PrintItemsList(bool RenderPoint, bool PrintToThermal, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool TableBorder = false, bool Preview = false, bool colored = false)
        {
            try
            {
                List <DataTable> aDTlist        = new List <DataTable>();
                DataTable        ItemsDatatable = null;

                if (RenderPoint)
                {
                    ItemsDatatable = ItemsMgmt.RenderPoint();
                }
                else
                {
                    ItemsDatatable = ItemsMgmt.SelectAllItems();
                }
                if (ItemsDatatable == null)
                {
                    return(false);
                }
                else
                {
                    if (ItemsDatatable.Rows.Count == 0)
                    {
                        return(false);
                    }
                }

                DataTable ItemCategoryDataTable  = ItemCategoryMgmt.SelectAll();
                DataTable VendorsDataTable       = VendorsMgmt.SelectAllVendors();
                DataTable ItemsTypeDataTalbe     = ItemTypeMgmt.SelectAll();
                int       itemcategoryrowsnumber = ItemCategoryDataTable.Rows.Count;
                int       vendorrowsnumber       = VendorsDataTable.Rows.Count;
                int       typerowsnumber         = ItemsTypeDataTalbe.Rows.Count;

                DataTable ToPrintTable = new DataTable();
                ToPrintTable.Columns.Add("Barcode");
                ToPrintTable.Columns.Add("Description");
                ToPrintTable.Columns.Add("Ava.Qty");
                ToPrintTable.Columns.Add("Avg Cost");
                ToPrintTable.Columns.Add("Type");
                ToPrintTable.Columns.Add("Category");
                ToPrintTable.Columns.Add("Pref.Vendor");
                if (RenderPoint)
                {
                    ToPrintTable.Columns.Add("Phone");
                }

                foreach (DataRow r in ItemsDatatable.Rows)
                {
                    DataRow aRow = ToPrintTable.Rows.Add();
                    aRow["Barcode"]     = r["Barcode"];
                    aRow["Description"] = r["Description"];
                    aRow["Ava.Qty"]     = Math.Round(double.Parse(r["Qty"].ToString()), 3);
                    aRow["Avg Cost"]    = Math.Round(double.Parse(r["AvgUnitCost"].ToString()), 3);
                    for (int i = 0; i < typerowsnumber; i++)
                    {
                        if (int.Parse(ItemsTypeDataTalbe.Rows[i]["ID"].ToString()) == int.Parse(r["Type"].ToString()))
                        {
                            aRow["Type"] = ItemsTypeDataTalbe.Rows[i]["Name"].ToString();
                            break;
                        }
                    }
                    for (int i = 0; i < itemcategoryrowsnumber; i++)
                    {
                        if (int.Parse(ItemCategoryDataTable.Rows[i]["ID"].ToString()) == int.Parse(r["Category"].ToString()))
                        {
                            aRow["Category"] = ItemCategoryDataTable.Rows[i]["Name"].ToString();
                            break;
                        }
                    }

                    for (int i = 0; i < vendorrowsnumber; i++)
                    {
                        if (int.Parse(VendorsDataTable.Rows[i]["ID"].ToString()) == int.Parse(r["Vendor"].ToString()))
                        {
                            aRow["Pref.Vendor"] = VendorsDataTable.Rows[i]["Name"].ToString();
                            if (RenderPoint)
                            {
                                aRow["Phone"] = VendorsDataTable.Rows[i]["Phone1"].ToString();
                            }
                            break;
                        }
                    }
                }

                if (TableBorder)
                {
                    ToPrintTable.Columns[0].ColumnName = "[Border=true1]" + ToPrintTable.Columns[0].ColumnName;
                }
                if (RenderPoint)
                {
                    ToPrintTable.Columns.Remove("Category");
                }
                ToPrintTable.Columns["Description"].ColumnName = ("<th width=30%> Description");
                ToPrintTable.Columns.Remove("Type");
                aDTlist.Add(ToPrintTable);
                List <string> aHeaderList = ReportsHelper.ImportReportHeader(0, 1);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);

                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
                if (RenderPoint)
                {
                    aHeaderList.Add("<b><font size=4>" + Text.ReportsNames.RenPointListRepNm + " </font>");
                }
                else
                {
                    aHeaderList.Add("<b><font size=4>" + Text.ReportsNames.ItemsListRepNm + " </font>");
                }

                aHeaderList.Add("<b><font size=2>" + Text.ReportsText.DateRepTxt + ": " + DateTime.Now.ToShortDateString() + " </font>");
                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
                if (Preview)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", false, "", colored);
                    return(true);
                }

                else if (ExportToPdf)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                    return(true);
                }
                else if (ExportToExcel)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                    return(true);
                }
                else if (PrintToThermal)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true, false, "", false, "", colored);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 7
0
        public bool PrintPhysicalItemsStatus(bool PrintToThermal, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool TableBorder = false, bool Preview = false, bool colored = false)
        {
            try
            {
                List <DataTable> aDTlist        = new List <DataTable>();
                DataTable        ItemsDatatable = ItemsMgmt.SelectAllItems();

                if (ItemsDatatable == null)
                {
                    return(false);
                }
                else
                {
                    if (ItemsDatatable.Rows.Count == 0)
                    {
                        return(false);
                    }
                }

                DataTable ToPrintTable = new DataTable();
                ToPrintTable.Columns.Add("Barcode");
                ToPrintTable.Columns.Add("Description");
                ToPrintTable.Columns.Add("Ava.Qty");
                ToPrintTable.Columns.Add("Physical Count");

                foreach (DataRow r in ItemsDatatable.Rows)
                {
                    DataRow aRow = ToPrintTable.Rows.Add();
                    aRow["Barcode"]        = r["Barcode"];
                    aRow["Description"]    = r["Description"];
                    aRow["Ava.Qty"]        = Math.Round(double.Parse(r["Qty"].ToString()), 3);
                    aRow["Physical Count"] = "________";
                }

                if (TableBorder)
                {
                    ToPrintTable.Columns[0].ColumnName = "[Border=true1]" + ToPrintTable.Columns[0].ColumnName;
                }

                aDTlist.Add(ToPrintTable);
                List <string> aHeaderList = ReportsHelper.ImportReportHeader(0, 1);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);

                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);

                aHeaderList.Add("<b><font size=4>" + Text.ReportsNames.PhysicalInvWorksheetRepNm + " </font>");

                aHeaderList.Add("<b><font size=2>" + Text.ReportsText.DateRepTxt + ": " + DateTime.Now.ToShortDateString() + " </font>");
                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
                if (Preview)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", false, "", colored);
                    return(true);
                }

                else if (ExportToPdf)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                    return(true);
                }
                else if (ExportToExcel)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                    return(true);
                }
                else if (PrintToThermal)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true, false, "", false, "", colored);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }