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; }
private int AddAdjustGeneralEntry(DataTable aTable) { try { if (!ValidateAdjustTable(aTable)) { return -1; } AdjustInventoryGeneral aAdjustGeneral = new AdjustInventoryGeneral(); aAdjustGeneral.Number = AdjustInventoryGeneralMgmt.NextBillNumber(); aAdjustGeneral.TellerID = Convert.ToInt32(UsersMgmt.SelectUserIDByUserName(SharedFunctions.ReturnLoggedUserName()).ToString()); aAdjustGeneral.Date = DateTime.Now.ToShortDateString(); aAdjustGeneral.IsChecked = 0; if (AdjustInventoryGeneralMgmt.AddAdjustGeneralItem(aAdjustGeneral)) { return aAdjustGeneral.Number; } else { return aAdjustGeneral.Number; } } catch (Exception ex) { MessageBox.Show("NOT ADDED \n ERROR IN ADJUSTITEMSFRM: FUNCTION:AddAdjustToDataBase {EXCEPTION }" + ex.ToString(), MsgTxt.UnexpectedError, MessageBoxButtons.OK, MessageBoxIcon.Error); return -1; } }
private void UpdatePrivBtn_Click(object sender, EventArgs e) { try { if (UserNameComboBox.SelectedValue != null && UserNameComboBox.Text != "") { UserNameComboBox.BackColor = UserBGColor; if (UserNameComboBox.Text.ToLower() != "admin") { int UserID = int.Parse(UserNameComboBox.SelectedValue.ToString()); if (EditAdminsCheckBox.Checked) { if (!PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins"))) { PriviligesMgmt.AddPrivilige(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins")); } } else { if (PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins"))) { PriviligesMgmt.RemovePrivilige(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins")); } } if (AdminCheckBox.Checked == true) { UsersMgmt.MakeUserAdmin(UserID, 1); } else { UsersMgmt.MakeUserAdmin(UserID, 0); } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); UserNameComboBox.Text = ""; } else { MessageBox.Show(MsgTxt.CannotChangeAdminTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); UserNameComboBox.BackColor = SharedVariables.TxtBoxRequiredColor; UserNameComboBox.Focus(); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdatePrivBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close();; } }
private void ListAdjustsBtn_Click(object sender, EventArgs e) { try { aAdjustList = AdjustInventoryGeneralMgmt.SelectAllAdjustsGeneral(-1, string.Empty, string.Empty); aAdjustDetailedSumVal = AdjustInventoryDetailedMgmt.SelectAllAdjustsDetailedSUMValue(-1, -1); aUsersTable = UsersMgmt.SelectAllUsers(); page(1); } catch (Exception ex) { MessageBox.Show("ERROR IN LIST ADJUST ITEMS" + ex.ToString(), MsgTxt.UnexpectedError, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void UpdateVariables(string aUserName) { try { UserNameComboBox.Text = aUserName; UserNameComboBox.SelectedValue = UsersMgmt.SelectUserIDByUserName(aUserName).ToString(); } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateInfoBtn_Click(object sender, EventArgs e) { try { if (UserNameComboBox.Text != "") { if (UsersMgmt.SelectUserInfoByID(int.Parse(UserNameComboBox.SelectedValue.ToString()))["IsAdmin"].ToString() == "1") { MessageBox.Show(UiText.CannotEditAdminsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Users aUser = new Users(); aUser.User_Name = NameTxtBox.Text; aUser.User_Address = AddressTxtBox.Text; aUser.User_Phone1 = Phone1TxtBox.Text; aUser.User_Phone2 = Phone2TxtBox.Text; aUser.User_Password = PasswordTxtBox.Text; aUser.User_Description = DescriptionTxtBox.Text; aUser.User_ID = int.Parse(UserNameComboBox.SelectedValue.ToString()); if (UsersMgmt.UpdateUser(aUser)) { foreach (TextBox aTextBox in this.UserInfoGB.Controls.OfType <TextBox>()) { aTextBox.Text = ""; } MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); UserNameComboBox.Text = ""; } else { MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.UnexpectedError, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + " " + MsgTxt.UserTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateInfoBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private void UserNameComboBox_SelectedValueChanged(object sender, EventArgs e) { try { if (UserNameComboBox.SelectedValue != null && !isloading) { //ControlHelper.SuspendDrawing(this); int UserID = int.Parse(UserNameComboBox.SelectedValue.ToString()); bool isenabled; if (UsersMgmt.SelectUserInfoByID(UserID)["IsAdmin"].ToString() == "1") { PasswordTxtBox.UseSystemPasswordChar = true; isenabled = false; CannotEditAdminLbl.Visible = true; } else { PasswordTxtBox.UseSystemPasswordChar = false; isenabled = true; CannotEditAdminLbl.Visible = false; } DataRow UserInfo = UsersMgmt.SelectUserInfoByID(UserID); foreach (var aGroupBox in this.Controls.OfType <GroupBox>()) { foreach (TextBox aTextBox in aGroupBox.Controls.OfType <TextBox>()) { aTextBox.Text = UserInfo[aTextBox.Name.ToString().Substring(0, aTextBox.Name.Length - 6)].ToString(); aTextBox.Enabled = isenabled; } foreach (CheckBox aCheckBox in aGroupBox.Controls.OfType <CheckBox>()) { aCheckBox.Checked = PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString())); aCheckBox.Enabled = isenabled; } } UpdateInfoBtn.Enabled = isenabled; UpdatePrivBtn.Enabled = isenabled; // ControlHelper.ResumeDrawing(this); } } catch (Exception ex) { //ControlHelper.ResumeDrawing(this); MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UserNameComboBox_SelectedValueChanged] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private void UpdateInfoBtn_Click(object sender, EventArgs e) { try { if (UserNameComboBox.SelectedValue != null && UserNameComboBox.Text != "") { UserNameComboBox.BackColor = UserBGColor; if (Validators.TxtBoxNotEmpty(PasswordTxtBox.Text)) { PasswordTxtBox.BackColor = PasswordBGColor; Users aUser = new Users(); aUser.User_Name = NameTxtBox.Text; aUser.User_Address = AddressTxtBox.Text; aUser.User_Phone1 = Phone1TxtBox.Text; aUser.User_Phone2 = Phone2TxtBox.Text; aUser.User_Password = PasswordTxtBox.Text; aUser.User_Description = DescriptionTxtBox.Text; aUser.User_ID = int.Parse(UserNameComboBox.SelectedValue.ToString()); UsersMgmt.UpdateUser(aUser); foreach (TextBox aTextBox in this.UserInfoGB.Controls.OfType <TextBox>()) { aTextBox.Text = ""; } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); UserNameComboBox.Text = ""; } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); PasswordTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; PasswordTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); UserNameComboBox.BackColor = SharedVariables.TxtBoxRequiredColor; UserNameComboBox.Focus(); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateInfoBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void UpdatePrivBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(UserNameComboBox.Text)) { int UserID = int.Parse(UserNameComboBox.SelectedValue.ToString()); if (UsersMgmt.SelectUserInfoByID(UserID)["IsAdmin"].ToString() == "1") { MessageBox.Show(UiText.CannotEditAdminsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { foreach (CheckBox aCheckBox in PriviligesGB.Controls.OfType <CheckBox>()) { if (aCheckBox.Checked == true) { if (!PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString()))) { PriviligesMgmt.AddPrivilige(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString())); } } else { if (PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString()))) { PriviligesMgmt.RemovePrivilige(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString())); } } } MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + " " + MsgTxt.UserTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdatePrivBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private DisposalGeneral FillDisposalGeneral() { try { DisposalGeneral aDisposalGeneral = new DisposalGeneral(); aDisposalGeneral.Disposal_General_Date = DateTime.Now.ToShortDateString(); aDisposalGeneral.Disposal_General_Time = DateTime.Now.ToShortTimeString(); aDisposalGeneral.Disposal_General_Reason = int.Parse(DisposalReasonComboBox.SelectedValue.ToString()); aDisposalGeneral.Disposal_General_Number = GetNextDisposalNumber(); aDisposalGeneral.Disposal_General_TotalCost = double.Parse(TotalTxtBox.Text); aDisposalGeneral.Disposal_General_TotalTax = double.Parse(TaxTxtBox.Text); aDisposalGeneral.Disposal_General_Comments = CommentsTxtBox.Text; aDisposalGeneral.Disposal_General_TellerID = Convert.ToInt32(UsersMgmt.SelectUserIDByUserName(SharedFunctions.ReturnLoggedUserName()).ToString()); //for now return(aDisposalGeneral); } catch { return(null); } }
private void UserNameComboBox_SelectedValueChanged(object sender, EventArgs e) { try { if (UserNameComboBox.SelectedValue != null && !isloading) { int UserID = int.Parse(UserNameComboBox.SelectedValue.ToString()); DataRow UserInfo = UsersMgmt.SelectUserInfoByID(UserID); foreach (TextBox aTextBox in UserInfoGB.Controls.OfType <TextBox>()) { aTextBox.Text = UserInfo[aTextBox.Name.ToString().Substring(0, aTextBox.Name.Length - 6)].ToString(); } EditAdminsCheckBox.Checked = PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins")); AdminCheckBox.Checked = UsersMgmt.IsUserAdmin(UserID); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UserNameComboBox_SelectedValueChanged] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void ListUsersBtn_Click(object sender, EventArgs e) { try { int RowNum = 0; DataTable UsersTable = UsersMgmt.SelectAllUsers(); if (UsersTable == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListUsers:DB-ERROR UsersTable=null] \n \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (UsersTable.Rows.Count > 0) { RowNum = 0; ListUsersDgView.Rows.Clear(); foreach (DataRow r in UsersTable.Rows) { ListUsersDgView.Rows.Add(); ListUsersDgView.Rows[RowNum].Cells["Namecol"].Value = UsersTable.Rows[RowNum]["Name"].ToString(); ListUsersDgView.Rows[RowNum].Cells["Address"].Value = UsersTable.Rows[RowNum]["Address"].ToString(); ListUsersDgView.Rows[RowNum].Cells["Phone1"].Value = UsersTable.Rows[RowNum]["Phone1"].ToString(); ListUsersDgView.Rows[RowNum].Cells["Phone2"].Value = UsersTable.Rows[RowNum]["Phone2"].ToString(); ListUsersDgView.Rows[RowNum].Cells["UserName"].Value = UsersTable.Rows[RowNum]["UserName"].ToString(); ListUsersDgView.Rows[RowNum].Cells["Password"].Value = UsersTable.Rows[RowNum]["Password"].ToString(); ListUsersDgView.Rows[RowNum].Cells["Description"].Value = UsersTable.Rows[RowNum]["Description"].ToString(); RowNum++; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListUsersBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
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 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; } }
private void ListDCBtn_Click(object sender, EventArgs e) { int FilterVendorID = int.Parse(VendorNameComboBox.SelectedValue.ToString()); aCurrencyTable = CurrencyMgmt.SelectAll(); aUsersTable = UsersMgmt.SelectAllUsers(); aAccountsTable = AccountsMgmt.SelectAll(); aPaymentMethodTable = PaymentMethodMgmt.SelectAll(); aAccountsTable = AccountsMgmt.SelectAll(); aVendorTable = VendorsMgmt.SelectAllVendors(); DebitDGView.Rows.Clear(); CreditDGView.Rows.Clear(); int FilterTellerNameID = 0; if (TellerNameChkBox.Checked) { FilterTellerNameID = int.Parse(TellerNameComboBox.SelectedValue.ToString()); } string FilterDateFrom = ""; string FilterDateTo = ""; if (DateCheckBox.Checked) { FilterDateFrom = DateFrompicker.Value.ToShortDateString(); FilterDateTo = DateToPicker.Value.ToShortDateString(); } bool FilterCheckedBills = CheckChkBox.Checked; bool FilterIsRevised = RevisedChkBox.Checked; bool FilterUnCheckedBills = UnCheckedChkBox.Checked; bool FilterUnRevisedBills = UnRevisedChkBox.Checked; bool FilterBillCashCredit = CreditBillsChkBox.Checked; //LISTING BILLS aPurchaseVoucherTable = PurchaseVoucherGeneralMgmt.SelectAllVouchers(FilterTellerNameID, FilterDateFrom, FilterDateTo, FilterCheckedBills, FilterIsRevised, FilterUnCheckedBills, FilterUnRevisedBills, FilterVendorID, FilterBillCashCredit); TotalITemsTxtBoxDebit.Text = aPurchaseVoucherTable.Rows.Count.ToString(); TotalDebitPriceTxtBox.Text = "0"; if (aPurchaseVoucherTable.Rows.Count > 0) { double TotalDebitPrice = 0; for (int i = 0; i < aPurchaseVoucherTable.Rows.Count; i++) { TotalDebitPrice += double.Parse(aPurchaseVoucherTable.Rows[i]["TotalCost"].ToString()); } TotalDebitPriceTxtBox.Text = TotalDebitPrice.ToString(); RowNumDebit = 0; if (DebitDGView.Rows.Count < ItemsPerPageDebit) { //TestingFor Paging pagesnumberDebit = (int)aPurchaseVoucherTable.Rows.Count / ItemsPerPageDebit; if ((double.Parse(aPurchaseVoucherTable.Rows.Count.ToString()) / ItemsPerPageDebit - int.Parse(aPurchaseVoucherTable.Rows.Count.ToString()) / ItemsPerPageDebit) > 0) { pagesnumberDebit++; } foreach (DataRow r in aPurchaseVoucherTable.Rows) { if (DebitDGView.Rows.Count < ItemsPerPageDebit) { DebitDGView.Rows.Add(); DebitDGView.Rows[RowNumDebit].Cells["VoucherNumber"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["VoucherNumber"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["Date"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["Date"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["Time"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["Time"].ToString(); for (int i = 0; i < aVendorTable.Rows.Count; i++) { if (int.Parse(aVendorTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["VendorID"].ToString())) { DebitDGView.Rows[RowNumDebit].Cells["Vendor"].Value = aVendorTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNumDebit]["TellerID"].ToString(); break; } } DebitDGView.Rows[RowNumDebit].Cells["TotalFreeITemsQty"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalFreeITemsQty"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["TotalTax"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalTax"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["Subtotal"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["Subtotal"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["DiscountPerc"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["DiscountPerc"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["TotalItemsDiscount"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalItemsDiscount"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["TotalDiscount"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalDiscount"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["TotalCost"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalCost"].ToString(); for (int i = 0; i < aPaymentMethodTable.Rows.Count; i++) { if (int.Parse(aPaymentMethodTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["PaymentMethodID"].ToString())) { DebitDGView.Rows[RowNumDebit].Cells["PaymentMethod"].Value = aPaymentMethodTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNumDebit]["TellerID"].ToString(); break; } } DebitDGView.Rows[RowNumDebit].Cells["Comments"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["Comments"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["CreditCardInfo"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CreditCardInfo"].ToString(); for (int i = 0; i < aCurrencyTable.Rows.Count; i++) { if (int.Parse(aCurrencyTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["CurrencyID"].ToString())) { DebitDGView.Rows[RowNumDebit].Cells["Currency"].Value = aCurrencyTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNumDebit]["TellerID"].ToString(); break; } } for (int i = 0; i < aAccountsTable.Rows.Count; i++) { if (int.Parse(aAccountsTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["AccountID"].ToString())) { DebitDGView.Rows[RowNumDebit].Cells["Currency"].Value = aAccountsTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNumDebit]["TellerID"].ToString(); break; } } for (int i = 0; i < aUsersTable.Rows.Count; i++) { if (int.Parse(aUsersTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["TellerID"].ToString())) { DebitDGView.Rows[RowNumDebit].Cells["Teller"].Value = aUsersTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString(); break; } } DebitDGView.Rows[RowNumDebit].Cells["CheckNumber"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CheckNumber"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["IsCashCredit"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["IsCashCredit"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["VendorAccountAmountOld"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["VendorAccountAmountOld"].ToString(); if (aPurchaseVoucherTable.Rows[RowNumDebit]["IsChecked"].ToString() == "0") { DebitDGView.Rows[RowNumDebit].Cells["IsChecked"].Value = "NO";//aBillTable.Rows[RowNumDebit]["IsChecked"].ToString(); } else { DebitDGView.Rows[RowNumDebit].Cells["IsChecked"].Value = "YES"; } DebitDGView.Rows[RowNumDebit].Cells["CheckedBy"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CheckedBy"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["CheckDate"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CheckDate"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["CheckTime"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CheckTime"].ToString(); if (aPurchaseVoucherTable.Rows[RowNumDebit]["IsRevised"].ToString() == "0") { DebitDGView.Rows[RowNumDebit].Cells["IsRevised"].Value = "NO";//aBillTable.Rows[RowNumDebit]["IsChecked"].ToString(); } else { DebitDGView.Rows[RowNumDebit].Cells["IsRevised"].Value = "YES"; } DebitDGView.Rows[RowNumDebit].Cells["RevisedBy"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["RevisedBy"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["ReviseDate"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["ReviseDate"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["ReviseTime"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["ReviseTime"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["ReviseLoss"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["ReviseLoss"].ToString(); DebitDGView.Rows[RowNumDebit].Cells["Fees"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["Fees"].ToString(); RowNumDebit++; } } PageOfTotalTxtBoxDebit.Text = "1/" + pagesnumberDebit.ToString(); currentpageDebit = 1; } } //LISTING PAYMENTS //LISTING PAYMENTS CREDIT aVendorPaymentTable = VendorsPaymentsMgmt.SelectAll(FilterTellerNameID, FilterDateFrom, FilterDateTo, FilterCheckedBills, FilterIsRevised, FilterUnCheckedBills, FilterUnRevisedBills, FilterVendorID); TotalITemsTxtBoxCredit.Text = aVendorPaymentTable.Rows.Count.ToString(); TotalCreditTxtBox.Text = "0"; if (aVendorPaymentTable.Rows.Count > 0) { double TotalCredit = 0; for (int i = 0; i < aVendorPaymentTable.Rows.Count; i++) { TotalCredit += double.Parse(aVendorPaymentTable.Rows[i]["Amount"].ToString()); } TotalCreditTxtBox.Text = TotalCredit.ToString(); RowNumCredit = 0; if (CreditDGView.Rows.Count < ItemsPerPageCredit) { //TestingFor Paging pagesnumberCredit = (int)aVendorPaymentTable.Rows.Count / ItemsPerPageCredit; if ((double.Parse(aVendorPaymentTable.Rows.Count.ToString()) / ItemsPerPageCredit - int.Parse(aVendorPaymentTable.Rows.Count.ToString()) / ItemsPerPageCredit) > 0) { pagesnumberCredit++; } foreach (DataRow r in aVendorPaymentTable.Rows) { if (CreditDGView.Rows.Count < ItemsPerPageCredit) { CreditDGView.Rows.Add(); CreditDGView.Rows[RowNumCredit].Cells["PaymentNumber"].Value = aVendorPaymentTable.Rows[RowNumCredit]["PaymentNumber"].ToString(); for (int i = 0; i < aVendorTable.Rows.Count; i++) { if (int.Parse(aVendorTable.Rows[i]["ID"].ToString()) == int.Parse(aVendorPaymentTable.Rows[RowNumCredit]["VendorID"].ToString())) { CreditDGView.Rows[RowNumCredit].Cells["VendorIDCredit"].Value = aVendorTable.Rows[i]["Name"].ToString(); break; } } CreditDGView.Rows[RowNumCredit].Cells["DateCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["Date"].ToString(); CreditDGView.Rows[RowNumCredit].Cells["TimeCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["Time"].ToString(); for (int i = 0; i < aUsersTable.Rows.Count; i++) { if (int.Parse(aUsersTable.Rows[i]["ID"].ToString()) == int.Parse(aVendorPaymentTable.Rows[RowNumCredit]["TellerID"].ToString())) { CreditDGView.Rows[RowNumCredit].Cells["TellerCredit"].Value = aUsersTable.Rows[i]["UserName"].ToString(); break; } } CreditDGView.Rows[RowNumCredit].Cells["AmountCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["Amount"].ToString(); CreditDGView.Rows[RowNumCredit].Cells["OldAmountCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["OldVendorAccountAmount"].ToString(); CreditDGView.Rows[RowNumCredit].Cells["CommentsCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["Comments"].ToString(); if (aVendorPaymentTable.Rows[RowNumCredit]["IsChecked"].ToString() == "0") { CreditDGView.Rows[RowNumCredit].Cells["IsCheckedCredit"].Value = "NO";//aBillsDataTable.Rows[RowNum]["IsChecked"].ToString(); } else { CreditDGView.Rows[RowNumCredit].Cells["IsCheckedCredit"].Value = "YES"; } if (aVendorPaymentTable.Rows[RowNumCredit]["IsRevised"].ToString() == "0") { CreditDGView.Rows[RowNumCredit].Cells["IsRevisedCredit"].Value = "NO";//aBillsDataTable.Rows[RowNum]["IsRevised"].ToString(); } else { CreditDGView.Rows[RowNumCredit].Cells["IsRevisedCredit"].Value = "YES"; } CreditDGView.Rows[RowNumCredit].Cells["CheckDateCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["CheckDate"].ToString(); CreditDGView.Rows[RowNumCredit].Cells["CheckTimeCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["CheckTime"].ToString(); CreditDGView.Rows[RowNumCredit].Cells["CheckedByCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["CheckedBy"].ToString(); CreditDGView.Rows[RowNumCredit].Cells["ReviseDateCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["ReviseDate"].ToString(); CreditDGView.Rows[RowNumCredit].Cells["ReviseTimeCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["ReviseTime"].ToString(); CreditDGView.Rows[RowNumCredit].Cells["RevisedByCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["RevisedBy"].ToString(); RowNumCredit++; } PageOfTotalTxtBoxCredit.Text = "1/" + pagesnumberCredit.ToString(); currentpageCredit = 1; } } } }
private void ListVouchersBtn_Click(object sender, EventArgs e) { try { int FilterVendorID = -1; if (ByVendorNameChkBox.Checked && VendorsComboBox.SelectedValue != null) { FilterVendorID = int.Parse(VendorsComboBox.SelectedValue.ToString());//VendorsMgmt.SelectVendorIDByName(VendorNameTxtBox.Text); // CustomerMgmt.SelectCustomerIDByPhone1(CustomerPhoneTxtBox.Text); if (FilterVendorID == -1) { MessageBox.Show(MsgTxt.UnexpectedError + " " + MsgTxt.VendorTxt + " " + VendorsComboBox.Text + " " + MsgTxt.NotFoundTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } aVendorTable = VendorsMgmt.SelectAllVendors(); if (aVendorTable == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListVouchersBtn_Click:DB-ERROR aVendorTable=null] \n \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } aCurrencyTable = CurrencyMgmt.SelectAll(); if (aCurrencyTable == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aCurrencyTable:DB-ERROR aCurrencyTable=null] \n \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } aUsersTable = UsersMgmt.SelectAllUsers(); if (aUsersTable == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aUsersTable:DB-ERROR aUsersTable=null] \n \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } aAccountsTable = AccountsMgmt.SelectAll(); if (aAccountsTable == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aAccountsTable:DB-ERROR aAccountsTable=null] \n \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } aPaymentMethodTable = PaymentMethodMgmt.SelectAll(); if (aPaymentMethodTable == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aPaymentMethodTable:DB-ERROR aPaymentMethodTable=null] \n \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //aVouchersTable = PurchaseVoucherGeneralMgmt.SelectAllVouchers(); int FilterTellerID = 0; if (TellerNameChkBox.Checked && TellerNameComboBox.SelectedValue != null) { FilterTellerID = int.Parse(TellerNameComboBox.SelectedValue.ToString()); } string FilterDateFrom = ""; string FilterDateTo = ""; if (DateCheckBox.Checked) { FilterDateFrom = DateFrompicker.Value.ToShortDateString(); FilterDateTo = DateToPicker.Value.ToShortDateString(); } bool FilterChecked = CheckedChkBox.Checked; bool FilterRevised = IsRevisedChkBox.Checked; bool FilterUnChecked = UncheckedVouchersChkBox.Checked; bool FilterUnRevised = UnRevisedChkBox.Checked; aVouchersTable = PurchaseVoucherGeneralMgmt.SelectAllVouchers(FilterTellerID, FilterDateFrom, FilterDateTo, FilterChecked, FilterRevised, FilterUnChecked, FilterUnRevised, FilterVendorID, false); if (aVouchersTable == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aVouchersTable:DB-ERROR aVouchersTable=null] \n \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TotalITemsTxtBox.Text = aVouchersTable.Rows.Count.ToString(); ListVouchersDGView.Rows.Clear(); if (aVouchersTable.Rows.Count > 0) { RowNum = 0; if (ListVouchersDGView.Rows.Count < ItemsPerPage) { //TestingFor Paging pagesnumber = (int)aVouchersTable.Rows.Count / ItemsPerPage; if ((double.Parse(aVouchersTable.Rows.Count.ToString()) / ItemsPerPage - int.Parse(aVouchersTable.Rows.Count.ToString()) / ItemsPerPage) > 0) { pagesnumber++; } foreach (DataRow r in aVouchersTable.Rows) { if (ListVouchersDGView.Rows.Count < ItemsPerPage) { ListVouchersDGView.Rows.Add(); ListVouchersDGView.Rows[RowNum].Cells["VoucherNumber"].Value = aVouchersTable.Rows[RowNum]["VoucherNumber"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["Date"].Value = aVouchersTable.Rows[RowNum]["Date"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["Time"].Value = aVouchersTable.Rows[RowNum]["Time"].ToString(); for (int i = 0; i < aVendorTable.Rows.Count; i++) { if (int.Parse(aVendorTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["VendorID"].ToString())) { ListVouchersDGView.Rows[RowNum].Cells["Vendor"].Value = aVendorTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString(); break; } } ListVouchersDGView.Rows[RowNum].Cells["TotalFreeITemsQty"].Value = aVouchersTable.Rows[RowNum]["TotalFreeITemsQty"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["TotalTax"].Value = aVouchersTable.Rows[RowNum]["TotalTax"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["Subtotal"].Value = aVouchersTable.Rows[RowNum]["Subtotal"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["DiscountPerc"].Value = aVouchersTable.Rows[RowNum]["DiscountPerc"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["TotalItemsDiscount"].Value = aVouchersTable.Rows[RowNum]["TotalItemsDiscount"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["TotalDiscount"].Value = aVouchersTable.Rows[RowNum]["TotalDiscount"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["TotalCost"].Value = aVouchersTable.Rows[RowNum]["TotalCost"].ToString(); for (int i = 0; i < aPaymentMethodTable.Rows.Count; i++) { if (int.Parse(aPaymentMethodTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["PaymentMethodID"].ToString())) { ListVouchersDGView.Rows[RowNum].Cells["PaymentMethod"].Value = aPaymentMethodTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString(); break; } } ListVouchersDGView.Rows[RowNum].Cells["Comments"].Value = aVouchersTable.Rows[RowNum]["Comments"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["CreditCardInfo"].Value = aVouchersTable.Rows[RowNum]["CreditCardInfo"].ToString(); for (int i = 0; i < aCurrencyTable.Rows.Count; i++) { if (int.Parse(aCurrencyTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["CurrencyID"].ToString())) { ListVouchersDGView.Rows[RowNum].Cells["Currency"].Value = aCurrencyTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString(); break; } } for (int i = 0; i < aAccountsTable.Rows.Count; i++) { if (int.Parse(aAccountsTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["AccountID"].ToString())) { ListVouchersDGView.Rows[RowNum].Cells["Currency"].Value = aAccountsTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString(); break; } } for (int i = 0; i < aUsersTable.Rows.Count; i++) { if (int.Parse(aUsersTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["TellerID"].ToString())) { ListVouchersDGView.Rows[RowNum].Cells["Teller"].Value = aUsersTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString(); break; } } ListVouchersDGView.Rows[RowNum].Cells["CheckNumber"].Value = aVouchersTable.Rows[RowNum]["CheckNumber"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["IsCashCredit"].Value = aVouchersTable.Rows[RowNum]["IsCashCredit"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["VendorAccountAmountOld"].Value = aVouchersTable.Rows[RowNum]["VendorAccountAmountOld"].ToString(); if (aVouchersTable.Rows[RowNum]["IsChecked"].ToString() == "0") { ListVouchersDGView.Rows[RowNum].Cells["IsChecked"].Value = "NO";//aBillTable.Rows[RowNum]["IsChecked"].ToString(); } else { ListVouchersDGView.Rows[RowNum].Cells["IsChecked"].Value = "YES"; } ListVouchersDGView.Rows[RowNum].Cells["CheckedBy"].Value = aVouchersTable.Rows[RowNum]["CheckedBy"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["CheckDate"].Value = aVouchersTable.Rows[RowNum]["CheckDate"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["CheckTime"].Value = aVouchersTable.Rows[RowNum]["CheckTime"].ToString(); if (aVouchersTable.Rows[RowNum]["IsRevised"].ToString() == "0") { ListVouchersDGView.Rows[RowNum].Cells["IsRevised"].Value = "NO";//aBillTable.Rows[RowNum]["IsChecked"].ToString(); } else { ListVouchersDGView.Rows[RowNum].Cells["IsRevised"].Value = "YES"; } ListVouchersDGView.Rows[RowNum].Cells["RevisedBy"].Value = aVouchersTable.Rows[RowNum]["RevisedBy"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["ReviseDate"].Value = aVouchersTable.Rows[RowNum]["ReviseDate"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["ReviseTime"].Value = aVouchersTable.Rows[RowNum]["ReviseTime"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["ReviseLoss"].Value = aVouchersTable.Rows[RowNum]["ReviseLoss"].ToString(); ListVouchersDGView.Rows[RowNum].Cells["Fees"].Value = aVouchersTable.Rows[RowNum]["Fees"].ToString(); RowNum++; } } PageOfTotalTxtBox.Text = "1/" + pagesnumber.ToString(); currentpage = 1; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListVouchersBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
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(); } }
private void LoginBtn_Click(object sender, EventArgs e) { if (true) { MessageBox.Show("Testing Mode Enabled"); Testing ateTesting = new Testing(); ateTesting.Show(); } if (!Security.V1.ActivationCheck.__IsRegisteredVersion) { if (Security.V1.ActivationCheck.__IsTrialValid == false) { MessageBox.Show(MsgTxt.YouShouldActivateNowTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } bool isadmin; if (UsrTxtBox.Text.Trim() != "" && PassTxtBox.Text.Trim() != "") { UsrTxtBox.BackColor = UsrBGColor; PassTxtBox.BackColor = PassBGColor; DataRow dr = UsersMgmt.SelectUserByUserNameandPassword(UsrTxtBox.Text, PassTxtBox.Text); if (dr != null) { if (IsFirstLogin || SharedVariables.IsStartup) { if (Convert.ToInt32(dr["IsAdmin"]) == 1) { PrivilegesManager.IsCurrentUserAdmin = true; SharedVariables.user_logged_name = dr["UserName"].ToString(); SharedVariables.user_logged_name_name = dr["Name"].ToString(); isadmin = true; } else { PrivilegesManager.IsCurrentUserAdmin = false; SharedVariables.user_logged_name = dr["UserName"].ToString(); SharedVariables.user_logged_name_name = dr["Name"].ToString(); isadmin = false; } PrivilegesManager.FillTemplate(Convert.ToInt32(dr["ID"])); PrivilegesManager.IsTempActive = false; PrivilegesManager.IsAdminActive = isadmin; SharedVariables.is_user_logged = true; if (SharedVariables.IsStartup) { Main2 aMain = new Main2(); aMain.Show(); //this.Close(); } } // END OF FIRST LOGIN else //NOT FIRST LOGIN { if (Convert.ToInt32(dr["IsAdmin"]) == 1) { PrivilegesManager.IsTempUserAdmin = true; SharedVariables.temp_logged_name = dr["UserName"].ToString(); SharedVariables.temp_logged_name_name = dr["Name"].ToString(); } else { PrivilegesManager.IsTempUserAdmin = false; SharedVariables.temp_logged_name = dr["UserName"].ToString(); SharedVariables.temp_logged_name_name = dr["Name"].ToString(); } PrivilegesManager.FillTemplate(Convert.ToInt32(dr["ID"]), true); PrivilegesManager.IsTempActive = true; } if (SharedVariables.IsStartup) { SharedVariables.IsStartup = false; this.UsrTxtBox.Focus(); this.UsrTxtBox.Clear(); this.PassTxtBox.Clear(); this.Hide(); } else //TEMP LOGIN SCREEN LAUNCHED INSIDE THE PROGRAM { this.Close(); } } else { Thread.Sleep(1000); MessageBox.Show(MsgTxt.UsrNameTxt + " " + MsgTxt.OrTxt + " " + MsgTxt.PasswordTxt + " " + MsgTxt.IncorrectTxt, MsgTxt.InformationCaption, MessageBoxButtons.OK, MessageBoxIcon.Hand); } } else { string Messagetxt = MsgTxt.PleaseAddAllRequiredFields + "\n"; if (UsrTxtBox.Text.Trim() == "") { Messagetxt += "1)" + MsgTxt.UsrNameTxt + "\n"; UsrTxtBox.Focus(); UsrTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; } if (PassTxtBox.Text.Trim() == "") { Messagetxt += "2)" + MsgTxt.PasswordTxt; PassTxtBox.Focus(); if (UsrTxtBox.Text.Trim() == "") { UsrTxtBox.Focus(); } PassTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; } MessageBox.Show(Messagetxt, MsgTxt.InformationCaption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private bool AddPayment() { semaphore = true; int NextCheckNumber = -1; double Amount = 0; try { if (CustomerDoNotHaveAccount) { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n 1)" + MsgTxt.CustomerTxt + "\n2)" + MsgTxt.ValidAccountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); semaphore = false; return(false); } else { if (!double.TryParse(PaymentAmountTxtBox.Text, out Amount) || PaymentAmountTxtBox.Text == string.Empty) { MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); PaymentAmountTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; return(false); } else if (Amount == 0) { MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); PaymentAmountTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; return(false); } else { PaymentAmountTxtBox.BackColor = PaymentAmountTxtBoxCOLOR; //This is Added To Take The New Value //انه لو صارت حركة بيع في اثناء التعديل DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString())); aCusomerAccountRow = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID); Balance = Double.Parse(aCusomerAccountRow["Amount"].ToString()); aCustomerPayment = new CustomersPayments(); int PaymentNumber = CustomersPaymentsMgmt.NextPaymentNumber(); if (PaymentNumber == 0)//ERROR PAYMENT NUMBER ZERO { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [Payment Number = 0] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); semaphore = false; this.Close(); return(false); } aCustomerPayment.Customer_Payment_PaymentNumber = PaymentNumber; aCustomerPayment.Customer_Payment_CustomerID = CustomerID; aCustomerPayment.Customer_Payment_Date = DateTime.Now.ToShortDateString(); aCustomerPayment.Customer_Payment_Time = DateTime.Now.ToShortTimeString(); int TellerID = UsersMgmt.SelectUserIDByUserName(SharedFunctions.ReturnLoggedUserName()); if (TellerID == 0) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [TellerID = 0] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); semaphore = false; this.Close(); return(false); } aCustomerPayment.Customer_Payment_TellerID = TellerID; aCustomerPayment.Customer_Payment_OldAmount = Balance; aCustomerPayment.Customer_Payment_Amount = Amount; aCustomerPayment.Customer_Payment_Comments = CommentsTxtBox.Text; aCustomerPayment.PaymentMethodID = int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()); aCustomerPayment.AccountID = int.Parse(AccountComboBox.SelectedValue.ToString()); Checks aCheck = new Checks(); if (aMethodRow["IsCash"].ToString() == "1") { aCustomerPayment.IsCreditCard = 0; aCustomerPayment.CreditCardInfo = "NOT-CREDIT"; if (!CustomersPaymentsMgmt.AddCustomerPayment(aCustomerPayment)) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT ADD PAYMENT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); semaphore = false; this.Close(); return(false); } int CusAccountID = int.Parse(aCusomerAccountRow["ID"].ToString()); double NewAmount = aCustomerPayment.Customer_Payment_OldAmount - aCustomerPayment.Customer_Payment_Amount; if (!CustomersAccountsMgmt.UpdateAccountAmountByAccountID(CusAccountID, NewAmount)) { CustomersPaymentsMgmt.DeleteCustomerPayment(aCustomerPayment); MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT UPDATE ACCOUNT AMOUNT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); semaphore = false; this.Close(); return(false); } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); semaphore = false; return(true); } else if (aMethodRow["IsCredit"].ToString() == "1")//----------------------------------------------------------------------------- { if (CreditCardInfoTxtBox.Text.Trim() != "") { aCustomerPayment.IsCreditCard = 1; aCustomerPayment.CreditCardInfo = CreditCardInfoTxtBox.Text; if (!CustomersPaymentsMgmt.AddCustomerPayment(aCustomerPayment)) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT ADD PAYMENT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return(false); } int CusAccountID = int.Parse(aCusomerAccountRow["ID"].ToString()); double NewAmount = aCustomerPayment.Customer_Payment_OldAmount - aCustomerPayment.Customer_Payment_Amount; if (!CustomersAccountsMgmt.UpdateAccountAmountByAccountID(CusAccountID, NewAmount)) { CustomersPaymentsMgmt.DeleteCustomerPayment(aCustomerPayment); MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT UPDATE ACCOUNT AMOUNT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return(false); } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); semaphore = false; return(true); } else { MessageBox.Show(MsgTxt.PleaseAddCreditCardInfoTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); CreditCardInfoTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; semaphore = false; return(true); } } else //its cheque---------------------------------------------------------------------------------- { if (HolderNameTxtBox.Text.Trim() != "") { aCheck.Chekcs_HolderName = HolderNameTxtBox.Text; } else { MessageBox.Show(MsgTxt.CheckHolderNameTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); semaphore = false; HolderNameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; return(false); } aCustomerPayment.IsCreditCard = 0; aCustomerPayment.CreditCardInfo = "NOT-CREDIT"; //its check NextCheckNumber = ChecksMgmt.NextCheckNumber(); if (NextCheckNumber == 0) //ERRO IN CHEQUES { MessageBox.Show("ERROR IN CHEQUE"); semaphore = false; return(false); } aCustomerPayment.CheckNumber = NextCheckNumber; if (!CustomersPaymentsMgmt.AddCustomerPayment(aCustomerPayment)) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error: CANNOT ADD PAYMENT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); semaphore = false; this.Close(); return(false); } aCheck.Chekcs_PaymentDate = CheckDatePicker.Value.ToShortDateString(); aCheck.Chekcs_IsBill = 0; aCheck.Chekcs_IsPurchaseVoucher = 0; aCheck.Chekcs_AccountID = 0; aCheck.Chekcs_Comments = CheckCommentsTxtBox.Text; aCheck.Chekcs_Amount = aCustomerPayment.Customer_Payment_Amount; aCheck.Chekcs_IsPaid = 0; aCheck.CheckNumber = NextCheckNumber; aCheck.AddingDate = DateTime.Now.ToShortDateString(); aCheck.Chekcs_PaymentDate = CheckDatePicker.Text; aCheck.Chekcs_IsVendorPayment = 0; aCheck.Chekcs_IsCustomerPayment = 1; aCheck.Chekcs_CustomerPaymentNumber = aCustomerPayment.Customer_Payment_PaymentNumber; if (!ChecksMgmt.InsertCheck(aCheck)) { CustomersPaymentsMgmt.DeleteCustomerPayment(aCustomerPayment); MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error: CANNOT ADD CHECK] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); semaphore = false; return(true); } int CusAccountID = int.Parse(aCusomerAccountRow["ID"].ToString()); double NewAmount = aCustomerPayment.Customer_Payment_OldAmount - aCustomerPayment.Customer_Payment_Amount; if (!CustomersAccountsMgmt.UpdateAccountAmountByAccountID(CusAccountID, NewAmount)) { ChecksMgmt.DeleteCheckByCheckNumber(aCheck.CheckNumber); CustomersPaymentsMgmt.DeleteCustomerPayment(aCustomerPayment); MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT UPDATE ACCOUNT AMOUNT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); semaphore = false; this.Close(); return(false); } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); semaphore = false; return(true); } //end of cheque } } } catch (Exception ex) { semaphore = false; MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddPaymentBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } return(false); }
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" + ": " + UsersMgmt.SelectUserNameByID(int.Parse(InventoryGeneral.Rows[0]["TellerID"].ToString())) + "</h2>"); aStringList.Add("<h2>" + ReceiptText.RctTxtReprintedOn + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "</h2>"); aStringList.Add("<h2> " + ReceiptText.RctTxtReprintedBy + ": " + SharedFunctions.ReturnLoggedUserName() + "</h2>"); aStringList.Add(ReceiptText.RctTxtInvoiceNum + ": " + 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); } }
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(); } }
private void AddUserBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(UserNameTxtBox.Text) && Validators.TxtBoxNotEmpty(PasswordTxtBox.Text)) { if (!UsersMgmt.IsUserExist(UserNameTxtBox.Text)) { Users aUser = new Users(); aUser.User_Name = NameTxtBox.Text; aUser.User_Address = AddressTxtBox.Text; aUser.User_Phone1 = Phone1TxtBox.Text; aUser.User_Phone2 = Phone2TxtBox.Text; aUser.User_Password = PasswordTxtBox.Text; aUser.User_Description = DescriptionTxtBox.Text; aUser.User_UserName = UserNameTxtBox.Text; if (UsersMgmt.AddUser(aUser)) { MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult ret; ret = MessageBox.Show(MsgTxt.AddAnotherItemTxt, MsgTxt.InformationCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); if (ret == DialogResult.Yes) { foreach (TextBox aTextBox in this.UserInfoGB.Controls.OfType <TextBox>()) { aTextBox.Text = ""; } } else { this.Close(); } } else { MessageBox.Show(MsgTxt.UnexpectedError + " \n[DataBase Error]:IN [AddUserBtn_Click]" + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } else { MessageBox.Show(MsgTxt.UserTxt + " [ " + UserNameTxtBox.Text + " ] " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); if (!Validators.TxtBoxNotEmpty(PasswordTxtBox.Text)) { PasswordTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; PasswordTxtBox.Focus(); } else { PasswordTxtBox.BackColor = PasswordBGColor; } if (!Validators.TxtBoxNotEmpty(UserNameTxtBox.Text)) { UserNameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; UserNameTxtBox.Focus(); } else { UserNameTxtBox.BackColor = NameBGColor; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + " \n[Exception]:IN [AddUserBtn_Click]" + "\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void Add1000Sale_Click(object sender, EventArgs e) { int cnt = 1; DateTime date = DateTime.Now; var randAmount = new Random(); int userId = int.Parse(UsersMgmt.SelectAllUsers().Rows[0]["ID"].ToString()); while (cnt++ < NumberOfBills) { try { int numofDetailed = randAmount.Next(1, 20); var aBillGeneral = new BillGeneral(); aBillGeneral.Bill_General_AccountID = 1; aBillGeneral.Bill_General_CashIn = 100; aBillGeneral.Bill_General_Currency = "JOD"; aBillGeneral.Bill_General_CurrencyID = 1; aBillGeneral.Bill_General_CustomerID = 1; aBillGeneral.Bill_General_Date = date.Subtract(TimeSpan.FromDays(randAmount.Next(1, 2000))).ToShortDateString(); aBillGeneral.Bill_General_DiscountPerc = 0; aBillGeneral.Bill_General_IsCashCredit = 0; aBillGeneral.Bill_General_NetAmount = 100; aBillGeneral.Bill_General_Number = BillGeneralMgmt.NextBillNumber(); aBillGeneral.Bill_General_PaymentMethodID = 1; aBillGeneral.Bill_General_PriceLevel = 1; aBillGeneral.Bill_General_SalesDiscount = 0; aBillGeneral.Bill_General_SubTotal = 100; aBillGeneral.Bill_General_TellerID = userId; aBillGeneral.Bill_General_Time = DateTime.Now.ToShortTimeString(); aBillGeneral.Bill_General_TotalCost = randAmount.Next(50, 99); aBillGeneral.Bill_General_TotalDiscount = 0; aBillGeneral.Bill_General_TotalItems = numofDetailed; aBillGeneral.Bill_General_TotalPrice = 100; aBillGeneral.Bill_General_TotalTax = 16; aBillGeneral.CustomerAccountAmountOld = 0; aBillGeneral.Bill_General_Comments = "Test Sale"; aBillGeneral.Bill_General_CreditCardInfo = "NotCredit"; Random aRandom = new Random(); if (BillGeneralMgmt.InsertBill(aBillGeneral)) { while (numofDetailed > 0) { BillDetailed aBillDetailed = new BillDetailed(); string aBarcode = "Test Item " + aRandom.Next(1, (int)NumberOfItems); DataTable aItemRow = ItemsMgmt.SelectItemByBarCode(aBarcode); if (aItemRow.Rows.Count != 0) { aBillDetailed.Bill_Detailed_ItemDescription = aItemRow.Rows[0]["Description"].ToString(); aBillDetailed.Bill_Detailed_ItemID = int.Parse(aItemRow.Rows[0]["ID"].ToString()); aBillDetailed.Bill_Detailed_Number = aBillGeneral.Bill_General_Number; aBillDetailed.Bill_Detailed_OldAvaQty = double.Parse(aItemRow.Rows[0]["Qty"].ToString()); aBillDetailed.Bill_Detailed_OldAvgUnitCost = double.Parse(aItemRow.Rows[0]["AvgUnitCost"].ToString()); aBillDetailed.Bill_Detailed_Qty = numofDetailed; aBillDetailed.Bill_Detailed_SellPrice = double.Parse(aItemRow.Rows[0]["SellPrice"].ToString()); aBillDetailed.Bill_Detailed_TotalPerUnit = aBillDetailed.Bill_Detailed_Qty * aBillDetailed.Bill_Detailed_SellPrice; BillDetailedMgmt.InsertItem(aBillDetailed); } numofDetailed--; } } if (cnt % 100 == 0) { label1.Text = $"Adding Bill {cnt}/{NumberOfBills} ... ({(cnt / NumberOfBills) * 100 })%"; Application.DoEvents(); } } catch (Exception ex) { MessageBox.Show($"Error in {cnt} \n {ex}"); } } }
private void Add1000PurchaseVoucherBtn_Click(object sender, EventArgs e) { Random randAmount = new Random(); int cnt = 1; var Vendors = VendorsMgmt.SelectAllVendors(); int userId = int.Parse(UsersMgmt.SelectAllUsers().Rows[0]["ID"].ToString()); while (cnt++ < NumberOfPurchases) { try { PurchaseVoucherGeneral aPurchaseGeneral = new PurchaseVoucherGeneral(); aPurchaseGeneral.AccountID = 1; aPurchaseGeneral.Comments = ""; aPurchaseGeneral.CurrencyID = 1; aPurchaseGeneral.Date = DateTime.Now.Subtract(TimeSpan.FromDays(randAmount.Next(1, 2000))).ToShortDateString(); aPurchaseGeneral.DiscountPerc = 0; aPurchaseGeneral.Fees = 10; aPurchaseGeneral.IsCashCredit = 0; aPurchaseGeneral.IsChecked = 0; aPurchaseGeneral.IsRevised = 0; aPurchaseGeneral.PaymentMethodID = 1; aPurchaseGeneral.Subtotal = 100; aPurchaseGeneral.TellerID = userId; aPurchaseGeneral.Time = DateTime.Now.ToShortTimeString(); aPurchaseGeneral.TotalCost = 90; aPurchaseGeneral.TotalDiscount = 0; aPurchaseGeneral.TotalFreeItemsQty = 0; aPurchaseGeneral.TotalItemsDiscount = 0; aPurchaseGeneral.TotalTax = 10; aPurchaseGeneral.VendorAccountAmountOld = 0; aPurchaseGeneral.VendorID = int.Parse(Vendors.Rows[(int)NumberOfPurchases % Vendors.Rows.Count]["ID"].ToString()); aPurchaseGeneral.VoucherNumber = PurchaseVoucherGeneralMgmt.NextVoucherNumber(); aPurchaseGeneral.CreditCardInfo = ""; int NumofDetailed = randAmount.Next(1, 20); if (PurchaseVoucherGeneralMgmt.AddVoucher(aPurchaseGeneral)) { while (NumofDetailed > 0) { PurchaseVoucherDetailed aPurchaseDetailed = new PurchaseVoucherDetailed(); string aBarcode = "Test Item " + randAmount.Next(1, (int)NumberOfItems).ToString(); DataTable aItemRow = ItemsMgmt.SelectItemByBarCode(aBarcode); if (aItemRow.Rows.Count != 0) { aPurchaseDetailed.Purchase_Voucher_Detailed_ItemID = int.Parse(aItemRow.Rows[0]["ID"].ToString()); aPurchaseDetailed.Purchase_Voucher_Detailed_VoucherNumber = aPurchaseGeneral.VoucherNumber; aPurchaseDetailed.Purchase_Voucher_Detailed_IsRevised = 0; aPurchaseDetailed.Purchase_Voucher_Detailed_ItemCost = double.Parse(aItemRow.Rows[0]["AvgUnitCost"].ToString()); aPurchaseDetailed.Purchase_Voucher_Detailed_OldAvaQty = double.Parse(aItemRow.Rows[0]["Qty"].ToString()); aPurchaseDetailed.Purchase_Voucher_Detailed_Qty = NumofDetailed; aPurchaseDetailed.Purchase_Voucher_Detailed_Discount = 0; // = double.Parse(aItemRow.Rows[0]["SellPrice"].ToString()); aPurchaseDetailed.Purchase_Voucher_Detailed_FreeItemsQty = 0; // aBillDetailed.Bill_Detailed_TotalPerUnit = aBillDetailed.Bill_Detailed_Qty * aBillDetailed.Bill_Detailed_SellPrice; PurchaseVoucherDetailedMgmt.AddItem(aPurchaseDetailed); } NumofDetailed--; } } if (cnt % 100 == 0) { label1.Text = $"Adding Purchase Order {cnt}/{NumberOfPurchases} ... ({(cnt / NumberOfPurchases) * 100 })%"; Application.DoEvents(); } } catch (Exception ex) { MessageBox.Show($"Error in {cnt} \n {ex}"); } } }
private void ListBillsBtn_Click(object sender, EventArgs e) { try { int FilterCustomerID = -1; if (CustomerNameChkBox.Checked) { FilterCustomerID = CustomerMgmt.SelectCustomerIDByPhone1(CustomerPhoneTxtBox.Text); if (FilterCustomerID == -1) { MessageBox.Show("Customer Not Found"); } } aCustomerTable = CustomerMgmt.SelectAllCustomers(); aCurrencyTable = CurrencyMgmt.SelectAll(); aUsersTable = UsersMgmt.SelectAllUsers(); aAccountsTable = AccountsMgmt.SelectAll(); aPriceLevelTable = PriceLevelsMgmt.SelectAll(); aPaymentMethodTable = PaymentMethodMgmt.SelectAll(); ListBillsDGView.Rows.Clear(); int FilterTellerNameID = 0; if (TellerNameChkBox.Checked && TellerNameComboBox.SelectedValue != null) { FilterTellerNameID = int.Parse(TellerNameComboBox.SelectedValue.ToString()); } string FilterDateFrom = ""; string FilterDateTo = ""; if (DateCheckBox.Checked) { FilterDateFrom = DateFrompicker.Value.ToShortDateString(); FilterDateTo = DateToPicker.Value.ToShortDateString(); } bool FilterCheckedBills = CkeckedBillsChkBox.Checked; bool FilterIsRevised = IsRevisedChkBox.Checked; bool FilterUnCheckedBills = UncheckedBillChkBox.Checked; bool FilterUnRevisedBills = UnRevisedChkBox.Checked; bool FilterCashCreditBills = CreditBillsChkBox.Checked; aBillTable = BillGeneralMgmt.SelectAllBills(FilterTellerNameID, FilterDateFrom, FilterDateTo, FilterCheckedBills, FilterIsRevised, FilterUnCheckedBills, FilterUnRevisedBills, FilterCustomerID, FilterCashCreditBills); if (aBillTable == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListBillsBtn_Click:DB-ERROR aBillTable=null] \n \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TotalITemsTxtBox.Text = aBillTable.Rows.Count.ToString(); if (aBillTable.Rows.Count > 0) { RowNum = 0; if (ListBillsDGView.Rows.Count < ItemsPerPage) { //TestingFor Paging pagesnumber = (int)aBillTable.Rows.Count / ItemsPerPage; if ((double.Parse(aBillTable.Rows.Count.ToString()) / ItemsPerPage - int.Parse(aBillTable.Rows.Count.ToString()) / ItemsPerPage) > 0) { pagesnumber++; } foreach (DataRow r in aBillTable.Rows) { if (ListBillsDGView.Rows.Count < ItemsPerPage) { ListBillsDGView.Rows.Add(); ListBillsDGView.Rows[RowNum].Cells["Number"].Value = aBillTable.Rows[RowNum]["Number"].ToString(); ListBillsDGView.Rows[RowNum].Cells["Date"].Value = aBillTable.Rows[RowNum]["Date"].ToString(); ListBillsDGView.Rows[RowNum].Cells["BillTime"].Value = aBillTable.Rows[RowNum]["BillTime"].ToString(); ListBillsDGView.Rows[RowNum].Cells["TotalItems"].Value = aBillTable.Rows[RowNum]["TotalItems"].ToString(); ListBillsDGView.Rows[RowNum].Cells["TotalTax"].Value = aBillTable.Rows[RowNum]["TotalTax"].ToString(); ListBillsDGView.Rows[RowNum].Cells["TotalPrice"].Value = aBillTable.Rows[RowNum]["TotalPrice"].ToString(); for (int i = 0; i < aUsersTable.Rows.Count; i++) { if (int.Parse(aUsersTable.Rows[i]["ID"].ToString()) == int.Parse(aBillTable.Rows[RowNum]["TellerID"].ToString())) { ListBillsDGView.Rows[RowNum].Cells["TellerID"].Value = aUsersTable.Rows[i]["UserName"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString(); break; } } for (int i = 0; i < aCustomerTable.Rows.Count; i++) { if (int.Parse(aCustomerTable.Rows[i]["ID"].ToString()) == int.Parse(aBillTable.Rows[RowNum]["CustomerID"].ToString())) { ListBillsDGView.Rows[RowNum].Cells["CustomerID"].Value = aCustomerTable.Rows[i]["Name"].ToString(); break; } } for (int i = 0; i < aPriceLevelTable.Rows.Count; i++) { if (int.Parse(aPriceLevelTable.Rows[i]["ID"].ToString()) == int.Parse(aBillTable.Rows[RowNum]["PriceLevelID"].ToString())) { ListBillsDGView.Rows[RowNum].Cells["PriceLevelID"].Value = aPriceLevelTable.Rows[i]["Name"].ToString(); break; } } for (int i = 0; i < aPaymentMethodTable.Rows.Count; i++) { if (int.Parse(aPaymentMethodTable.Rows[i]["ID"].ToString()) == int.Parse(aBillTable.Rows[RowNum]["PaymentMethodID"].ToString())) { ListBillsDGView.Rows[RowNum].Cells["PaymentMethodID"].Value = aPaymentMethodTable.Rows[i]["Name"].ToString(); break; } } ListBillsDGView.Rows[RowNum].Cells["TotalCost"].Value = aBillTable.Rows[RowNum]["TotalCost"].ToString(); ListBillsDGView.Rows[RowNum].Cells["Comments"].Value = aBillTable.Rows[RowNum]["Comments"].ToString(); ListBillsDGView.Rows[RowNum].Cells["SalesDiscount"].Value = aBillTable.Rows[RowNum]["SalesDiscount"].ToString(); ListBillsDGView.Rows[RowNum].Cells["DiscountPerc"].Value = aBillTable.Rows[RowNum]["DiscountPerc"].ToString(); ListBillsDGView.Rows[RowNum].Cells["CashIn"].Value = aBillTable.Rows[RowNum]["CashIn"].ToString(); ListBillsDGView.Rows[RowNum].Cells["TotalDiscount"].Value = aBillTable.Rows[RowNum]["TotalDiscount"].ToString(); if (aBillTable.Rows[RowNum]["IsChecked"].ToString() == "0") { ListBillsDGView.Rows[RowNum].Cells["IsChecked"].Value = UiText.NoTxt; } else { ListBillsDGView.Rows[RowNum].Cells["IsChecked"].Value = UiText.YesTxt; } if (aBillTable.Rows[RowNum]["IsRevised"].ToString() == "0") { ListBillsDGView.Rows[RowNum].Cells["IsRevised"].Value = UiText.NoTxt; } else { ListBillsDGView.Rows[RowNum].Cells["IsRevised"].Value = UiText.YesTxt; } ListBillsDGView.Rows[RowNum].Cells["CheckedDate"].Value = aBillTable.Rows[RowNum]["CheckedDate"].ToString(); ListBillsDGView.Rows[RowNum].Cells["CheckedBy"].Value = aBillTable.Rows[RowNum]["CheckedBy"].ToString(); ListBillsDGView.Rows[RowNum].Cells["ReviseDate"].Value = aBillTable.Rows[RowNum]["ReviseDate"].ToString(); ListBillsDGView.Rows[RowNum].Cells["RevisedBy"].Value = aBillTable.Rows[RowNum]["RevisedBy"].ToString(); ListBillsDGView.Rows[RowNum].Cells["ReviseLoss"].Value = aBillTable.Rows[RowNum]["ReviseLoss"].ToString(); RowNum++; } } PageOfTotalTxtBox.Text = "1/" + pagesnumber.ToString(); currentpage = 1; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListBillsBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private bool AddPayment() { try { semaphore = true; int NextCheckNumber = -1; double Amount = 0; if (VendorDoNotHaveAccount || AccountNotJOD) { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n 1)" + MsgTxt.VendorTxt + "\n2)" + MsgTxt.ValidAccountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); semaphore = false; return(false); } else { if (!double.TryParse(PaymentAmountTxtBox.Text, out Amount)) { MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); PaymentAmountTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; return(false); } else if (Amount == 0) { MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); PaymentAmountTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; return(false); } else { PaymentAmountTxtBox.BackColor = PaymentAmountTxtBoxCOLOR; DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString())); if (aMethodRow == null) { throw new Exception("aMethodRow==null"); } aVendorAccountRow = VendorsAccountsMgmt.SelectVendorAccountRowByVendorID(VendorID); Balance = Double.Parse(aVendorAccountRow["Amount"].ToString()); aVendorPayment = new VendorsPayments(); int PaymentNumber = VendorsPaymentsMgmt.NextPaymentNumber(); aVendorPayment.Vendor_Payment_PaymentNumber = PaymentNumber; aVendorPayment.Vendor_Payment_VendorID = VendorID; aVendorPayment.Vendor_Payment_Date = DateTime.Now.ToShortDateString(); aVendorPayment.Vendor_Payment_Time = DateTime.Now.ToShortTimeString(); int TellerID = UsersMgmt.SelectUserIDByUserName(SharedFunctions.ReturnLoggedUserName()); aVendorPayment.Vendor_Payment_TellerID = TellerID; aVendorPayment.Vendor_Payment_OldAmount = Balance; aVendorPayment.PaymentMethodID = int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()); aVendorPayment.Vendor_Payment_Comments = CommentsTxtBox.Text; aVendorPayment.MyAccountID = int.Parse(AccountComboBox.SelectedValue.ToString()); aVendorPayment.Vendor_Payment_Amount = double.Parse(PaymentAmountTxtBox.Text); Checks aCheck = new Checks(); if (aMethodRow["IsCash"].ToString() == "1") { aVendorPayment.IsCreditCard = 0; aVendorPayment.CreditCardInfo = "NOT-CREDIT"; VendorsPaymentsMgmt.AddVendorPayment(aVendorPayment); //IS REVISED AND IS CHECKED ADDED TO ZERO IN QUERY int VenAccountID = int.Parse(aVendorAccountRow["ID"].ToString()); double NewAmount = Balance - aVendorPayment.Vendor_Payment_Amount; VendorsAccountsMgmt.UpdateAccountAmountByAccountID(VenAccountID, NewAmount); double MyOldAmount = AccountsMgmt.SelectAccountAmountByID(int.Parse(AccountComboBox.SelectedValue.ToString())); AccountsMgmt.UpdateAccountAmountByAccountID(int.Parse(AccountComboBox.SelectedValue.ToString()), MyOldAmount - aVendorPayment.Vendor_Payment_Amount); } else if (aMethodRow["IsCredit"].ToString() == "1") { aVendorPayment.IsCreditCard = 1; aVendorPayment.CreditCardInfo = CreditCardInfoTxtBox.Text; VendorsPaymentsMgmt.AddVendorPayment(aVendorPayment); //IS REVISED AND IS CHECKED ADDED TO ZERO IN QUERY int VenAccountID = int.Parse(aVendorAccountRow["ID"].ToString()); double NewAmount = Balance - aVendorPayment.Vendor_Payment_Amount; VendorsAccountsMgmt.UpdateAccountAmountByAccountID(VenAccountID, NewAmount); int AccountID = int.Parse(AccountComboBox.SelectedValue.ToString()); DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(AccountID); double OldAmount = double.Parse(aAccountRow["Amount"].ToString()); double NewAmount2 = OldAmount - aVendorPayment.Vendor_Payment_Amount; AccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount2); } else { aVendorPayment.IsCreditCard = 0; aVendorPayment.CreditCardInfo = "NOT-CREDIT"; NextCheckNumber = ChecksMgmt.NextCheckNumber(); aVendorPayment.CheckNumber = NextCheckNumber; VendorsPaymentsMgmt.AddVendorPayment(aVendorPayment); aCheck.Chekcs_HolderName = HolderNameTxtBox.Text; aCheck.Chekcs_PaymentDate = CheckDatePicker.Value.ToShortDateString(); aCheck.Chekcs_IsBill = 0; aCheck.Chekcs_IsPurchaseVoucher = 0; aCheck.Chekcs_AccountID = 0; aCheck.Chekcs_Comments = CheckCommentsTxtBox.Text; aCheck.Chekcs_Amount = aVendorPayment.Vendor_Payment_Amount; aCheck.Chekcs_IsPaid = 0; aCheck.CheckNumber = NextCheckNumber; aCheck.AddingDate = DateTime.Now.ToShortDateString(); aCheck.Chekcs_PaymentDate = CheckDatePicker.Text; aCheck.Chekcs_IsVendorPayment = 1; aCheck.Chekcs_VendorPaymentNumber = aVendorPayment.Vendor_Payment_PaymentNumber; aCheck.Chekcs_IsCustomerPayment = 0; if (!ChecksMgmt.InsertCheck(aCheck)) { VendorsPaymentsMgmt.DeleteVendorPayment(aVendorPayment); MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error: CANNOT ADD CHECK] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); semaphore = false; //ReloadForm(); return(false); } } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); semaphore = false; return(true); } } } catch (Exception ex) { semaphore = false; MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddPaymentBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return(false); } }