Exemple #1
0
        private bool AddDisposalGeneral()
        {
            if (TeldgView.Rows.Count > 0)
            {
                if (DisposalReasonComboBox.SelectedValue == null)
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + " " + MsgTxt.DisposalReasonTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }

                DisposalGeneral aDisposalGeneral = FillDisposalGeneral();
                if (aDisposalGeneral == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                if (!DisposalGeneralMgmt.InsertDisposal(aDisposalGeneral))
                {
                    return(false);
                }
                DisposalDetailed aDisposalDetailed = new DisposalDetailed();
                foreach (DataGridViewRow r in TeldgView.Rows)
                {
                    if (!r.IsNewRow)
                    {
                        aDisposalDetailed.Disposal_Detailed_ItemID          = ItemsMgmt.SelectItemIDByBarcode(TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString());
                        aDisposalDetailed.Disposal_Detailed_ItemDescription = TeldgView.Rows[r.Index].Cells["Description"].Value.ToString();
                        aDisposalDetailed.Disposal_Detailed_Date            = DateTime.Now.ToShortDateString();
                        double TestParser = 0;
                        if (double.TryParse(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString(), out TestParser))
                        {
                            aDisposalDetailed.Disposal_Detailed_Qty = TestParser;//double.Parse(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString());
                        }
                        else
                        {
                            TestParser = 1;
                        }
                        aDisposalDetailed.Disposal_Detailed_UnitCost      = double.Parse(TeldgView.Rows[r.Index].Cells["PricePerUnit"].Value.ToString());
                        aDisposalDetailed.Disposal_Detailed_TotalPerUnit  = double.Parse(TeldgView.Rows[r.Index].Cells["PriceTotal"].Value.ToString());
                        aDisposalDetailed.Disposal_Detailed_GeneralNumber = aDisposalGeneral.Disposal_General_Number;
                        DisposalDetailedMgmt.InsertDisposalItem(aDisposalDetailed);
                        string Barcode = TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString();
                        ItemsMgmt.UpdateItemQtyByBarcode(Barcode, ItemsMgmt.SelectItemQtyByBarcode(Barcode), (0 - TestParser));//0-qty wich is negative to be subtracted from orginnal
                    }
                }
                return(true);
            }
            else
            {
                MessageBox.Show(MsgTxt.NotItemsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
        }
Exemple #2
0
        public static bool ItemStatusReport(int ItemID, string DateFrom, string DateTo, bool TableBorder = false, bool Preview = true, bool PrintToThermal = false, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool colored = false)
        {
            if (!ItemsMgmt.IsItemExistByID(ItemID))
            {
                return(false);
            }
            string           EmptyNoborderRow = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsHelper.MANUAL_TD_END;
            List <DataTable> aDTlist          = new List <DataTable>();
            DataTable        aTable1          = new DataTable();

            if (TableBorder)
            {
                aTable1.Columns.Add("[Border=true1]" + "Barcode");
            }
            else
            {
                aTable1.Columns.Add("Barcode");
            }
            aTable1.Columns.Add("Description");
            aTable1.Columns.Add("Type");
            aTable1.Columns.Add("Qty");

            DataRow aItemRow = ItemsMgmt.SelectItemRowByID(ItemID);
            bool    AddEmpty = false;
            double  NetTotal = 0.00;
            DataRow __PoorRow;

            double OnHandQty             = double.Parse(aItemRow["OnHandQty"].ToString());
            double TotalBeforeBills      = BillDetailedMgmt.SelectAllSoldQty(ItemID, DateFrom, DateTo, 0, true);
            double TotalBeforeAdjust     = AdjustInventoryDetailedMgmt.SelectAllAdjustQty(ItemID, DateFrom, DateTo, -1, true);
            double TotalBeforeDispose    = DisposalDetailedMgmt.SelectAllDisposedQty(ItemID, DateFrom, DateTo, 0, true);
            double TotalBeforePurchase   = PurchaseVoucherDetailedMgmt.SelectAllPurchaseQty(ItemID, DateFrom, DateTo, 0, true);
            double TotalBeforeCusRet     = ReturnItemsCustDetailedMGMT.SelectAllReturnedQty(ItemID, DateFrom, DateTo, 0, true);
            double TotalBeforeVenReturns = ReturnItemsVendorDetailedMgmt.SelectAllReturnedQty(ItemID, DateFrom, DateTo, 0, true);

            double BegginingQty = OnHandQty - TotalBeforeBills + TotalBeforeAdjust - TotalBeforeDispose + TotalBeforePurchase + TotalBeforeCusRet - TotalBeforeVenReturns;

            if (BegginingQty != 0)
            {
                NetTotal    += BegginingQty;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Beginning Qty";
                __PoorRow[3] = Math.Round(BegginingQty, 3);
                AddEmpty     = true;
            }

            double TotalBills         = BillDetailedMgmt.SelectAllSoldQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedBills = BillDetailedMgmt.SelectAllSoldQty(ItemID, DateFrom, DateTo, 1);

            if (TotalBills != 0)
            {
                NetTotal    -= TotalBills;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Sales";
                __PoorRow[3] = Math.Round(0.00 - TotalBills, 3);
                AddEmpty     = true;
            }
            if (TotalReversedBills != 0)
            {
                NetTotal    += TotalReversedBills;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Reversed Sales";
                __PoorRow[3] = Math.Round((TotalReversedBills), 3);
                AddEmpty     = true;
            }

            double TotalAdjust = AdjustInventoryDetailedMgmt.SelectAllAdjustQty(ItemID, DateFrom, DateTo, -1);

            if (TotalAdjust != 0)
            {
                NetTotal    += TotalAdjust;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Inventory Adjust";
                __PoorRow[3] = Math.Round(TotalAdjust, 3);
                AddEmpty     = true;
            }
            double TotalDisposed         = DisposalDetailedMgmt.SelectAllDisposedQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedDisposed = DisposalDetailedMgmt.SelectAllDisposedQty(ItemID, DateFrom, DateTo, 1);

            if (TotalDisposed != 0)
            {
                NetTotal    -= TotalDisposed;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Disposed";
                __PoorRow[3] = Math.Round(0.00 - TotalDisposed, 3);
                AddEmpty     = true;
            }
            if (TotalReversedDisposed != 0)
            {
                NetTotal    += TotalReversedDisposed;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Reversed Disposals";
                __PoorRow[3] = Math.Round((0.00 - TotalReversedDisposed), 3);
                AddEmpty     = true;
            }
            double TotalPurchase         = PurchaseVoucherDetailedMgmt.SelectAllPurchaseQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedPurchase = PurchaseVoucherDetailedMgmt.SelectAllPurchaseQty(ItemID, DateFrom, DateTo, 1);

            if (TotalPurchase != 0)
            {
                NetTotal    += TotalPurchase;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Purchase";
                __PoorRow[3] = Math.Round((TotalPurchase), 3);
                AddEmpty     = true;
            }
            if (TotalReversedPurchase != 0)
            {
                NetTotal    -= TotalReversedPurchase;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Reversed Purchase";
                __PoorRow[3] = Math.Round((0.00 - TotalReversedPurchase), 3);
                AddEmpty     = true;
            }
            double TotalCustomerReturns         = ReturnItemsCustDetailedMGMT.SelectAllReturnedQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedCustomerReturns = ReturnItemsCustDetailedMGMT.SelectAllReturnedQty(ItemID, DateFrom, DateTo, 1);

            if (TotalCustomerReturns != 0)
            {
                NetTotal    += TotalCustomerReturns;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Customer Returns";
                __PoorRow[3] = Math.Round((TotalCustomerReturns), 3);
                AddEmpty     = true;
            }
            if (TotalReversedCustomerReturns != 0)
            {
                NetTotal    -= TotalReversedCustomerReturns;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Reversed Customer Returns";
                __PoorRow[3] = Math.Round((0.00 - TotalReversedCustomerReturns), 3);
                AddEmpty     = true;
            }
            double TotalVendorReturns         = ReturnItemsVendorDetailedMgmt.SelectAllReturnedQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedVendorReturns = ReturnItemsVendorDetailedMgmt.SelectAllReturnedQty(ItemID, DateFrom, DateTo, 1);

            if (TotalVendorReturns != 0)
            {
                NetTotal    -= TotalVendorReturns;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Vendors Returns";
                __PoorRow[3] = Math.Round((0.00 - TotalVendorReturns), 3);
                AddEmpty     = true;
            }
            if (TotalReversedVendorReturns != 0)
            {
                NetTotal    += TotalReversedVendorReturns;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Reversed Vendors Returns";
                __PoorRow[3] = Math.Round((TotalReversedVendorReturns), 3);
                AddEmpty     = true;
            }

            if (NetTotal != 0)
            {
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.MANUAL_TD_OPTION_END + "TOTAL" + ReportsHelper.MANUAL_TD_END;
                __PoorRow[3] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.MANUAL_TD_OPTION_END + Math.Round((NetTotal), 3) + ReportsHelper.MANUAL_TD_END;
                AddEmpty     = true;
            }
            aDTlist.Add(aTable1);

            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.ItemSymmaryStatusRepName + " </font>");
            aHeaderList.Add("<b><font size=4>" + Text.ReportsText.DateRepTxt + ": " + DateTime.Now.ToShortDateString() + " </font>");
            aHeaderList.Add("<b><font size=4>" + Text.ReportsText.FromRepTxt + ": " + DateFrom + " " + Text.ReportsText.ToRepTxt + ": " + DateTo + " </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);
            }
        }