private void PaymentMethodCheckBox_SelectedValueChanged(object sender, EventArgs e) { if (PaymentMethodCheckBox.SelectedValue != null) { DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString())); AccountComboBox.SelectedValue = int.Parse(aMethodRow["DefaultAccountID"].ToString()); //PaymentMethodMgmt.SelectDefaultAccountIDByMethodID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString())); AccountDescriptionTxtBox.Text = AccountsMgmt.SelectAccountDescriptionByID(int.Parse(aMethodRow["DefaultAccountID"].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 = ChecksMgmt.NextCheckNumber().ToString(); } } }
private void AccountComboBox_SelectedValueChanged(object sender, EventArgs e) { try { if (AccountComboBox.SelectedValue != null) { DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(int.Parse(AccountComboBox.SelectedValue.ToString())); if (AccountsMgmt.SelectAccountPaymentMethodByID(int.Parse(AccountComboBox.SelectedValue.ToString())) == int.Parse(PaymentMethodCheckBox.SelectedValue.ToString())) { if (aAccountRow["CurrencyID"].ToString() != "1") { AccountNotJOD = true; } else { AccountNotJOD = false; } AccountDescriptionTxtBox.Text = AccountsMgmt.SelectAccountDescriptionByID(int.Parse(aAccountRow["ID"].ToString())); } else { MessageBox.Show(MsgTxt.AccountTxt + "\n[" + AccountComboBox.Text + "]\n" + MsgTxt.DoNotAcceptTxt + "\n" + PaymentMethodCheckBox.Text, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); //Same As Function on value change for the payment method combo box DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString())); AccountComboBox.SelectedValue = int.Parse(aMethodRow["DefaultAccountID"].ToString()); //PaymentMethodMgmt.SelectDefaultAccountIDByMethodID(int.Parse(PaymentMethodCheckBox.SelectedValue.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(); } } } } catch (Exception ex) //Unexpected Error { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AccountComboBox_SelectedValueChanged] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
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(); } }
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(); } }
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(); } }
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; } }