private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (dgv.SelectedRows.Count > 0) { if (GeneralFunctions.ValidateString(txt_DeliveryTypeName.Text, "Please Enter a valid Delivery Type Name") && GeneralFunctions.AccountNumberValidate(txt_AccountNumber.Text, out currentAccountNumber)) { DataRow[] rArr = dbAccountingProjectDS.APDeliveryType.Select("DeliveryTypeID = '" + txt_DeliveryTypeID.Text + "'"); rArr[0]["DeliveryTypeName"] = txt_DeliveryTypeName.Text; rArr[0]["DeliveryTypeAccountNumber"] = txt_AccountNumber.Text; rArr[0]["DeliveryPercentage"] = txt_Percentage.Text; //ClearAll(); } } else { MessageBox.Show("Please Select the row that you want to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } dgv.ClearSelection(); groupBox1.Enabled = false; btnedit.Visible = true; Btnsaveedit.Visible = false; btn_New.Enabled = true; btndelete.Enabled = false; btnedit.Enabled = false; SaveChanges(); }
private bool ValidateInput() { if (!GeneralFunctions.AccountNumberValidate(txt_BankAccountNumber.Text, out GLbankAccountNumber) || !GeneralFunctions.AccountNumberValidate(txt_BankAccount.Text, out bankAccountNumber) || !GeneralFunctions.ValidateString(txt_BankCode.Text, "Please Specify the Bank Code") || !GeneralFunctions.ValidateComboBox(cb_Currency, "Please Specify the Bank Currency")) { return(false); } if (txt_ServiceAccountNumber.Text != "") { if (!GeneralFunctions.AccountNumberValidate(txt_ServiceAccountNumber.Text, out serviceAccountNumber)) { return(false); } } if (txt_BankAccountDescription.Text != "") { if (!GeneralFunctions.ValidateSpacedString(txt_BankAccountDescription.Text, "Please Specify the Bank Account Description")) { return(false); } } if (txt_InterestEarned.Text != "") { if (!GeneralFunctions.ValidateDouble(txt_InterestEarned.Text, "Please Specify the Bank earned interest", out interestEarned)) { return(false); } } return(true); }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (dgv.SelectedRows.Count > 0) { if (GeneralFunctions.ValidateString(txt_Bank_Account_Code.Text, "Please Enter a valid Bank Account Code") && GeneralFunctions.AccountNumberValidate(txt_Bank_GL_Account.Text, out Bank_GL_Account) && GeneralFunctions.AccountNumberValidate(txt_Service_Charge_Account.Text, out Service_Charge_Account) && GeneralFunctions.AccountNumberValidate(txt_Interest_Earned_Account.Text, out Interest_Earned_Account)) { DataRow[] rArr = dbAccountingProjectDS.Bank_Account_Setup.Select("Bank_Account_ID = '" + txt_Bank_Account_ID.Text + "'"); rArr[0]["Bank_Account_Code"] = txt_Bank_Account_Code.Text; rArr[0]["Bank_Account_Name"] = txt_Bank_Account_Name.Text; rArr[0]["Bank_GL_Account"] = txt_Bank_GL_Account.Text; rArr[0]["Service_Charge_Account"] = txt_Service_Charge_Account.Text; rArr[0]["Interest_Earned_Account"] = txt_Interest_Earned_Account.Text; rArr[0]["AR_Checks_Tran_code"] = cb_AR_Checks_Tran_code.SelectedValue.ToString(); rArr[0]["Check_Format"] = txt_Check_Format.Text; rArr[0]["Deduction_Slip_Format"] = txt_Deduction_Slip_Format.Text; //ClearAll(); } } else { MessageBox.Show("Please Select the row that you want to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } dgv.ClearSelection(); groupBox1.Enabled = false; btnedit.Visible = true; Btnsaveedit.Visible = false; btn_New.Enabled = true; btndelete.Enabled = false; btnedit.Enabled = false; SaveChanges(); }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (dgv.SelectedRows.Count > 0) { if (GeneralFunctions.ValidateString(txt_Bank_Deposit_Type_Code.Text, "Please Enter a valid Bank Account Code") && GeneralFunctions.AccountNumberValidate(txt_Acct_Deposit_From.Text, out Acct_Deposit_From)) { if (!chkCredit_Card_Deposit.Checked) { if (!GeneralFunctions.AccountNumberValidate(txt_Cash_Short_Over_Acct.Text, out Cash_Short_Over_Acct)) { return; } } if (chkCredit_Card_Deposit.Checked) { if (!GeneralFunctions.AccountNumberValidate(txt_CC_Discount_Acct.Text, out CC_Discount_Acct)) { return; } } DataRow[] rArr = dbAccountingProjectDS.Bank_Deposit_Type.Select("Bank_Deposit_Type_ID = '" + txt_Bank_Deposit_Type_ID.Text + "'"); rArr[0]["Bank_Deposit_Type_Code"] = txt_Bank_Deposit_Type_Code.Text; rArr[0]["Bank_Deposit_Type_Name"] = txt_Bank_Deposit_Type_Name.Text; rArr[0]["Acct_Deposit_From"] = txt_Acct_Deposit_From.Text; rArr[0]["Credit_Card_Deposit"] = chkCredit_Card_Deposit.Checked; double CC_Fees = 0; double.TryParse(txt_CC_Fees.Text, out CC_Fees); if (chkCredit_Card_Deposit.Checked) { rArr[0]["CC_Discount_Acct"] = txt_CC_Discount_Acct.Text; rArr[0]["CC_Fees"] = CC_Fees; rArr[0]["Override_Fees"] = chkOverride_Fees.Checked; rArr[0]["Cash_Short_Over_Acct"] = ""; } else { rArr[0]["CC_Discount_Acct"] = ""; rArr[0]["CC_Fees"] = 0; rArr[0]["Override_Fees"] = false; rArr[0]["Cash_Short_Over_Acct"] = txt_Cash_Short_Over_Acct.Text; } rArr[0]["Bank_Account_ID"] = cb_Bank_Account_ID.SelectedValue.ToString(); //ClearAll(); } } else { MessageBox.Show("Please Select the row that you want to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } dgv.ClearSelection(); groupBox1.Enabled = false; btnedit.Visible = true; Btnsaveedit.Visible = false; btn_New.Enabled = true; btndelete.Enabled = false; btnedit.Enabled = false; SaveChanges(); }
private void btn_Done_Click(object sender, EventArgs e) { if (GeneralFunctions.AccountNumberValidate(txt_AccountNumber.Text, out validAccountNumber) && ValidateInput()) { SaveAPGeneralSetup(); this.Close(); } }
private void btn_Ok_Click(object sender, EventArgs e) { if (GeneralFunctions.AccountNumberValidate(txt_AccountBalanceSheet.Text, out accountBalanceSheet) && GeneralFunctions.AccountNumberValidate(txt_AccountIncomeStat.Text, out accountIncomeStatment)) { SaveGLGeneralSetup(); this.Close(); } }
private void insertToolStripMenuItem_Click(object sender, EventArgs e) { if (GeneralFunctions.ValidateString(txt_Bank_Account_Code.Text, "Please Enter a valid Bank Account Code") && GeneralFunctions.AccountNumberValidate(txt_Bank_GL_Account.Text, out Bank_GL_Account) && GeneralFunctions.AccountNumberValidate(txt_Service_Charge_Account.Text, out Service_Charge_Account) && GeneralFunctions.AccountNumberValidate(txt_Interest_Earned_Account.Text, out Interest_Earned_Account)) { sqlcon.Open(); SqlCommand cmdSelect = new SqlCommand("Select Bank_Account_ID from Bank_Account_Setup where Bank_Account_ID = '" + txt_Bank_Account_ID.Text + "'", sqlcon); SqlDataReader dr = cmdSelect.ExecuteReader(); if (!dr.HasRows && !GeneralFunctions.FindRow("Bank_Account_ID = '" + txt_Bank_Account_ID.Text + "'", dbAccountingProjectDS.Bank_Account_Setup)) { DataRow r = dbAccountingProjectDS.Bank_Account_Setup.NewRow(); r["Bank_Account_ID"] = int.Parse(txt_Bank_Account_ID.Text); r["Bank_Account_Code"] = txt_Bank_Account_Code.Text; r["Bank_Account_Name"] = txt_Bank_Account_Name.Text; r["Bank_GL_Account"] = txt_Bank_GL_Account.Text; r["Service_Charge_Account"] = txt_Service_Charge_Account.Text; r["Interest_Earned_Account"] = txt_Interest_Earned_Account.Text; r["AR_Checks_Tran_code"] = cb_AR_Checks_Tran_code.SelectedValue.ToString(); r["Check_Format"] = txt_Check_Format.Text; r["Deduction_Slip_Format"] = txt_Deduction_Slip_Format.Text; dbAccountingProjectDS.Bank_Account_Setup.Rows.Add(r); ClearAll(); dr.Close(); sqlcon.Close(); } else { if (DialogResult.OK == MessageBox.Show("The given Bank Account Code is already exists \n Preceed if you want to edit", "Alert", MessageBoxButtons.OKCancel)) { DataRow[] rArr = dbAccountingProjectDS.Bank_Account_Setup.Select("Bank_Account_ID = '" + txt_Bank_Account_ID.Text + "'"); rArr[0]["Bank_Account_Code"] = txt_Bank_Account_Code.Text; rArr[0]["Bank_Account_Name"] = txt_Bank_Account_Name.Text; rArr[0]["Bank_GL_Account"] = txt_Bank_GL_Account.Text; rArr[0]["Service_Charge_Account"] = txt_Service_Charge_Account.Text; rArr[0]["Interest_Earned_Account"] = txt_Interest_Earned_Account.Text; rArr[0]["AR_Checks_Tran_code"] = cb_AR_Checks_Tran_code.SelectedValue.ToString(); rArr[0]["Check_Format"] = txt_Check_Format.Text; rArr[0]["Deduction_Slip_Format"] = txt_Deduction_Slip_Format.Text; ClearAll(); } else { ClearAll(); } dr.Close(); sqlcon.Close(); } groupBox1.Enabled = false; btn_New.Visible = true; btnSavenew.Visible = false; SaveChanges(); } }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (dgv.SelectedRows.Count > 0) { if (GeneralFunctions.ValidateString(txt_CurrencyCode.Text, "Please Specify the Currency Code") && GeneralFunctions.ValidateString(txt_CurrencyDescription.Text, "Please Specify the Currency Description") && GeneralFunctions.AccountNumberValidate(txt_GLAccountNumber.Text, out GLAccountNo) && GeneralFunctions.AccountNumberValidate(txt_CurrencyAccountNumber.Text, out CurrencyAccountNumber) && BaseCurrenyValidate()) { DataRow[] rArr = dbAccountingProjectDS.GLCurrency.Select("CurrencyNumber = '" + txt_CurrencyCodeID.Text + "'"); if (rArr.Length != 0) { rArr[0]["CurrencyCode"] = txt_CurrencyCode.Text; rArr[0]["CurrencyDescription"] = txt_CurrencyDescription.Text; rArr[0]["GLAccountNumber"] = GLAccountNo; rArr[0]["CurrencyPLAccountNumber"] = CurrencyAccountNumber; if (checkBox_Active.Checked) { rArr[0]["Active"] = 1; } else { rArr[0]["Active"] = 0; } if (checkBox_baseCurrency.Checked) { baseCurrencyAvailable = false; rArr[0]["BaseCurrency"] = 1; } else if (!checkBox_baseCurrency.Checked && rArr[0]["BaseCurrency"].ToString() == "True") { baseCurrencyAvailable = false; rArr[0]["BaseCurrency"] = 0; MessageBox.Show("The values in the conversion table has to be changed on change of the base currency\n Please Insert the conversion table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!checkBox_baseCurrency.Checked) { rArr[0]["BaseCurrency"] = 0; } } ClearAll(); if (save) { save = false; } } } else { MessageBox.Show("Please Select the row that you want to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } dgv.ClearSelection(); }
private void insertToolStripMenuItem_Click(object sender, EventArgs e) { if (GeneralFunctions.ValidateString(txt_DeliveryTypeName.Text, "Please Enter a valid Delivery Type Name") && GeneralFunctions.AccountNumberValidate(txt_AccountNumber.Text, out currentAccountNumber)) { sqlcon.Open(); SqlCommand cmdSelect = new SqlCommand("Select DeliveryTypeID from APDeliveryType where DeliveryTypeID = '" + txt_DeliveryTypeID.Text + "'", sqlcon); SqlDataReader dr = cmdSelect.ExecuteReader(); if (!dr.HasRows && !GeneralFunctions.FindRow("DeliveryTypeID = '" + txt_DeliveryTypeID.Text + "'", dbAccountingProjectDS.APDeliveryType)) { DataRow r = dbAccountingProjectDS.APDeliveryType.NewRow(); r["DeliveryTypeID"] = int.Parse(txt_DeliveryTypeID.Text); //GeneralFunctions.DeliveryTypeID++; //currentDeliveryTypeID = GeneralFunctions.DeliveryTypeID; r["DeliveryTypeName"] = txt_DeliveryTypeName.Text; r["DeliveryPercentage"] = txt_Percentage.Text; r["DeliveryTypeAccountNumber"] = txt_AccountNumber.Text; dbAccountingProjectDS.APDeliveryType.Rows.Add(r); ClearAll(); dr.Close(); sqlcon.Close(); } else { if (DialogResult.OK == MessageBox.Show("The given Delivery Type Name is already exists \n Preceed if you want to edit", "Alert", MessageBoxButtons.OKCancel)) { DataRow[] rArr = dbAccountingProjectDS.APDeliveryType.Select("DeliveryTypeID = '" + txt_DeliveryTypeID.Text + "'"); rArr[0]["DeliveryTypeName"] = txt_DeliveryTypeName.Text; rArr[0]["DeliveryPercentage"] = txt_Percentage.Text; rArr[0]["DeliveryTypeAccountNumber"] = currentAccountNumber; ClearAll(); } else { ClearAll(); } dr.Close(); sqlcon.Close(); } groupBox1.Enabled = false; btn_New.Visible = true; btnSavenew.Visible = false; SaveChanges(); } }
private void insertToolStripMenuItem_Click(object sender, EventArgs e) { if (GeneralFunctions.ValidateString(txt_Bank_Deposit_Type_Code.Text, "Please Enter a valid Bank Account Code") && GeneralFunctions.AccountNumberValidate(txt_Acct_Deposit_From.Text, out Acct_Deposit_From)) { if (!chkCredit_Card_Deposit.Checked) { if (!GeneralFunctions.AccountNumberValidate(txt_Cash_Short_Over_Acct.Text, out Cash_Short_Over_Acct)) { return; } } if (chkCredit_Card_Deposit.Checked) { if (!GeneralFunctions.AccountNumberValidate(txt_CC_Discount_Acct.Text, out CC_Discount_Acct)) { return; } } sqlcon.Open(); SqlCommand cmdSelect = new SqlCommand("Select Bank_Deposit_Type_ID from Bank_Deposit_Type where Bank_Deposit_Type_ID = '" + txt_Bank_Deposit_Type_ID.Text + "'", sqlcon); SqlDataReader dr = cmdSelect.ExecuteReader(); if (!dr.HasRows && !GeneralFunctions.FindRow("Bank_Deposit_Type_ID = '" + txt_Bank_Deposit_Type_ID.Text + "'", dbAccountingProjectDS.Bank_Deposit_Type)) { DataRow r = dbAccountingProjectDS.Bank_Deposit_Type.NewRow(); r["Bank_Deposit_Type_ID"] = int.Parse(txt_Bank_Deposit_Type_ID.Text); r["Bank_Deposit_Type_Code"] = txt_Bank_Deposit_Type_Code.Text; r["Bank_Deposit_Type_Name"] = txt_Bank_Deposit_Type_Name.Text; r["Acct_Deposit_From"] = txt_Acct_Deposit_From.Text; r["Credit_Card_Deposit"] = chkCredit_Card_Deposit.Checked; double CC_Fees = 0; double.TryParse(txt_CC_Fees.Text, out CC_Fees); if (chkCredit_Card_Deposit.Checked) { r["CC_Discount_Acct"] = txt_CC_Discount_Acct.Text; r["CC_Fees"] = CC_Fees; r["Override_Fees"] = chkOverride_Fees.Checked; r["Cash_Short_Over_Acct"] = ""; } else { r["CC_Discount_Acct"] = ""; r["CC_Fees"] = 0; r["Override_Fees"] = false; r["Cash_Short_Over_Acct"] = txt_Cash_Short_Over_Acct.Text; } r["Bank_Account_ID"] = cb_Bank_Account_ID.SelectedValue.ToString(); dbAccountingProjectDS.Bank_Deposit_Type.Rows.Add(r); ClearAll(); dr.Close(); sqlcon.Close(); } else { if (DialogResult.OK == MessageBox.Show("The given Bank Deposit Type Code is already exists \n Preceed if you want to edit", "Alert", MessageBoxButtons.OKCancel)) { DataRow[] rArr = dbAccountingProjectDS.Bank_Deposit_Type.Select("Bank_Deposit_Type_ID = '" + txt_Bank_Deposit_Type_ID.Text + "'"); rArr[0]["Bank_Deposit_Type_Code"] = txt_Bank_Deposit_Type_Code.Text; rArr[0]["Bank_Deposit_Type_Name"] = txt_Bank_Deposit_Type_Name.Text; rArr[0]["Acct_Deposit_From"] = txt_Acct_Deposit_From.Text; rArr[0]["Credit_Card_Deposit"] = chkCredit_Card_Deposit.Checked; double CC_Fees = 0; double.TryParse(txt_CC_Fees.Text, out CC_Fees); if (chkCredit_Card_Deposit.Checked) { rArr[0]["CC_Discount_Acct"] = txt_CC_Discount_Acct.Text; rArr[0]["CC_Fees"] = CC_Fees; rArr[0]["Override_Fees"] = chkOverride_Fees.Checked; rArr[0]["Cash_Short_Over_Acct"] = ""; } else { rArr[0]["CC_Discount_Acct"] = ""; rArr[0]["CC_Fees"] = 0; rArr[0]["Override_Fees"] = false; rArr[0]["Cash_Short_Over_Acct"] = txt_Cash_Short_Over_Acct.Text; } rArr[0]["Bank_Account_ID"] = cb_Bank_Account_ID.SelectedValue.ToString(); ClearAll(); } else { ClearAll(); } dr.Close(); sqlcon.Close(); } groupBox1.Enabled = false; btn_New.Visible = true; btnSavenew.Visible = false; SaveChanges(); } }
private void Btnsaveedit_Click(object sender, EventArgs e) { if (dgv.SelectedRows.Count > 0) { if (GeneralFunctions.ValidateString(txt_CurrencyCode.Text, "Please Specify the Currency Code") && GeneralFunctions.ValidateString(txt_CurrencyDescription.Text, "Please Specify the Currency Description") && GeneralFunctions.AccountNumberValidate(txt_GLAccountNumber.Text, out GLAccountNo) && GeneralFunctions.AccountNumberValidate(txt_CurrencyAccountNumber.Text, out CurrencyAccountNumber) && BaseCurrenyValidate()) { DataRow[] rArr = dbAccountingProjectDS.GLCurrency.Select("CurrencyNumber = '" + txt_CurrencyCodeID.Text + "'"); if (rArr.Length != 0) { rArr[0]["CurrencyCode"] = txt_CurrencyCode.Text; rArr[0]["CurrencySign"] = txtCurrencySign.Text; rArr[0]["CurrencyDescription"] = txt_CurrencyDescription.Text; rArr[0]["GLAccountNumber"] = GLAccountNo; rArr[0]["CurrencyPLAccountNumber"] = CurrencyAccountNumber; if (checkBox_Active.Checked) { rArr[0]["Active"] = 1; } else { rArr[0]["Active"] = 0; } if (checkBox_baseCurrency.Checked) { baseCurrencyAvailable = false; rArr[0]["BaseCurrency"] = 1; } else if (!checkBox_baseCurrency.Checked && rArr[0]["BaseCurrency"].ToString() == "True") { baseCurrencyAvailable = false; rArr[0]["BaseCurrency"] = 0; MessageBox.Show("The values in the conversion table has to be changed on change of the base currency\n Please Insert the conversion table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!checkBox_baseCurrency.Checked) { rArr[0]["BaseCurrency"] = 0; } } ClearAll(); dgv.ClearSelection(); GB1.Enabled = false; btnedit.Visible = true; Btnsaveedit.Visible = false; btn_New.Enabled = true; btndelete.Enabled = true; if (save) { save = false; } adapter.Update(dbAccountingProjectDS.GLCurrency); dbAccountingProjectDS.AcceptChanges(); SqlConnection sqlcon2 = new SqlConnection(GeneralFunctions.ConnectionString); sqlcon2.Open(); SqlCommand command2 = new SqlCommand("Select MAX(CurrencyNumber)+1 from GLCurrency ", sqlcon2); int MaxNumber2 = Convert.ToInt32(command2.ExecuteScalar()); txt_CurrencyCodeID.Text = Convert.ToString(MaxNumber2); currentcurrencyNumber = MaxNumber2; sqlcon2.Close(); } } else { MessageBox.Show("Please Select the row that you want to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } dgv.ClearSelection(); SqlConnection sqlcon3 = new SqlConnection(GeneralFunctions.ConnectionString); sqlcon3.Open(); SqlCommand GetCurrencyID = new SqlCommand("Select MAX(CurrencyNumber)+1 From GLCurrency", sqlcon3); if (GetCurrencyID.ExecuteScalar() != DBNull.Value) { GeneralFunctions.CurrencyID = Convert.ToInt32(GetCurrencyID.ExecuteScalar()); } else { GeneralFunctions.CurrencyID = 1; } currentcurrencyNumber = GeneralFunctions.CurrencyID; txt_CurrencyCodeID.Text = currentcurrencyNumber.ToString(); }
private void btnSavenew_Click(object sender, EventArgs e) { if (GeneralFunctions.ValidateString(txt_CurrencyCode.Text, "Please Specify the Currency Code") && GeneralFunctions.ValidateString(txt_CurrencyDescription.Text, "Please Specify the Currency Description") && GeneralFunctions.AccountNumberValidate(txt_GLAccountNumber.Text, out GLAccountNo) && GeneralFunctions.AccountNumberValidate(txt_CurrencyAccountNumber.Text, out CurrencyAccountNumber) && BaseCurrenyValidate()) { sqlcon.Open(); SqlCommand cmdSelect = new SqlCommand("Select CurrencyNumber from GLCurrency where CurrencyNumber = '" + txt_CurrencyCodeID.Text + "'", sqlcon); SqlDataReader dr = cmdSelect.ExecuteReader(); if (!dr.HasRows && !GeneralFunctions.FindRow("CurrencyNumber = '" + txt_CurrencyCodeID.Text + "'", dbAccountingProjectDS.GLCurrency)) { DataRow r = dbAccountingProjectDS.GLCurrency.NewRow(); r["CurrencyNumber"] = currentcurrencyNumber; //GeneralFunctions.CurrencyID++; //currentcurrencyNumber = GeneralFunctions.CurrencyID; r["CurrencyCode"] = txt_CurrencyCode.Text; r["CurrencySign"] = txtCurrencySign.Text; r["CurrencyDescription"] = txt_CurrencyDescription.Text; r["GLAccountNumber"] = GLAccountNo; r["CurrencyPLAccountNumber"] = CurrencyAccountNumber; if (checkBox_baseCurrency.Checked) { baseCurrencyAvailable = true; r["BaseCurrency"] = 1; } else { r["BaseCurrency"] = 0; } if (checkBox_Active.Checked) { r["Active"] = 1; } else { r["Active"] = 0; } dbAccountingProjectDS.GLCurrency.Rows.Add(r); dr.Close(); sqlcon.Close(); adapter.Update(dbAccountingProjectDS.GLCurrency); dbAccountingProjectDS.AcceptChanges(); //CheckBaseCurrency(); save = true; GB1.Enabled = false; btn_New.Visible = true; btnSavenew.Visible = false; ClearAll(); if (save) { save = false; } SqlConnection sqlcon2 = new SqlConnection(GeneralFunctions.ConnectionString); sqlcon2.Open(); SqlCommand command2 = new SqlCommand("Select MAX(CurrencyNumber)+1 from GLCurrency ", sqlcon2); int MaxNumber2 = Convert.ToInt32(command2.ExecuteScalar()); txt_CurrencyCodeID.Text = Convert.ToString(MaxNumber2); currentcurrencyNumber = MaxNumber2; sqlcon2.Close(); } else { if (DialogResult.OK == MessageBox.Show("The given Currency Code already exists \n Preceed if you want to edit", "Alert", MessageBoxButtons.OKCancel)) { DataRow[] rArr = dbAccountingProjectDS.GLCurrency.Select("CurrencyNumber = '" + txt_CurrencyCodeID.Text + "'"); rArr[0]["CurrencyCode"] = txt_CurrencyCode.Text; rArr[0]["CurrencySign"] = txtCurrencySign.Text; rArr[0]["CurrencyDescription"] = txt_CurrencyDescription.Text; rArr[0]["GLAccountNumber"] = GLAccountNo; rArr[0]["CurrencyPLAccountNumber"] = CurrencyAccountNumber; if (checkBox_Active.Checked) { rArr[0]["Active"] = 1; } else { rArr[0]["Active"] = 0; } if (checkBox_baseCurrency.Checked) { baseCurrencyAvailable = true; rArr[0]["BaseCurrency"] = 1; } else if (!checkBox_baseCurrency.Checked && rArr[0]["BaseCurrency"].ToString() == "True") { baseCurrencyAvailable = false; rArr[0]["BaseCurrency"] = 0; MessageBox.Show("The values in the conversion table has to be changed on change of the base currency\n Please Insert the conversion table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } adapter.Update(dbAccountingProjectDS.GLCurrency); dbAccountingProjectDS.AcceptChanges(); //CheckBaseCurrency(); save = true; GB1.Enabled = false; btn_New.Visible = true; btnSavenew.Visible = false; ClearAll(); if (save) { save = false; } SqlConnection sqlcon2 = new SqlConnection(GeneralFunctions.ConnectionString); sqlcon2.Open(); SqlCommand command2 = new SqlCommand("Select MAX(CurrencyNumber)+1 from GLCurrency ", sqlcon2); int MaxNumber2 = Convert.ToInt32(command2.ExecuteScalar()); txt_CurrencyCodeID.Text = Convert.ToString(MaxNumber2); currentcurrencyNumber = MaxNumber2; sqlcon2.Close(); } else { ClearAll(); } GB1.Enabled = false; btn_New.Visible = true; btnSavenew.Visible = false; if (save) { save = false; } dr.Close(); sqlcon.Close(); adapter.Update(dbAccountingProjectDS.GLCurrency); dbAccountingProjectDS.AcceptChanges(); SqlConnection sqlcon3 = new SqlConnection(GeneralFunctions.ConnectionString); sqlcon3.Open(); SqlCommand command3 = new SqlCommand("Select MAX(CurrencyNumber)+1 from GLCurrency ", sqlcon3); int MaxNumber3 = Convert.ToInt32(command3.ExecuteScalar()); txt_CurrencyCodeID.Text = Convert.ToString(MaxNumber3); currentcurrencyNumber = MaxNumber3; sqlcon3.Close(); } } }
//private void btn_SaveChanges_Click(object sender, EventArgs e) { // adapter.Update(dbAccountingProjectDS.GLCurrency); // dbAccountingProjectDS.AcceptChanges(); // //CheckBaseCurrency(); // save = true; //} private void insertToolStripMenuItem_Click(object sender, EventArgs e) { if (GeneralFunctions.ValidateString(txt_CurrencyCode.Text, "Please Specify the Currency Code") && GeneralFunctions.ValidateString(txt_CurrencyDescription.Text, "Please Specify the Currency Description") && GeneralFunctions.AccountNumberValidate(txt_GLAccountNumber.Text, out GLAccountNo) && GeneralFunctions.AccountNumberValidate(txt_CurrencyAccountNumber.Text, out CurrencyAccountNumber) && BaseCurrenyValidate()) { sqlcon.Open(); SqlCommand cmdSelect = new SqlCommand("Select CurrencyNumber from GLCurrency where CurrencyNumber = '" + txt_CurrencyCodeID.Text + "'", sqlcon); SqlDataReader dr = cmdSelect.ExecuteReader(); if (!dr.HasRows && !GeneralFunctions.FindRow("CurrencyNumber = '" + txt_CurrencyCodeID.Text + "'", dbAccountingProjectDS.GLCurrency)) { DataRow r = dbAccountingProjectDS.GLCurrency.NewRow(); r["CurrencyNumber"] = currentcurrencyNumber; //GeneralFunctions.CurrencyID++; //currentcurrencyNumber = GeneralFunctions.CurrencyID; r["CurrencyCode"] = txt_CurrencyCode.Text; r["CurrencyDescription"] = txt_CurrencyDescription.Text; r["GLAccountNumber"] = GLAccountNo; r["CurrencyPLAccountNumber"] = CurrencyAccountNumber; if (checkBox_baseCurrency.Checked) { baseCurrencyAvailable = true; r["BaseCurrency"] = 1; } else { r["BaseCurrency"] = 0; } if (checkBox_Active.Checked) { r["Active"] = 1; } else { r["Active"] = 0; } dbAccountingProjectDS.GLCurrency.Rows.Add(r); dr.Close(); sqlcon.Close(); ClearAll(); if (save) { save = false; } } else { if (DialogResult.OK == MessageBox.Show("The given Currency Code already exists \n Preceed if you want to edit", "Alert", MessageBoxButtons.OKCancel)) { DataRow[] rArr = dbAccountingProjectDS.GLCurrency.Select("CurrencyNumber = '" + txt_CurrencyCodeID.Text + "'"); rArr[0]["CurrencyCode"] = txt_CurrencyCode.Text; rArr[0]["CurrencyDescription"] = txt_CurrencyDescription.Text; rArr[0]["GLAccountNumber"] = GLAccountNo; rArr[0]["CurrencyPLAccountNumber"] = CurrencyAccountNumber; if (checkBox_Active.Checked) { rArr[0]["Active"] = 1; } else { rArr[0]["Active"] = 0; } if (checkBox_baseCurrency.Checked) { baseCurrencyAvailable = true; rArr[0]["BaseCurrency"] = 1; } else if (!checkBox_baseCurrency.Checked && rArr[0]["BaseCurrency"].ToString() == "True") { baseCurrencyAvailable = false; rArr[0]["BaseCurrency"] = 0; MessageBox.Show("The values in the conversion table has to be changed on change of the base currency\n Please Insert the conversion table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } ClearAll(); if (save) { save = false; } } else { ClearAll(); } dr.Close(); sqlcon.Close(); } } }
private void dgv_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex != -1 && e.RowIndex != -1) { if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null) { if (e.ColumnIndex == 1) { if (dgv.Rows[currentRowIndex].Cells["AccountTypeName"].Value.ToString() == "") { string accountNumber; GeneralFunctions.AccountNumberValidate(dgv.Rows[currentRowIndex].Cells["AccountNumber"].Value.ToString(), out accountNumber); DataRow[] rArr = dbAccountingProjectDS.GLAccounts.Select("AccountNumber = '" + accountNumber + "'"); if (rArr.Length != 0) { dgv.Rows[currentRowIndex].Cells["AccountTypeName"].Value = rArr[0]["AccountTypeName"].ToString(); } else { MessageBox.Show("The given account number doesnt exist\n Please Enter another account or Choose an existing account"); } } if (dgv.Rows[currentRowIndex].Cells["AccountTypeName"].Value.ToString().ToLower() != "header" && dgv.Rows[currentRowIndex].Cells["AccountTypeName"].Value.ToString().ToLower() != "statistical" && dgv.Rows[currentRowIndex].Cells["AccountTypeName"].Value.ToString().ToLower() != "") { dgv.Rows[currentRowIndex].Cells["Debit"].Value = value; dgv.Rows[currentRowIndex].Cells["Credit"].Value = value; dgv.Rows[currentRowIndex].Cells["Units"].Value = 0; } if (currentRowIndex == dtTemplateAccounts.Rows.Count - 1) { DataRow r = dtTemplateAccounts.NewRow(); dtTemplateAccounts.Rows.Add(r); } } if (e.ColumnIndex == 5) { CalculateBalance(); if (checkBox_Currency.Checked && cb_Currency.Text != "") { double amount = double.Parse(dgv.Rows[currentRowIndex].Cells["Debit"].Value.ToString()); dgv.Rows[currentRowIndex].Cells["DebitCC"].Value = GeneralFunctions.CalculateForiegnCurrencyValue(amount, double.Parse(txt_CurrencyRate.Text)); } else if (checkBox_Currency.Checked && cb_Currency.Text == "") { dgv.Rows[currentRowIndex].Cells["Debit"].Value = ""; MessageBox.Show("Please Specify the foreign currency", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (e.ColumnIndex == 6) { CalculateBalance(); if (checkBox_Currency.Checked && cb_Currency.Text != "") { double amount = double.Parse(dgv.Rows[currentRowIndex].Cells["Credit"].Value.ToString()); dgv.Rows[currentRowIndex].Cells["CreditCC"].Value = GeneralFunctions.CalculateForiegnCurrencyValue(amount, double.Parse(txt_CurrencyRate.Text)); } else if (checkBox_Currency.Checked && cb_Currency.Text == "") { dgv.Rows[currentRowIndex].Cells["Credit"].Value = ""; MessageBox.Show("Please Specify the foreign currency", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (e.ColumnIndex == 7) { CalculateUnitsCount(); } } } }
private bool TemplateAccountsValidate() { bool valid = true; DataRow[] rArr; DataRow r; string validAccountNumber; double debitvalue = 0, creditvalue = 0, currentvalue; for (int i = 0; i < dtTemplateAccounts.Rows.Count; i++) { r = dtTemplateAccounts.Rows[i]; if (r.RowState != DataRowState.Deleted) { if (r.Equals(dtTemplateAccounts.Rows[dtTemplateAccounts.Rows.Count - 1]) && r["AccountNumber"].ToString() == "" && r["AccountNumber"].ToString() == "") { break; } if (r["AccountNumber"].ToString() != "") { if (!GeneralFunctions.AccountNumberValidate(r["AccountNumber"].ToString(), out validAccountNumber)) { errorProvider1.SetError(dgv, "The given account number doesnt exist"); valid = false; } else { r["AccountNumber"] = validAccountNumber; rArr = dbAccountingProjectDS.GLAccounts.Select("AccountNumber = '" + validAccountNumber + "'"); if (r["AccountName"].ToString() != "") { if (rArr.Length != 0) { if (rArr[0]["AccountName"].ToString() != r["AccountName"].ToString()) { r["AccountName"] = (string)rArr[0]["AccountName"]; } else { errorProvider1.SetError(dgv, ""); } } } else { r["AccountName"] = (string)rArr[0]["AccountName"]; } if (dgv.Rows[i].Cells["AccountTypeName"].Value.ToString().ToLower() == "header" || dgv.Rows[i].Cells["AccountTypeName"].Value.ToString().ToLower() == "statistical") { r["Debit"] = DBNull.Value; r["Credit"] = DBNull.Value; } currentvalue = 0; if (dgv.Rows[i].Cells["Debit"].Value.ToString() != "" && GeneralFunctions.ValidateDouble(dgv.Rows[i].Cells["Debit"].Value.ToString(), "Please Insert a valid debit value", out currentvalue)) { debitvalue += currentvalue; } currentvalue = 0; if (dgv.Rows[i].Cells["Credit"].Value.ToString() != "" && GeneralFunctions.ValidateDouble(dgv.Rows[i].Cells["Credit"].Value.ToString(), "Please Insert a valid credit value", out currentvalue)) { creditvalue += currentvalue; } } } else { errorProvider1.SetError(dgv, "The account number cant be equal to null"); valid = false; } } } if (debitvalue != creditvalue) { MessageBox.Show("The debit accounts arent equal to credit accounts"); valid = false; } return(valid); }