/// <summary> /// checking checking existance entries for save or edit function /// </summary> public void SaveOrEditMessage() { try { AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); string strTaxNameForLedger = string.Empty; strTaxNameForLedger = txtTaxName.Text; if (btnSave.Text == "Save") { if (!bllAccountLedger.AccountLedgerCheckExistence(strTaxNameForLedger, 0)) { if (PublicVariables.isMessageAdd) { if (Messages.SaveMessage()) { SaveFunction(); TaxSelectionGridFill(); TaxSearchGridFill(); } } else { SaveFunction(); TaxSelectionGridFill(); TaxSearchGridFill(); } } else { Messages.InformationMessage("Cannot save. Ledger already exists"); } } else { if (!bllAccountLedger.AccountLedgerCheckExistence(strTaxNameForLedger, decLedgerId)) { if (PublicVariables.isMessageEdit) { if (Messages.UpdateMessage()) { EditFunction(); TaxSelectionGridFill(); TaxSearchGridFill(); } } else { EditFunction(); TaxSelectionGridFill(); TaxSearchGridFill(); } } else { Messages.InformationMessage("Cannot save. Ledger already exists"); } } } catch (Exception ex) { MessageBox.Show("TC6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> ///Function to edit account ledger /// </summary> public void EditFunction() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger.LedgerName = txtLedgerName.Text.Trim(); infoAccountLedger.AccountGroupId = Convert.ToDecimal(cmbGroup.SelectedValue.ToString()); infoAccountLedger.OpeningBalance = Convert.ToDecimal(((txtOpeningBalance.Text == "") ? "0" : txtOpeningBalance.Text.Trim())); infoAccountLedger.CrOrDr = cmbOpeningBalanceCrOrDr.Text.Trim(); infoAccountLedger.Narration = txtNarration.Text.Trim(); if (isBankAccount) { infoAccountLedger.BankAccountNumber = txtAcNo.Text.Trim(); infoAccountLedger.BranchName = txtBranchName.Text.Trim(); infoAccountLedger.BranchCode = txtBranchCode.Text.Trim(); } else { if (isSundryDebtorOrCreditor) { infoAccountLedger.BankAccountNumber = txtAccountNo.Text; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.BranchCode = string.Empty; } else { infoAccountLedger.BankAccountNumber = string.Empty; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.BranchCode = string.Empty; } } if (!isDefault) { infoAccountLedger.IsDefault = false; } else { infoAccountLedger.IsDefault = true; } if (isSundryDebtorOrCreditor) { infoAccountLedger.MailingName = txtMailingName.Text.Trim(); infoAccountLedger.Address = txtAddress.Text.Trim(); infoAccountLedger.Phone = txtPhone.Text.Trim(); infoAccountLedger.Mobile = txtMobile.Text.Trim(); infoAccountLedger.Email = txtEmail.Text.Trim(); infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim()); infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.Trim()); if (cmbPricingLevel.SelectedIndex <= 0) { infoAccountLedger.PricinglevelId = 1; } else { infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } if (cmbBillByBill.Text == "Yes") { infoAccountLedger.BillByBill = true; } else { infoAccountLedger.BillByBill = false; } infoAccountLedger.Tin = txtTin.Text.Trim(); infoAccountLedger.Cst = txtCst.Text.Trim(); infoAccountLedger.Pan = txtPan.Text.Trim(); if (cmbArea.SelectedIndex <= 0) { infoAccountLedger.AreaId = 1; } else { infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); } if (cmbRoute.SelectedIndex < 0) { infoAccountLedger.RouteId = 1; } else { infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString()); } infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; } else { infoAccountLedger.MailingName = string.Empty; infoAccountLedger.Address = string.Empty; infoAccountLedger.State = string.Empty; infoAccountLedger.Phone = string.Empty; infoAccountLedger.Mobile = string.Empty; infoAccountLedger.Email = string.Empty; infoAccountLedger.CreditPeriod = 0; infoAccountLedger.CreditLimit = 0; infoAccountLedger.PricinglevelId = 1; infoAccountLedger.BillByBill = false; infoAccountLedger.Tin = string.Empty; infoAccountLedger.Cst = string.Empty; infoAccountLedger.Pan = string.Empty; infoAccountLedger.RouteId = 1; infoAccountLedger.AreaId = 1; infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate; } infoAccountLedger.LedgerId = decAccountLedgerId; if (bllAccountLedger.AccountLedgerCheckExistence(txtLedgerName.Text.Trim(), decLedger) == false) { bllAccountLedger.AccountLedgerEdit(infoAccountLedger); LedgerPostingEdit(); if (cmbBillByBill.Text == "Yes" && isSundryDebtorOrCreditor) { PartyBalanceEdit(); } else { bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(decAccountLedgerId.ToString(), 1); } Messages.UpdatedMessage(); Clear(); } else { Messages.InformationMessage("Ledgername already exist"); txtLedgerName.Focus(); } } catch (Exception ex) { MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// check if data present in database /// </summary> /// <returns></returns> public bool CheckAlreadyExist() { bool isOk = true; try { AccountLedgerBll bllAccountledger = new AccountLedgerBll(); int inCompleteRow = 0; int inCurrentindex = 0; string strMessage = "Row"; foreach (DataGridViewRow dgvRow in dgvMultipleAccountLedger.Rows) { if (dgvRow.Cells["dgvtxtLedgerName"].Value != null) { string LedgerName = dgvRow.Cells["dgvtxtLedgerName"].Value.ToString(); if (bllAccountledger.AccountLedgerCheckExistence(LedgerName, 0) == true) { isOk = false; if (inCompleteRow == 0) { strMessage = strMessage + Convert.ToString(dgvRow.Index + 1); inCurrentindex = dgvRow.Index; inCompleteRow++; } else { strMessage = strMessage + ", " + Convert.ToString(dgvRow.Index + 1); } } } } if (!isOk) { strMessage = strMessage + " contains already exisitng ledgers. Do you want to continue?"; if (MessageBox.Show(strMessage, "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { isOk = true; for (int inK = 0; inK < dgvMultipleAccountLedger.Rows.Count; inK++) { if (dgvMultipleAccountLedger.Rows[inK].Cells["dgvtxtLedgerName"].Value != null) { string strLedgerName = dgvMultipleAccountLedger.Rows[inK].Cells["dgvtxtLedgerName"].Value.ToString().Trim(); if (bllAccountledger.AccountLedgerCheckExistence(strLedgerName, 0) == true) { if (!dgvMultipleAccountLedger.Rows[inK].IsNewRow) { dgvMultipleAccountLedger.Rows.RemoveAt(inK); inK--; } } } } } else { dgvMultipleAccountLedger.Rows[inCurrentindex].Cells["dgvtxtLedgerName"].Selected = true; dgvMultipleAccountLedger.CurrentCell = dgvMultipleAccountLedger.Rows[inCurrentindex].Cells["dgvtxtLedgerName"]; dgvMultipleAccountLedger.Focus(); } } } catch (Exception ex) { MessageBox.Show("MAL5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isOk; }
/// <summary> /// Function to save account ledger /// </summary> public void SaveFunction() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger.LedgerName = txtLedgerName.Text.Trim(); infoAccountLedger.AccountGroupId = Convert.ToDecimal(cmbGroup.SelectedValue.ToString()); decOpeningBalance = Convert.ToDecimal(((txtOpeningBalance.Text == "") ? "0" : txtOpeningBalance.Text.Trim())); infoAccountLedger.OpeningBalance = decOpeningBalance; infoAccountLedger.CrOrDr = cmbOpeningBalanceCrOrDr.Text.Trim(); infoAccountLedger.Narration = txtNarration.Text.Trim(); infoAccountLedger.IsDefault = false; if (isBankAccount) { infoAccountLedger.BankAccountNumber = txtAcNo.Text.Trim(); infoAccountLedger.BranchName = txtBranchName.Text.Trim(); infoAccountLedger.BranchCode = txtBranchCode.Text.Trim(); } else { if (isSundryDebtorOrCreditor) { infoAccountLedger.BankAccountNumber = txtAccountNo.Text; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.BranchCode = string.Empty; } else { infoAccountLedger.BankAccountNumber = string.Empty; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.BranchCode = string.Empty; } } if (isSundryDebtorOrCreditor) { infoAccountLedger.MailingName = txtMailingName.Text.Trim(); infoAccountLedger.BankAccountNumber = txtAccountNo.Text.Trim(); infoAccountLedger.Address = txtAddress.Text.Trim(); infoAccountLedger.Phone = txtPhone.Text.Trim(); infoAccountLedger.Mobile = txtMobile.Text.Trim(); infoAccountLedger.Email = txtEmail.Text.Trim(); infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim()); infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.Trim()); if (cmbPricingLevel.SelectedIndex <= 0) { infoAccountLedger.PricinglevelId = 1; } else { infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } if (cmbBillByBill.Text == "Yes") { infoAccountLedger.BillByBill = true; } else { infoAccountLedger.BillByBill = false; } infoAccountLedger.Tin = txtTin.Text.Trim(); infoAccountLedger.Cst = txtCst.Text.Trim(); infoAccountLedger.Pan = txtPan.Text.Trim(); if (cmbArea.SelectedIndex <= 0) { infoAccountLedger.AreaId = 1; } else { infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); } if (cmbRoute.SelectedIndex < 0) { infoAccountLedger.RouteId = 1; } else { infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString()); } infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate; } else { infoAccountLedger.MailingName = string.Empty; infoAccountLedger.BankAccountNumber = string.Empty; infoAccountLedger.Address = string.Empty; infoAccountLedger.State = string.Empty; infoAccountLedger.Phone = string.Empty; infoAccountLedger.Mobile = string.Empty; infoAccountLedger.Email = string.Empty; infoAccountLedger.CreditPeriod = 0; infoAccountLedger.CreditLimit = 0; infoAccountLedger.PricinglevelId = 0; infoAccountLedger.BillByBill = false; infoAccountLedger.Tin = string.Empty; infoAccountLedger.Cst = string.Empty; infoAccountLedger.Pan = string.Empty; infoAccountLedger.RouteId = 1; infoAccountLedger.AreaId = 1; infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate; } if (bllAccountLedger.AccountLedgerCheckExistence(txtLedgerName.Text.Trim().ToString(), 0) == false) { decLedgerId = bllAccountLedger.AccountLedgerAddWithIdentity(infoAccountLedger); if (decOpeningBalance > 0) { LedgerPostingAdd(); if (cmbBillByBill.Text == "Yes" && isSundryDebtorOrCreditor) { PartyBalanceAdd(); } } Messages.SavedMessage(); Clear(); decIdForOtherForms = decLedgerId; if (frmRejectionInObj != null) { this.Close(); } if (frmMaterialReceptObj != null) { this.Close(); } if (frmPurchaseInvoiceObj != null) { this.Close(); } if (frmContraVoucherObj != null) { this.Close(); } if (frmPaymentVoucherObj != null) { this.Close(); } if (frmReceiptVoucherObj != null) { this.Close(); } if (frmDailysalaryvoucherobj != null) { this.Close(); } /*------------------For ReceiptVoucher--------------------*/ if (frmReceiptVoucherObj != null) { this.Close(); } if (frmPurchaseOrderObj != null) { this.Close(); } /*----------For journal voucher------------*/ if (frmJournalVoucherObj != null) { this.Close(); } /*----------For Debitnote voucher-----------*/ if (frmDebitNoteObj != null) { this.Close(); } /*----------For Creditnote voucher-----------*/ if (frmCreditNoteObj != null) { this.Close(); } if (frmSalesReturnObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmSalesInvoiceObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmSalesQuotationObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmSalesOrderObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } /*---------- For Pdcpayable voucher-----------*/ if (frmPdcpayableObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmPdcpayableObj2 != null) { if (decIdForOtherForms != 0) { this.Close(); } } /*---------- Coded For PdcReceivable voucher-----------*/ if (frmpdcreceivableObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } if (frmpdcreceivableObj2 != null) { if (decIdForOtherForms != 0) { this.Close(); } } /*.................end.......................*/ if (frmPOSObj != null) { if (decIdForOtherForms != 0) { this.Close(); } } } else { Messages.InformationMessage("Ledger name already exist"); txtLedgerName.Focus(); } } catch (Exception ex) { MessageBox.Show("AL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }