Exemplo n.º 1
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.º 2
0
        public void UpdateVariables(DataRow aGeneralVoucherDataRow)
        {
            try
            {
                aPurchaseDataRow = aGeneralVoucherDataRow;
                PurchaseVoucherNumTxtBox.Text = aGeneralVoucherDataRow["VoucherNumber"].ToString();
                aVendorDataRow = VendorsMgmt.SelectVendorRowByID(int.Parse(aGeneralVoucherDataRow["VendorID"].ToString()));
                if (aVendorDataRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCustomerRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditVoucher-SelectVendorRowByID Returned Null");
                }

                VendorsComboBox.Text         = aVendorDataRow["Name"].ToString();
                VendorDescriptionTxtBox.Text = aVendorDataRow["Company"].ToString();
                //account amount is latered to iscredit
                DateLbl.Text   = DateTime.Parse(aGeneralVoucherDataRow["Date"].ToString()).ToShortDateString();
                TimeLbl.Text   = DateTime.Parse(aGeneralVoucherDataRow["Time"].ToString()).ToShortTimeString();
                TellerLbl.Text = UsersMgmt.SelectUserNameByID(int.Parse(aGeneralVoucherDataRow["TellerID"].ToString()));
                if (TellerLbl.Text == null)
                {
                    //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-UsersMgmt.UsrById Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("[EditVoucher-UsersMgmt.UsrById Returned Null]");
                }
                //DOWN RIGHT
                SubtotalTxtBox.Text      = aGeneralVoucherDataRow["Subtotal"].ToString();
                DiscountPercTxtBox.Text  = aGeneralVoucherDataRow["DiscountPerc"].ToString();
                DiscountTxtBox.Text      = (float.Parse(SubtotalTxtBox.Text) * float.Parse(DiscountPercTxtBox.Text) / 100).ToString();
                ItemsDiscountTxtBox.Text = aGeneralVoucherDataRow["TotalItemsDiscount"].ToString();
                TotalDiscountTxtBox.Text = aGeneralVoucherDataRow["TotalDiscount"].ToString();
                TotalTaxTxtBox.Text      = aGeneralVoucherDataRow["TotalTax"].ToString();
                FeesTxtBox.Text          = aGeneralVoucherDataRow["Fees"].ToString();
                TotalTxtBox.Text         = aGeneralVoucherDataRow["TotalCost"].ToString();
                //GroupBox1 Elements
                if (aPurchaseDataRow["IsRevised"].ToString() == "1")
                {
                    ReviseInfoGB.Show();
                    ReviseDatelbl.Text       = DateTime.Parse(aPurchaseDataRow["ReviseDate"].ToString()).ToShortDateString();
                    ReviseTime.Text          = DateTime.Parse(aPurchaseDataRow["ReviseTime"].ToString()).ToShortTimeString();
                    RevisedBylbl.Text        = aPurchaseDataRow["RevisedBy"].ToString();
                    IsRevisedLbl.Visible     = true;
                    ReviseLossProfitLbl.Text = aPurchaseDataRow["ReviseLoss"].ToString();
                }
                else
                {
                    ReviseInfoGB.Hide();
                }

                if (aPurchaseDataRow["IsChecked"].ToString() == "1")
                {
                    ChkedByUserNameLbl.Text = aPurchaseDataRow["CheckedBy"].ToString();

                    ChkDateLbl.Text = DateTime.Parse(aPurchaseDataRow["CheckDate"].ToString()).ToShortDateString();
                    CheckTime.Text  = DateTime.Parse(aPurchaseDataRow["CheckTime"].ToString()).ToShortTimeString();
                    CheckInfoGB.Show();
                }
                else
                {
                    CheckInfoGB.Hide();
                }
                //PaymentInformation
                DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aPurchaseDataRow["PaymentMethodID"].ToString()));
                if (aMethodRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectMethodRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditVoucher-SelectMethodRowByID Returned Null");
                }
                PaymentMethodCheckBox.Text      = aMethodRow["Name"].ToString();
                PaymentMethodDescripTxtBox.Text = aMethodRow["Description"].ToString();//PaymentMethodMgmt.SelectDescriptionByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()));
                if (aMethodRow["IsCash"].ToString() == "1")
                {
                    CashPaymentGB.Show();
                    CashPaymentGB.BringToFront();
                    PayInVisaGB.Hide();
                    CheckGB.Hide();
                }
                else if (aMethodRow["IsCredit"].ToString() == "1")
                {
                    PayInVisaGB.Show();
                    PayInVisaGB.BringToFront();
                    CashPaymentGB.Hide();
                    CheckGB.Hide();
                }
                else
                {
                    CheckGB.Show();
                    CheckGB.BringToFront();
                    CashPaymentGB.Hide();
                    PayInVisaGB.Hide();
                    CheckNumberTxtBox.Text = aPurchaseDataRow["CheckNumber"].ToString();
                    DataRow aCheckDataRow = ChecksMgmt.SelectCheckRowByNumber(int.Parse(aPurchaseDataRow["CheckNumber"].ToString()));
                    if (aCheckDataRow == null)
                    {
                        //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCheckRowByNumber Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw new Exception("EditVoucher-SelectCheckRowByNumber Returned Null");
                    }
                    HolderNameTxtBox.Text    = aCheckDataRow["HolderName"].ToString();
                    CheckCommentsTxtBox.Text = aCheckDataRow["Comments"].ToString();
                    CheckDatePicker.Text     = aCheckDataRow["PaymentDate"].ToString();
                }
                DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(int.Parse(aPurchaseDataRow["AccountID"].ToString()));
                if (aAccountRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectAccountRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectAccountRowByID Returned Null");
                }
                else
                {
                    AccountComboBox.Text          = aAccountRow["Name"].ToString();
                    AccountDescriptionTxtBox.Text = aAccountRow["Description"].ToString();
                    CurrencyComboBox.Text         = CurrencyMgmt.SelectCurrencyNameByID(int.Parse(aAccountRow["CurrencyID"].ToString()));
                    if (CurrencyComboBox.Text == null)
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditVoucher-SelectCurrencyNameByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                    CreditCardInfoTxtBox.Text = aPurchaseDataRow["CreditCardInfo"].ToString();
                }
                if (aPurchaseDataRow["IsCashCredit"].ToString() == "1")
                {
                    CashMethodComboBox.SelectedIndex = 1;
                    VendorAccountAmountTxtBox.Show();
                    VendorAccountAmountTxtBox.Text = aPurchaseDataRow["VendorAccountAmountOld"].ToString();
                    AccountComboBox.Hide();
                    AccountLbl.Hide();
                    CashInTxtBox.Hide();
                    ExchangeTxtBox.Hide();
                    CashInLbl.Hide();
                    ExchangeLbl.Hide();
                    JODstatic.Hide();
                    CurrencyLbl.Hide();
                    IsCreditLbl.Show();
                }
                else
                {
                    CashMethodComboBox.SelectedIndex = 0;
                    VendorAccountAmountTxtBox.Hide();
                    AccountComboBox.Show();
                    AccountLbl.Show();
                    CashInTxtBox.Show();
                    ExchangeTxtBox.Show();
                    CashInLbl.Show();
                    ExchangeLbl.Show();
                    JODstatic.Show();
                    CurrencyLbl.Show();
                    IsCreditLbl.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditVoucher-UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemplo n.º 3
0
        public void UpdateVariables(DataRow aCustomerPaymentRow)
        {
            try
            {
                PaymentNumberTxtBox.Text  = aCustomerPaymentRow["PaymentNumber"].ToString();
                aCustomerPaymentRowGlobal = aCustomerPaymentRow;

                DateLbl.Text   = DateTime.Parse(aCustomerPaymentRow["Date"].ToString()).ToShortDateString();
                TimeLbl.Text   = aCustomerPaymentRow["Time"].ToString();
                TellerLbl.Text = UsersMgmt.SelectUserNameByID(int.Parse(aCustomerPaymentRow["TellerID"].ToString()));
                if (TellerLbl.Text == null)
                {
                    //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-UsersMgmt.UsrById Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("[EditCustomerPayment-UsersMgmt.UsrById Returned Null]");
                }

                DataRow aCustomerRow = CustomerMgmt.SelectCustomerRowByID(int.Parse(aCustomerPaymentRow["CustomerID"].ToString()));
                if (aCustomerRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCustomerRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditCustomerPayment-SelectCustomerRowByID Returned Null");
                }

                CustomerPhoneTxtBox.Text = aCustomerRow["Phone1"].ToString();
                CustomerNameTxtBox.Text  = aCustomerRow["Name"].ToString();
                double OldBalance = double.Parse(aCustomerPaymentRow["OldUsrAccountAmount"].ToString());
                double Amount     = double.Parse(aCustomerPaymentRow["Amount"].ToString());
                double NewBalance = OldBalance - Amount;

                CustomerBalanceTxtBox.Text = OldBalance.ToString();
                NewBalanceTxtBox.Text      = NewBalance.ToString();

                aCustomerAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(int.Parse(aCustomerPaymentRow["CustomerID"].ToString()));
                if (aCustomerAccount == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCustomerRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditCustomerPayment-SelectCustomerAccountRowByCusID Returned Null");
                }
                CurrentBalanceTxtBox.Text = double.Parse(aCustomerAccount["Amount"].ToString()).ToString();

                PaymentAmountTxtBox.Text = Amount.ToString();
                CommentsTxtBox.Text      = aCustomerPaymentRow["Comments"].ToString();

                if (aCustomerPaymentRow["IsRevised"].ToString() == "1")
                {
                    ReviseInfoGB.Show();
                    ReviseDatelbl.Text   = DateTime.Parse(aCustomerPaymentRow["ReviseDate"].ToString()).ToShortDateString();
                    ReviseTime.Text      = aCustomerPaymentRow["ReviseTime"].ToString();
                    RevisedBylbl.Text    = aCustomerPaymentRow["RevisedBy"].ToString();
                    IsRevisedLbl.Visible = true;
                }
                else
                {
                    ReviseInfoGB.Hide();
                }

                if (aCustomerPaymentRow["IsChecked"].ToString() == "1")
                {
                    ChkedByUserNameLbl.Text = aCustomerPaymentRow["CheckedBy"].ToString();
                    ChkDateLbl.Text         = DateTime.Parse(aCustomerPaymentRow["CheckDate"].ToString()).ToShortDateString();
                    CheckTime.Text          = aCustomerPaymentRow["CheckTime"].ToString();
                    CheckInfoGB.Show();
                }
                else
                {
                    CheckInfoGB.Hide();
                }

                //PaymentInformation
                DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aCustomerPaymentRow["PaymentMethodID"].ToString()));
                if (aMethodRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectMethodRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditCustomerPayment-SelectMethodRowByID Returned Null");
                }
                PaymentMethodCheckBox.Text      = aMethodRow["Name"].ToString();
                PaymentMethodDescripTxtBox.Text = aMethodRow["Description"].ToString();//PaymentMethodMgmt.SelectDescriptionByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()));
                if (aMethodRow["IsCash"].ToString() == "1")
                {
                    CashPaymentGB.Show();
                    CashPaymentGB.BringToFront();
                    PayInVisaGB.Hide();
                    CheckGB.Hide();
                }
                else if (aMethodRow["IsCredit"].ToString() == "1")
                {
                    PayInVisaGB.Show();
                    PayInVisaGB.BringToFront();
                    CashPaymentGB.Hide();
                    CheckGB.Hide();
                }
                else
                {
                    CheckGB.Show();
                    CheckGB.BringToFront();
                    CashPaymentGB.Hide();
                    PayInVisaGB.Hide();
                    CheckNumberTxtBox.Text = aCustomerPaymentRow["CheckNumber"].ToString();
                    DataRow aCheckDataRow = ChecksMgmt.SelectCheckRowByNumber(int.Parse(aCustomerPaymentRow["CheckNumber"].ToString()));
                    if (aCheckDataRow == null)
                    {
                        //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCheckRowByNumber Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw new Exception("EditCustomerPayment-SelectCheckRowByNumber Returned Null");
                    }
                    HolderNameTxtBox.Text    = aCheckDataRow["HolderName"].ToString();
                    BanksComboBox.Text       = aCheckDataRow["BankName"].ToString();
                    CheckCommentsTxtBox.Text = aCheckDataRow["Comments"].ToString();
                    CheckDatePicker.Text     = aCheckDataRow["PaymentDate"].ToString();
                }

                DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(int.Parse(aCustomerPaymentRow["AccountID"].ToString()));
                if (aAccountRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectAccountRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditCustomerPayment-SelectAccountRowByID Returned Null");
                }
                else
                {
                    AccountComboBox.Text          = aAccountRow["Name"].ToString();
                    AccountDescriptionTxtBox.Text = aAccountRow["Description"].ToString();
                    CreditCardInfoTxtBox.Text     = aCustomerPaymentRow["CreditCardInfo"].ToString();
                    AccountBalanceTxtBox.Text     = aAccountRow["Amount"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditCustomerPayment-UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemplo n.º 4
0
        public void UpdateVariables(DataRow aGeneralBillDataRow)
        {
            try
            {
                aBillGeneralRow = aGeneralBillDataRow;

                InvoiceNumTxtBox.Text = aGeneralBillDataRow["Number"].ToString();

                DateLbl.Text = DateTime.Parse(aGeneralBillDataRow["Date"].ToString()).ToShortDateString();

                TimeLbl.Text = aGeneralBillDataRow["BillTime"].ToString();

                TellerLbl.Text = UsersMgmt.SelectUserNameByID(int.Parse(aGeneralBillDataRow["TellerID"].ToString()));
                if (TellerLbl.Text == null)
                {
                    //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-UsersMgmt.UsrById Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("[EditBill-UsersMgmt.UsrById Returned Null]");
                }
                aUserDataRow = CustomerMgmt.SelectCustomerRowByID(int.Parse(aGeneralBillDataRow["CustomerID"].ToString()));
                if (aUserDataRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCustomerRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectCustomerRowByID Returned Null");
                }
                PriceLevelComboBox.Text = PriceLevelsMgmt.SelectPriceLevelNameByID(int.Parse(aGeneralBillDataRow["PriceLevelID"].ToString()));
                if (PriceLevelComboBox.Text == null)
                {
                    //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectPriceLevelNameByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectPriceLevelNameByID Returned Null");
                }
                PhoneTxtBox.Text        = aUserDataRow["Phone1"].ToString();
                CustomerNameTxtBox.Text = aUserDataRow["Name"].ToString();
                CommentsTxtBox.Text     = aGeneralBillDataRow["Comments"].ToString();
                PriceLevelDiscount.Text = aGeneralBillDataRow["SalesDiscount"].ToString();
                DiscountPercTxtBox.Text = aGeneralBillDataRow["DiscountPerc"].ToString();
                SubtotalTxtBox.Text     = aGeneralBillDataRow["Subtotal"].ToString();
                NetAmountTxtBox.Text    = aGeneralBillDataRow["NetAmount"].ToString();
                TaxTxtBox.Text          = aGeneralBillDataRow["TotalTax"].ToString();
                DiscountBillTxtBox.Text = (double.Parse(DiscountPercTxtBox.Text) / 100 * double.Parse(NetAmountTxtBox.Text)).ToString();

                TotalDiscountTxtBox.Text = aGeneralBillDataRow["TotalDiscount"].ToString();
                TotalTxtBox.Text         = aGeneralBillDataRow["TotalPrice"].ToString();

                if (aGeneralBillDataRow["IsRevised"].ToString() == "1")
                {
                    ReviseInfoGB.Show();
                    ReviseDatelbl.Text       = DateTime.Parse(aGeneralBillDataRow["ReviseDate"].ToString()).ToShortDateString();
                    RevisedBylbl.Text        = aGeneralBillDataRow["RevisedBy"].ToString();
                    IsRevisedLbl.Visible     = true;
                    ReviseLossProfitLbl.Text = aGeneralBillDataRow["ReviseLoss"].ToString();
                }
                else
                {
                    ReviseInfoGB.Hide();
                }

                if (aGeneralBillDataRow["IsChecked"].ToString() == "1")
                {
                    ChkedByUserNameLbl.Text = aGeneralBillDataRow["CheckedBy"].ToString();
                    ChkDateLbl.Text         = DateTime.Parse(aGeneralBillDataRow["CheckedDate"].ToString()).ToShortDateString();
                    CheckInfoGB.Show();
                }
                else
                {
                    CheckInfoGB.Hide();
                }

                //PaymentInformation
                DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aGeneralBillDataRow["PaymentMethodID"].ToString()));
                if (aMethodRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectMethodRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectMethodRowByID Returned Null");
                }
                PaymentMethodCheckBox.Text      = aMethodRow["Name"].ToString();
                PaymentMethodDescripTxtBox.Text = aMethodRow["Description"].ToString();//PaymentMethodMgmt.SelectDescriptionByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()));

                if (aMethodRow["IsCash"].ToString() == "1")
                {
                    CashPaymentGB.Show();
                    CashPaymentGB.BringToFront();
                    PayInVisaGB.Hide();
                    CheckGB.Hide();
                }
                else if (aMethodRow["IsCredit"].ToString() == "1")
                {
                    PayInVisaGB.Show();
                    PayInVisaGB.BringToFront();
                    CashPaymentGB.Hide();
                    CheckGB.Hide();
                }
                else
                {
                    CheckGB.Show();
                    CheckGB.BringToFront();
                    CashPaymentGB.Hide();
                    PayInVisaGB.Hide();
                    CheckNumberTxtBox.Text = aGeneralBillDataRow["CheckNumber"].ToString();

                    DataRow aCheckDataRow = ChecksMgmt.SelectCheckRowByNumber(int.Parse(aGeneralBillDataRow["CheckNumber"].ToString()));
                    if (aCheckDataRow == null)
                    {
                        //MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCheckRowByNumber Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw new Exception("EditBill-SelectCheckRowByNumber Returned Null");
                    }

                    HolderNameTxtBox.Text    = aCheckDataRow["HolderName"].ToString();
                    CheckCommentsTxtBox.Text = aCheckDataRow["Comments"].ToString();
                    CheckDatePicker.Text     = aCheckDataRow["PaymentDate"].ToString();
                }

                DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(int.Parse(aGeneralBillDataRow["AccountID"].ToString()));
                if (aAccountRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectAccountRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditBill-SelectAccountRowByID Returned Null");
                }
                else
                {
                    AccountComboBox.Text          = aAccountRow["Name"].ToString();
                    AccountDescriptionTxtBox.Text = aAccountRow["Description"].ToString();

                    CurrencyComboBox.Text = CurrencyMgmt.SelectCurrencyNameByID(int.Parse(aGeneralBillDataRow["CurrencyID"].ToString()));
                    if (CurrencyComboBox.Text == null)
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectCurrencyNameByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                    CashInCurrency.Text       = CurrencyComboBox.Text;
                    CashInTxtBox.Text         = aGeneralBillDataRow["CashIn"].ToString();
                    BuyRateTxtBox.Text        = CurrencyMgmt.SelectBuyRateByID(int.Parse(aGeneralBillDataRow["CurrencyID"].ToString())).ToString();
                    SellRateTxtBox.Text       = CurrencyMgmt.SelectSellRateByID(int.Parse(aGeneralBillDataRow["CurrencyID"].ToString())).ToString();
                    ExchangeTxtBox.Text       = (double.Parse(CashInTxtBox.Text) * double.Parse(BuyRateTxtBox.Text) - double.Parse(TotalTxtBox.Text)).ToString();
                    CreditCardInfoTxtBox.Text = aGeneralBillDataRow["CreditCardInfo"].ToString();
                }

                if (aBillGeneralRow["IsCashCredit"].ToString() == "1")
                {
                    CashMethodComboBox.SelectedIndex = 1;

                    //CustomerAccountAmountlbl.Show();
                    CustomerAccountAmountTxtBox.Show();
                    CustomersAccountAmount.Show();

                    CustomerAccountAmountTxtBox.Text = aBillGeneralRow["CustomerAccountAmountOld"].ToString();
                    CashInTxtBox.Hide();
                    ExchangeTxtBox.Hide();
                    CashInLbl.Hide();
                    ExchangeLbl.Hide();
                    JODstatic.Hide();
                    CurrencyLbl.Hide();
                    IsCreditLbl.Show();
                }
                else
                {
                    CashMethodComboBox.SelectedIndex = 0;
                    //CustomerAccountAmountlbl.Hide();
                    CustomerAccountAmountTxtBox.Hide();
                    CustomersAccountAmount.Hide();

                    CashInTxtBox.Show();
                    ExchangeTxtBox.Show();
                    CashInLbl.Show();
                    ExchangeLbl.Show();
                    JODstatic.Show();
                    CurrencyLbl.Show();

                    IsCreditLbl.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Exemplo n.º 5
0
        public void UpdateVariables(DataRow aVendorPaymentRow)
        {
            try
            {
                PaymentNumberTxtBox.Text = aVendorPaymentRow["PaymentNumber"].ToString();
                aVendorPaymentRowGlobal  = aVendorPaymentRow;
                DateLbl.Text             = DateTime.Parse(aVendorPaymentRow["Date"].ToString()).ToShortDateString();
                TimeLbl.Text             = aVendorPaymentRow["Time"].ToString();
                TellerLbl.Text           = UsersMgmt.SelectUserNameByID(int.Parse(aVendorPaymentRow["TellerID"].ToString()));

                DataRow aVendorRow = VendorsMgmt.SelectVendorRowByID(int.Parse(aVendorPaymentRow["VendorID"].ToString()));
                if (aVendorRow == null)
                {
                    throw new Exception("LOWER in aVendorRow==null");
                }
                VendorNameTxtBox.Text    = aVendorRow["Name"].ToString();
                VendorCompanyTxtBox.Text = aVendorRow["Company"].ToString();
                double OldBalance = double.Parse(aVendorPaymentRow["OldVendorAccountAmount"].ToString());
                double Amount     = double.Parse(aVendorPaymentRow["Amount"].ToString());
                double NewBalance = OldBalance - Amount;//+ because its reversed
                VendorAccountBalanceTxtBox.Text = OldBalance.ToString();
                NewBalanceTxtBox.Text           = NewBalance.ToString();

                aAccount = AccountsMgmt.SelectAccountRowByID(int.Parse(aVendorPaymentRow["MyAccountID"].ToString()));
                if (aAccount == null)
                {
                    throw new Exception("LOWER in aAccount == null");
                }
                AccountDescriptionTxtBox.Text = aAccount["Description"].ToString();

                aVendorAccount = VendorsAccountsMgmt.SelectVendorAccountRowByVendorID(int.Parse(aVendorPaymentRow["VendorID"].ToString()));
                if (aVendorAccount == null)
                {
                    throw new Exception("LOWER in aVendorAccount == null");
                }
                CurrentBalanceTxtBox.Text = double.Parse(aVendorAccount["Amount"].ToString()).ToString();
                PaymentAmountTxtBox.Text  = Amount.ToString();
                CommentsTxtBox.Text       = aVendorPaymentRow["Comments"].ToString();
                if (aVendorPaymentRow["IsRevised"].ToString() == "1")
                {
                    ReviseInfoGB.Show();
                    ReviseDatelbl.Text   = DateTime.Parse(aVendorPaymentRow["ReviseDate"].ToString()).ToShortDateString();
                    ReviseTime.Text      = aVendorPaymentRow["ReviseTime"].ToString();
                    RevisedBylbl.Text    = aVendorPaymentRow["RevisedBy"].ToString();
                    IsRevisedLbl.Visible = true;
                }
                else
                {
                    ReviseInfoGB.Hide();
                }

                if (aVendorPaymentRow["IsChecked"].ToString() == "1")
                {
                    ChkedByUserNameLbl.Text = aVendorPaymentRow["CheckedBy"].ToString();
                    ChkDateLbl.Text         = DateTime.Parse(aVendorPaymentRow["CheckDate"].ToString()).ToShortDateString();
                    CheckTime.Text          = aVendorPaymentRow["CheckTime"].ToString();
                    CheckInfoGB.Show();
                }
                else
                {
                    CheckInfoGB.Hide();
                }

                //PaymentInformation
                DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aVendorPaymentRow["PaymentMethodID"].ToString()));
                if (aMethodRow == null)
                {
                    throw new Exception("LOWER in aMethodRow == null");
                }
                PaymentMethodCheckBox.Text      = aMethodRow["Name"].ToString();
                PaymentMethodDescripTxtBox.Text = aMethodRow["Description"].ToString();//PaymentMethodMgmt.SelectDescriptionByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()));
                if (aMethodRow["IsCash"].ToString() == "1")
                {
                    CashPaymentGB.Show();
                    CashPaymentGB.BringToFront();
                    PayInVisaGB.Hide();
                    CheckGB.Hide();
                }
                else if (aMethodRow["IsCredit"].ToString() == "1")
                {
                    PayInVisaGB.Show();
                    PayInVisaGB.BringToFront();
                    CashPaymentGB.Hide();
                    CheckGB.Hide();
                }
                else
                {
                    CheckGB.Show();
                    CheckGB.BringToFront();
                    CashPaymentGB.Hide();
                    PayInVisaGB.Hide();
                    CheckNumberTxtBox.Text = aVendorPaymentRow["CheckNumber"].ToString();
                    DataRow aCheckDataRow = ChecksMgmt.SelectCheckRowByNumber(int.Parse(aVendorPaymentRow["CheckNumber"].ToString()));
                    if (aCheckDataRow == null)
                    {
                        throw new Exception("LOWER in aCheckDataRow == null");
                    }
                    HolderNameTxtBox.Text    = aCheckDataRow["HolderName"].ToString();
                    CheckCommentsTxtBox.Text = aCheckDataRow["Comments"].ToString();
                    CheckDatePicker.Text     = DateTime.Parse(aCheckDataRow["PaymentDate"].ToString()).ToShortDateString();
                }
                DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(int.Parse(aVendorPaymentRow["MyAccountID"].ToString()));
                if (aAccountRow == null)
                {
                    throw new Exception("LOWER in aAccountRow == null");
                }
                AccountComboBox.Text          = aAccountRow["Name"].ToString();
                AccountDescriptionTxtBox.Text = aAccountRow["Description"].ToString();
                CreditCardInfoTxtBox.Text     = aVendorPaymentRow["CreditCardInfo"].ToString();
                AccountBalanceTxtBox.Text     = aAccountRow["Amount"].ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EDIT Vendor Payment: UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }