Example #1
0
        public void UpdateVariables(DataRow aCustomerDataRow)
        {
            try
            {
                IsLoading                    = true;
                Phone1ComboBox.Text          = aCustomerDataRow["Phone1"].ToString();
                Phone1ComboBox.SelectedValue = aCustomerDataRow["ID"].ToString();
                CustomerID                   = int.Parse(aCustomerDataRow["ID"].ToString());
                NameTxtBox.Text              = aCustomerDataRow["Name"].ToString();
                EmailTxtBox.Text             = aCustomerDataRow["Email"].ToString();
                AddressTxtBox.Text           = aCustomerDataRow["Address"].ToString();
                Phone1TxtBox.Text            = aCustomerDataRow["Phone1"].ToString();
                DataRow CusAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID);
                if (CusAccount != null)
                {
                    MakeUserAccountChkBox.Checked = true;
                }
                else
                {
                    MakeUserAccountChkBox.Checked = false;
                }

                UpdateCustomerBtn.Show();
                IsLoading = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #2
0
        private void CustomerNameComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (CustomerNameComboBox.SelectedValue != null)
                {
                    semaphore = true;

                    CustomerPhoneTxtBox.Text = CustomerNameComboBox.SelectedValue.ToString();
                    aCusomerAccountRow       = null;
                    aCustomerRow             = CustomerMgmt.SelectCustomerRowByPhone1(CustomerPhoneTxtBox.Text);

                    if (aCustomerRow == null) // No Customer
                    {
                        CustomerNameComboBox.Text  = string.Empty;
                        CustomerBalanceTxtBox.Text = string.Empty;
                        //
                        CommentsTxtBox.ReadOnly     = true;
                        CustomerDoNotHaveAccount    = true;
                        PaymentAmountTxtBox.Enabled = false;
                    }
                    else
                    {
                        string CustomerName = aCustomerRow["Name"].ToString();
                        CustomerID         = int.Parse(aCustomerRow["ID"].ToString());
                        aCusomerAccountRow = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID);
                        if (aCusomerAccountRow == null)
                        {
                            CustomerNameComboBox.Text  = CustomerName;
                            CustomerBalanceTxtBox.Text = UiText.CustomerDoNotHaveAccountTxt;
                            CustomerDoNotHaveAccount   = true;
                            //
                            CommentsTxtBox.ReadOnly     = true;
                            PaymentAmountTxtBox.Enabled = false;
                        }
                        else
                        {
                            Balance = Double.Parse(aCusomerAccountRow["Amount"].ToString());
                            CustomerNameComboBox.Text   = CustomerName;
                            CustomerBalanceTxtBox.Text  = Balance.ToString();
                            CommentsTxtBox.ReadOnly     = false;
                            CustomerDoNotHaveAccount    = false;
                            PaymentAmountTxtBox.Enabled = true;
                        }
                    }
                    semaphore = false;
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [CustomerNameComboBox_SelectedIndexChanged] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #3
0
        private void Phone1ComboBox_TextChanged(object sender, EventArgs e)
        {
            if (!IsLoading && !OnExit)
            {
                if (Validators.TxtBoxNotEmpty(Phone1ComboBox.Text))
                {
                    Phone1ComboBox.BackColor = Color.White;
                    DataRow DR = CustomerMgmt.SelectCustomerByPhone1(Phone1ComboBox.Text);
                    if (DR != null)
                    {
                        UpdateCustomerBtn.Show();
                        CustomerID         = int.Parse(DR["ID"].ToString());
                        NameTxtBox.Text    = DR["Name"].ToString();
                        AddressTxtBox.Text = DR["Address"].ToString();
                        EmailTxtBox.Text   = DR["Email"].ToString();
                        Phone1TxtBox.Text  = DR["Phone1"].ToString();

                        DataRow CusAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID);
                        if (CusAccount != null)
                        {
                            MakeUserAccountChkBox.Checked = true;
                        }
                        else
                        {
                            MakeUserAccountChkBox.Checked = false;
                        }
                    }
                    else
                    {
                        UpdateCustomerBtn.Hide();
                        // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [Phone1ComboBox_TextChanged:SelectCustomerByPhone1 ==null] \n Exception: " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    UpdateCustomerBtn.Hide();

                    MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Phone1ComboBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                    Phone1ComboBox.Focus();
                }
            }
        }
Example #4
0
        private void UpdateCustomerBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (NameTxtBox.Text.ToUpper() == "CASH")
                {
                    return;
                }
                if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(Phone1TxtBox.Text))
                {
                    Phone1TxtBox.BackColor = PhoneColor;
                    NameTxtBox.BackColor   = NameColor;

                    if (!CustomerMgmt.IsPhoneUsed(Phone1TxtBox.Text) || Phone1TxtBox.Text == Phone1ComboBox.Text)
                    {
                        Customer aCustomer = new Customer();
                        aCustomer.Customer_Name    = NameTxtBox.Text;
                        aCustomer.Customer_Address = AddressTxtBox.Text;
                        aCustomer.Customer_Email   = EmailTxtBox.Text;
                        aCustomer.Customer_Phone1  = Phone1TxtBox.Text;
                        aCustomer.Customer_ID      = CustomerID;
                        DataRow CusAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID);

                        if (MakeUserAccountChkBox.Checked == false)
                        {
                            if (CusAccount != null)
                            {
                                Err1.Show();
                            }
                            else
                            {
                                CustomerMgmt.UpdateInfomationByID(aCustomer);
                                MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.Close();
                            }
                        }
                        else
                        {
                            if (CusAccount == null)
                            {
                                if (!CustomersAccountsMgmt.InsertCustomerAccount(CustomerID))
                                {
                                    MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            if (!CustomerMgmt.UpdateInfomationByID(aCustomer))
                            {
                                MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                throw new Exception("Database Error in [Update Information By ID]");
                            }
                            else
                            {
                                MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.PhoneInUse, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    if (!Validators.TxtBoxNotEmpty(Phone1TxtBox.Text))
                    {
                        Phone1TxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        Phone1TxtBox.Focus();
                    }
                    else
                    {
                        Phone1TxtBox.BackColor = PhoneColor;
                    }

                    if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text))
                    {
                        NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        NameTxtBox.Focus();
                    }
                    else
                    {
                        NameTxtBox.BackColor = NameColor;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateCustomerBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #5
0
        private void AddCustomerBtn_Click(object sender, EventArgs e)
        {
            try
            {
                double TestParserBal = 0.00;
                if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(Phone1TxtBox.Text))
                {
                    if (MakeUserAccountChkBox.Checked)
                    {
                        if (!double.TryParse(OpenBalTxtBox.Text, out TestParserBal))
                        {
                            MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    if (!CustomerMgmt.IsPhoneUsed(Phone1TxtBox.Text))
                    {
                        Customer aCustomer = new Customer();
                        aCustomer.Customer_Name    = NameTxtBox.Text;
                        aCustomer.Customer_Address = AddressTxtBox.Text;
                        aCustomer.Customer_Email   = EmailTxtBox.Text;
                        aCustomer.Customer_Phone1  = Phone1TxtBox.Text;

                        if (CustomerMgmt.InsertCustomer(aCustomer))
                        {
                            if (MakeUserAccountChkBox.Checked)
                            {
                                int CustomerID = CustomerMgmt.SelectCustomerIDByPhone1(Phone1TxtBox.Text);
                                if (!CustomersAccountsMgmt.InsertCustomerAccount(CustomerID))
                                {
                                    MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                int AccountID = int.Parse(CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID)["ID"].ToString());
                                CustomersAccountsMgmt.UpdateAccountAmountByAccountID(AccountID, TestParserBal);
                            }

                            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.CustomerInfoGB.Controls.OfType <TextBox>())
                                {
                                    aTextBox.Text = "";
                                }
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.PhoneInUse, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    if (!Validators.TxtBoxNotEmpty(Phone1TxtBox.Text))
                    {
                        Phone1TxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        Phone1TxtBox.Focus();
                    }
                    else
                    {
                        Phone1TxtBox.BackColor = PhoneColor;
                    }

                    if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text))
                    {
                        NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        NameTxtBox.Focus();
                    }
                    else
                    {
                        NameTxtBox.BackColor = NameColor;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddCustomerBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #6
0
        private void ReviseBillBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (aBillGeneralRow["IsRevised"].ToString() == "0")
                {
                    if (CashMethodComboBox.SelectedIndex == 1)//iscredit
                    {
                        int     CustomerID       = CustomerMgmt.SelectCustomerIDByPhone1(PhoneTxtBox.Text);
                        DataRow aCustomerAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID);
                        double  OldAmount        = double.Parse(aCustomerAccount["Amount"].ToString());
                        double  NewAmount        = OldAmount - double.Parse(TotalTxtBox.Text);
                        int     AccountID        = int.Parse(aCustomerAccount["ID"].ToString());
                        CustomersAccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount);
                    }
                    else
                    {//int.Parse(AccountComboBox.SelectedValue.ToString());
                        int     AccountID   = int.Parse(aBillGeneralRow["AccountID"].ToString());
                        DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(AccountID);
                        double  OldAmount   = double.Parse(aAccountRow["Amount"].ToString());
                        double  NewAmount   = OldAmount - double.Parse(TotalTxtBox.Text);;
                        AccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount);
                    }
                    //Mark the check (if any) as revised
                    DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aBillGeneralRow["PaymentMethodID"].ToString()));
                    if (aMethodRow["IsCheck"].ToString() == "1")
                    {
                        ChecksMgmt.MakeCheckRevised(int.Parse(aBillGeneralRow["CheckNumber"].ToString()), DateTime.Now.ToShortDateString());
                    }
                    //Now Update AvgUnitCost
                    double CostLoss = 0;
                    foreach (DataGridViewRow r in TeldgView.Rows)
                    {
                        if (!r.IsNewRow)
                        {
                            int    ItemID             = ItemsMgmt.SelectItemIDByBarcode(TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString());
                            double OldAvgUnitCost     = BillDetailedMgmt.SelectOldAvgUnitCostByID(ItemID, int.Parse(aBillGeneralRow["Number"].ToString()));
                            double ReturnQty          = double.Parse(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString());
                            double CurrentAvgUnitCost = ItemsMgmt.SelectItemCostByBarcode(TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString());
                            double CurrentAvaQty      = ItemsMgmt.SelectItemQtyByID(ItemID);
                            double NewAvgUnitCost     = CurrentAvgUnitCost;
                            if ((ReturnQty + CurrentAvaQty) != 0) //to avoid division by zero
                            {
                                NewAvgUnitCost = ((CurrentAvgUnitCost * CurrentAvaQty) + (ReturnQty * OldAvgUnitCost)) / (ReturnQty + CurrentAvaQty);
                            }
                            CostLoss += (NewAvgUnitCost - OldAvgUnitCost) * BillDetailedMgmt.SelectAllItemsSoldAfterBillNumber(ItemID, int.Parse(aBillGeneralRow["Number"].ToString()));
                            ItemsMgmt.UpdateItemQtyandAvgUnitCostByID(ItemID, (ReturnQty + CurrentAvaQty), NewAvgUnitCost);
                            BillDetailedMgmt.MakeItemAsRevised(int.Parse(aBillGeneralRow["Number"].ToString()), ItemID);
                        }
                    }
                    //Now we should mark the bill general as reversed
                    if (!BillGeneralMgmt.UpdateBillToRevised(SharedFunctions.ReturnLoggedUserName(), DateTime.Now.ToShortDateString(), int.Parse(aBillGeneralRow["Number"].ToString()), CostLoss))
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DB-ERROR-EditBill-ReviseBillBtn_Click] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }

                    MessageBox.Show(MsgTxt.ReversedSuccessfullyTxt, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(MsgTxt.AlreadyReversedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-ReviseBillBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }
Example #7
0
        public bool CutomerBalanceListReport(bool PrintToThermal, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool TableBorder = false, bool Preview = false, bool colored = false)
        {
            List <DataTable> aDTlist = new List <DataTable>();

            DataTable aCustomerTable = CustomerMgmt.SelectAllCustomers();

            aCustomerTable.Columns.Add("Balance");

            Ordercolumns.SetColumnsOrder(aCustomerTable, new string[] { "ID", "Name", "Balance", "Phone1", "Email", "Address" });
            DataTable aCustomerAccountTable = CustomersAccountsMgmt.SelectAll();

            if (aCustomerTable.Rows.Count > 0)
            {
                int RowNum = 0;
                foreach (DataRow r in aCustomerTable.Rows)
                {
                    if (aCustomerAccountTable != null)
                    {
                        for (int i = 0; i < aCustomerAccountTable.Rows.Count; i++)
                        {
                            if (int.Parse(aCustomerTable.Rows[RowNum]["ID"].ToString()) == int.Parse(aCustomerAccountTable.Rows[i]["CustomerID"].ToString()))
                            {
                                aCustomerTable.Rows[RowNum]["Balance"] = aCustomerAccountTable.Rows[i]["Amount"].ToString();
                            }
                        }
                    }
                    RowNum++;
                }

                aCustomerTable.Columns.Remove("ID");
                if (TableBorder)
                {
                    aCustomerTable.Columns[0].ColumnName = "[Border=true1]" + aCustomerTable.Columns[0].ColumnName;
                }


                //REMOVING EMPTY COLUMNS
                List <string> aColumnsToRemove = new List <string>();
                foreach (DataColumn aColumn in aCustomerTable.Columns)
                {
                    bool ColumnEmpty = false;
                    for (int i = 0; i < aCustomerTable.Rows.Count; i++)
                    {
                        if (aCustomerTable.Rows[i][aColumn].ToString().Trim() == "")
                        {
                            ColumnEmpty = true;
                        }
                        else
                        {
                            ColumnEmpty = false;
                            break;
                        }
                    }
                    if (ColumnEmpty)
                    {
                        aColumnsToRemove.Add(aColumn.ColumnName);
                    }
                }
                for (int i = 0; i < aColumnsToRemove.Count; i++)
                {
                    aCustomerTable.Columns.Remove(aColumnsToRemove[i]);
                }
                //END REMOVING EMPTY COLUMNS
                aDTlist.Add(aCustomerTable);

                List <string> aHeaderList = ReportsHelper.ImportReportHeader(0, 1);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);
                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
                aHeaderList.Add("<b><font size=4>" + "Customers Balance Summary" + " </font>");
                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);

                if (Preview)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", false, "", colored);
                    return(true);
                }

                else if (ExportToPdf)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                    return(true);
                }
                else if (ExportToExcel)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                    return(true);
                }
                else if (PrintToThermal)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false); //there is no items in the customer table
            }
        }
