// create button method/event private void CreateButtonClick(object sender, EventArgs e) { if (!TxtName.Text.Contains(" ")) { TxtName.Text = "Must Enter Full Name!"; TxtName.Focus(); } else { customer1.Name = TxtName.Text; customer1.InitialDeposit = double.Parse(TxtInitialDeposit.Text); customer1.accountNumberGenerate(); TxtInitialDeposit.Text = customer1.convertDeposit(); AccountTxtBox.Text = customer1.AccountNumber.ToString(); TxtName.Enabled = false; TxtInitialDeposit.ReadOnly = true; AccountLbl.Show(); AccountTxtBox.Show(); lblDeposit.Show(); TxtDeposit.Show(); TxtDeposit.Focus(); lblWithDraw.Show(); TxtWithdraw.Show(); UpdateAccountButton.Show(); CreateButton.Hide(); TxtDeposit.Focus(); } }
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(); } }