private void btnSave_Click(object sender, EventArgs e) { //TODO: 1. Check whether the account name exists or not //2. if exist then do not allow to save with the same account name //3. Prompt user to change the account name as it already exists if (tbxName.Text.Equals(string.Empty)) { MessageBox.Show("Account Name can not be blank!"); tbxName.Focus(); return; } if (accMaster.IsAccountExists(tbxName.Text.Trim())) { MessageBox.Show("Account Name already Exists!"); tbxName.Focus(); return; } objAccount.AccountName = tbxName.Text.Trim(); objAccount.PrintName = tbxPrintname.Text.Trim() == null ? string.Empty : tbxPrintname.Text.Trim(); objAccount.ShortName = tbxAlias.Text == null ? string.Empty : tbxPrintname.Text.Trim(); objAccount.LedgerType = cbxLedgertype.SelectedItem == null ? string.Empty : cbxLedgertype.SelectedItem.ToString(); objAccount.Group = cbxGroupname.SelectedItem == null ? string.Empty : cbxGroupname.SelectedItem.ToString(); AccountGroupModel objGroup = accMaster.GetAccountGroupIdByGroupName(objAccount.Group); objAccount.AccGroupId = objGroup.UnderGroupId; objAccount.MultiCurrency = Convert.ToBoolean(cbxMulticurrency.SelectedItem.ToString() == "Y" ? true : false); objAccount.OPBal = Convert.ToDecimal(tbxOpbal.Text.Trim() == string.Empty ? "0.00" : tbxOpbal.Text.Trim()); if (objAccount.OPBal != 0) { PopupScreens.CostcenterPopup frmCost = new PopupScreens.CostcenterPopup(); frmCost.StartPosition = FormStartPosition.CenterParent; frmCost.ShowDialog(); } objAccount.PrevYearBal = Convert.ToDecimal(tbxPrevyearbal.Text.Trim() == string.Empty ? "0.00" : tbxPrevyearbal.Text.Trim()); objAccount.DrCrOpeningBal = cbxCrDr.SelectedItem.ToString(); objAccount.DrCrPrevBal = cbxPrevCrDr.SelectedItem.ToString(); //objAccount.MaintainBillwiseAccounts = cbxMaintainBalancing.SelectedItem.ToString() == "Y" ? true : false; objAccount.AllocateAmountItems = cbxAllocateAmount.SelectedItem.ToString() == "Y" ? true : false; objAccount.CreditDaysforSale = Convert.ToInt32(tbxCreditdaysforSale.Text == string.Empty ? "0" : tbxCreditdaysforSale.Text.Trim()); objAccount.CreditDaysforPurchase = Convert.ToInt32(tbxCreditdaysforPurc.Text == string.Empty ? "0" : tbxCreditdaysforPurc.Text.Trim()); if (objAccount.MaintainBillwiseAccounts) { PopupScreens.MaintainBillByBillDetails frmbill = new PopupScreens.MaintainBillByBillDetails(); frmbill.StartPosition = FormStartPosition.CenterParent; frmbill.ShowDialog(); } PopupScreens.SalesManDetails frmSM = new PopupScreens.SalesManDetails(); frmSM.StartPosition = FormStartPosition.CenterParent; frmSM.ShowDialog(); //objAccount.CreditLimit = tbxcred.Text; PopupScreens.CreditLimitforAccount frmCredit = new PopupScreens.CreditLimitforAccount(); frmCredit.StartPosition = FormStartPosition.CenterParent; frmCredit.ShowDialog(); PopupScreens.UnclearChequeDeposite frmDeposites = new PopupScreens.UnclearChequeDeposite(); frmDeposites.StartPosition = FormStartPosition.CenterParent; frmDeposites.ShowDialog(); PopupScreens.BudgetsforAccount frmBudget = new PopupScreens.BudgetsforAccount(); frmBudget.StartPosition = FormStartPosition.CenterParent; frmBudget.ShowDialog(); PopupScreens.UnclearChequeIssued frmIssued = new PopupScreens.UnclearChequeIssued(); frmIssued.StartPosition = FormStartPosition.CenterParent; frmIssued.ShowDialog(); PopupScreens.MasterSeriesGroup frmMaster = new PopupScreens.MasterSeriesGroup(); frmMaster.StartPosition = FormStartPosition.CenterParent; frmMaster.ShowDialog(); objAccount.Transport = tbxTransport.Text == null ? string.Empty : tbxTransport.Text; objAccount.Station = tbxStation.Text == null ? string.Empty : tbxStation.Text; objAccount.specifyDefaultSaleType = cbxSpecifydefaultSale.SelectedItem.ToString() == "Y" ? true : false; objAccount.FreezeSaleType = cbxFreezesaletype.SelectedItem.ToString() == "Y" ? true : false; objAccount.DefaultSaleType = cbxDefaultsaletype.SelectedItem.ToString() == "" ? string.Empty : cbxDefaultsaletype.SelectedItem.ToString(); objAccount.SpecifyDefaultPurType = cbxSpecifydefaultPurcType.SelectedItem.ToString().Equals("Y") ? true : false; objAccount.DefaultPurcType = cbxDefaultPurcType.SelectedItem == null ? string.Empty : cbxDefaultPurcType.SelectedItem.ToString(); objAccount.FreezePurcType = cbxFreezePurcType.SelectedItem.ToString() == "Y" ? true : false; objAccount.InterestRatePayable = Convert.ToDecimal(tbxInterestPay.Text == string.Empty ? "0.00" : tbxInterestPay.Text); objAccount.InterestRateReceivable = Convert.ToDecimal(tbxInterestrateReceviable.Text == string.Empty ? "0.00" : tbxInterestrateReceviable.Text.Trim()); objAccount.address = tbxAddress.Text.Trim() == null ? string.Empty : tbxAddress.Text.Trim(); objAccount.address1 = tbxAddress1.Text.Trim() == null ? string.Empty : tbxAddress1.Text.Trim(); objAccount.address2 = tbxAddress2.Text.Trim() == null ? string.Empty : tbxAddress2.Text.Trim(); objAccount.address3 = tbxAddress3.Text.Trim() == null ? string.Empty : tbxAddress3.Text.Trim(); objAccount.ImageData = AccLogo; objAccount.State = cbxState.SelectedItem.ToString(); //objAccount.area = tbxArea.Text.Trim() == null ? string.Empty : tbxArea.Text.Trim(); objAccount.TelephoneNumber = tbxTelno.Text.Trim() == null ? string.Empty : tbxTelno.Text.Trim(); objAccount.Fax = tbxFax.Text == null ? string.Empty : tbxFax.Text.Trim(); objAccount.MobileNumber = tbxMobileno.Text == null ? string.Empty : tbxMobileno.Text.Trim(); objAccount.email = tbxEmail.Text == null ? string.Empty : tbxEmail.Text.Trim(); objAccount.enablemailquery = Convert.ToBoolean(tbxEmailQuery.Text.Trim().Equals("Y") ? true : false); objAccount.enableSMSquery = Convert.ToBoolean(tbxSMSQuery.Text.Trim().Equals("Y") ? true : false); objAccount.contactperson = tbxContactPerson.Text == null ? string.Empty : tbxContactPerson.Text.Trim(); objAccount.ITPanNumber = tbxITpan.Text == null ? string.Empty : tbxITpan.Text.Trim(); objAccount.Ward = tbxWard.Text == null ? string.Empty : tbxWard.Text.Trim(); objAccount.LstNumber = tbxLstno.Text == null ? string.Empty : tbxLstno.Text.Trim(); objAccount.CSTNumber = tbxCstno.Text == null ? string.Empty : tbxCstno.Text.Trim(); objAccount.TIN = tbxTin.Text == null ? string.Empty : tbxTin.Text.Trim(); objAccount.LBTNumber = tbxlbtno == null ? string.Empty : tbxlbtno.Text.Trim(); objAccount.ServiceTaxNumber = tbxServicetax == null ? string.Empty : tbxServicetax.Text.Trim(); objAccount.IECode = tbxIecode.Text == null ? string.Empty : tbxIecode.Text.Trim(); objAccount.DLNO1 = tbxDlno1.Text.Trim() == null ? string.Empty : tbxDlno1.Text.Trim(); objAccount.No1 = tbxNo1.Text.Trim() == null ? string.Empty : tbxNo1.Text.Trim(); objAccount.ChequePrintName = tbxChequePrintName.Text == null ? string.Empty : tbxChequePrintName.Text.Trim(); objAccount.allowwebbasedreporting = tbxWebBasedReporting.Text.Trim() == null ? string.Empty : tbxWebBasedReporting.Text.Trim(); //objAccount.BankAccountNumber= string message = string.Empty; decLedgerId = accMaster.SaveAccount(objAccount); if (decLedgerId > 0) { LedgerPostingAdd(); MessageBox.Show("Saved Successfully!"); ClearControls(); tbxName.Focus(); groupId = 0; } }