Example #8
0
        public void UpdateVariables(DataRow aCustomerPaymentRow)
        {
            try
            {
                PaymentNumberTxtBox.Text  = aCustomerPaymentRow["PaymentNumber"].ToString();
                aCustomerPaymentRowGlobal = aCustomerPaymentRow;

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

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

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

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

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

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

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

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

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

                DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(int.Parse(aCustomerPaymentRow["AccountID"].ToString()));
                if (aAccountRow == null)
                {
                    // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectAccountRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new Exception("EditCustomerPayment-SelectAccountRowByID Returned Null");
                }
                else
                {
                    AccountComboBox.Text          = aAccountRow["Name"].ToString();
                    AccountDescriptionTxtBox.Text = aAccountRow["Description"].ToString();
                    CreditCardInfoTxtBox.Text     = aCustomerPaymentRow["CreditCardInfo"].ToString();
                    AccountBalanceTxtBox.Text     = aAccountRow["Amount"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditCustomerPayment-UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #9
0
        private void RevisePaymentBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (aCustomerPaymentRowGlobal["IsRevised"].ToString() == "0")
                {
                    string  RevisedBy     = SharedFunctions.ReturnLoggedUserName();
                    string  ReviseDate    = DateTime.Now.ToShortDateString();
                    string  ReviseTime    = DateTime.Now.ToShortTimeString();
                    int     PaymentNumber = int.Parse(aCustomerPaymentRowGlobal["PaymentNumber"].ToString());
                    DataRow aMethodRow    = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aCustomerPaymentRowGlobal["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");
                    }
                    if (!CustomersPaymentsMgmt.UpdatePaymentToRevised(RevisedBy, ReviseDate, ReviseTime, PaymentNumber))
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DB-ERROR-EditcustomerPayment-RevisePaymentBtn_Click-FUNC:UpdatePaymentToRevised] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }

                    if (aMethodRow["IsCheck"].ToString() == "1")
                    {
                        ChecksMgmt.MakeCheckRevised(int.Parse(aCustomerPaymentRowGlobal["CheckNumber"].ToString()), DateTime.Now.ToShortDateString());
                    }



                    double Amount        = double.Parse(aCustomerPaymentRowGlobal["Amount"].ToString());
                    double CurrentAmount = double.Parse(aCustomerAccount["Amount"].ToString());
                    int    AccountID     = int.Parse(aCustomerAccount["ID"].ToString());
                    double NewAmount     = CurrentAmount + Amount;

                    if (!CustomersAccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount))
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DB-ERROR-EditcustomerPayment-RevisePaymentBtn_Click-FUNC:UpdateAccountAmountByAccountID] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                    else
                    {
                        //int.Parse(AccountComboBox.SelectedValue.ToString());
                        int     MyAccountID = int.Parse(aCustomerPaymentRowGlobal["AccountID"].ToString());
                        DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(MyAccountID);
                        double  OldAmount   = double.Parse(aAccountRow["Amount"].ToString());
                        double  MyNewAmount = OldAmount - Amount;
                        AccountsMgmt.UpdateAccountAmountByAccountID(MyAccountID, MyNewAmount);
                    }

                    //Mark the check (if any) as revised
                    MessageBox.Show(MsgTxt.ReversedSuccessfullyTxt, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(MsgTxt.AlreadyReversedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditcustomerPayment-RevisePaymentBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }
Example #10
0
        private void ListCustomersBtn_Click(object sender, EventArgs e)
        {
            try
            {
                aCustomerTable        = CustomerMgmt.SelectAllCustomers();
                aCustomerAccountTable = CustomersAccountsMgmt.SelectAll();
                if (aCustomerTable != null)
                {
                    //if (aCustomerTable.Rows.Count>1&& aCustomerAccountTable == null)
                    //{
                    //    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListCustomersBtn:DB-ERROR   aCustomerAccountTable=null] \n Exception: \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //    return;
                    //}
                    TotalITemsTxtBox.Text = aCustomerTable.Rows.Count.ToString();
                    if (aCustomerTable.Rows.Count > 0)
                    {
                        pagesnumber = (int)aCustomerTable.Rows.Count / ItemsPerPage;
                        if ((double.Parse(aCustomerTable.Rows.Count.ToString()) / ItemsPerPage - int.Parse(aCustomerTable.Rows.Count.ToString()) / ItemsPerPage) > 0)
                        {
                            pagesnumber++;
                        }

                        RowNum = 0;
                        ListCustomersDGView.Rows.Clear();
                        foreach (DataRow r in aCustomerTable.Rows)
                        {
                            if (ListCustomersDGView.Rows.Count < ItemsPerPage)
                            {
                                ListCustomersDGView.Rows.Add();
                                ListCustomersDGView.Rows[RowNum].Cells["Namecol"].Value = aCustomerTable.Rows[RowNum]["Name"].ToString();
                                ListCustomersDGView.Rows[RowNum].Cells["Email"].Value   = aCustomerTable.Rows[RowNum]["Email"].ToString();
                                ListCustomersDGView.Rows[RowNum].Cells["Address"].Value = aCustomerTable.Rows[RowNum]["Address"].ToString();
                                ListCustomersDGView.Rows[RowNum].Cells["Phone1"].Value  = aCustomerTable.Rows[RowNum]["Phone1"].ToString();
                                if (aCustomerAccountTable != null)
                                {
                                    for (int i = 0; i < aCustomerAccountTable.Rows.Count; i++)
                                    {
                                        if (int.Parse(aCustomerTable.Rows[RowNum]["ID"].ToString()) == int.Parse(aCustomerAccountTable.Rows[i]["CustomerID"].ToString()))
                                        {
                                            ListCustomersDGView.Rows[RowNum].Cells["AccountAmount"].Value = aCustomerAccountTable.Rows[i]["Amount"].ToString();
                                        }
                                    }
                                }
                                RowNum++;
                            }
                        }
                        PageOfTotalTxtBox.Text = "1/" + pagesnumber.ToString();
                        currentpage            = 1;
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListCustomersBtn:DB-ERROR  aCustomerTable=null  \n Exception: \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListCustomersBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Example #11
0
        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);
        }