/// <summary> /// Function to fill the grid /// </summary> public void Gridfill() { try { List<DataTable> ListObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (cmbAccountGroup.Text.Trim() == string.Empty) { cmbAccountGroup.Text = "All"; } if (txtMobile.Text.Trim() == string.Empty) { txtMobile.Text = "All"; } if (txtPhone.Text.Trim() == string.Empty) { txtPhone.Text = "All"; } if (txtEmail.Text.Trim() == string.Empty) { txtEmail.Text = "All"; } if (txtLedgerName.Text.Trim() == string.Empty) { txtLedgerName.Text = "All"; } if (txtMobile.Text == "All") { txtMobile.Text = string.Empty; } if (txtPhone.Text == "All") { txtPhone.Text = string.Empty; } if (txtEmail.Text == "All") { txtEmail.Text = string.Empty; } if (txtLedgerName.Text == "All") { txtLedgerName.Text = string.Empty; } ListObj = bllAccountLedger.PartyAddressBookSearch(cmbAccountGroup.Text, txtMobile.Text, txtPhone.Text, txtEmail.Text, txtLedgerName.Text); dvgPartyAddressBook.DataSource = ListObj[0]; } catch (Exception ex) { MessageBox.Show("PAB:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill ledgers as TreeMode /// </summary> /// <param name="tn"></param> public void FillTree(TreeNode tn) { try { List<DataTable> ListObj = new List<DataTable>(); AccountGroupBll bllAccountGroup = new AccountGroupBll(); ListObj = bllAccountGroup.AccountGroupViewAllByGroupUnder(Convert.ToDecimal(tn.Name)); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (ListObj[0].Rows.Count > 0) { foreach (DataRow dr in ListObj[0].Rows) { tn.Nodes.Add(dr["accountGroupId"].ToString(), dr["accountGroupName"].ToString()); tn.ExpandAll(); if (tn.LastNode != null) { tn.LastNode.ForeColor = Color.Red; } else { tn.LastNode.ForeColor = Color.Blue; } } foreach (TreeNode tn1 in tn.Nodes) { FillTree(tn1); List<DataTable> ListObjLedger= bllAccountLedger.AccountLedgerViewAllByLedgerName(Convert.ToDecimal(tn1.Name)); foreach (DataRow dr in ListObjLedger[0].Rows) { tn1.Nodes.Add(dr["ledgerId"].ToString(), dr["ledgerName"].ToString()); tn1.ExpandAll(); if (tn1.LastNode != null) { tn1.LastNode.ForeColor = Color.Blue; } else { tn.LastNode.ForeColor = Color.Red; } } } } } catch (Exception ex) { MessageBox.Show("COA:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// function to fill particular combo in datagridview /// </summary> public void AccountLedgerComboFill() { try { List<DataTable> ListObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); ListObj = bllAccountLedger.AccountLedgerViewAllForComboBox(); dgvcmbParticular.DataSource = ListObj[0]; dgvcmbParticular.ValueMember = "ledgerId"; dgvcmbParticular.DisplayMember = "ledgerName"; } catch (Exception ex) { MessageBox.Show("BU2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// BankAccount Combobox fill function /// </summary> public void bankAccountComboFill() { try { List<DataTable> listObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll(); listObj = obj.BankComboFill(); cmbBankAccount.DataSource = listObj[0]; cmbBankAccount.ValueMember = "ledgerId"; cmbBankAccount.DisplayMember = "ledgerName"; cmbBankAccount.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show("BR:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Area combo box /// </summary> public void AreaComboFill() { try { AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); List<DataTable> ListObj = new List<DataTable>(); ListObj = bllAccountLedger.cmbAreafillInCustomer(); DataRow dr = ListObj[0].NewRow(); dr["areaId"] = 0; dr["areaName"] = "All"; ListObj[0].Rows.InsertAt(dr, 0); cmbArea.DataSource = ListObj[0]; cmbArea.ValueMember = "areaId"; cmbArea.DisplayMember = "areaName"; } catch (Exception ex) { MessageBox.Show("Cus1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill AccountLedger combobox /// </summary> public void AccountLedgerComboFill() { try { List<DataTable> ListObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); ListObj = bllAccountLedger.AccountLedgerViewAll(); DataRow dr = ListObj[0].NewRow(); dr[0] = 0; dr[2] = "ALL"; ListObj[0].Rows.InsertAt(dr, 0); cmbAccountLedger.DataSource = ListObj[0]; cmbAccountLedger.ValueMember = "ledgerId"; cmbAccountLedger.DisplayMember = "ledgerName"; cmbAccountLedger.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show("JVREP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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> /// Cell click event for open Party balance form and calculate the settelment /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPaymentVoucher_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.Columns["dgvbtnAgainst"].Index) { decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].FormattedValue.ToString())); if (decI > 0) { frmPartyBalanceObj = new frmPartyBalance(); frmPartyBalanceObj.MdiParent = formMDI.MDIObj; decimal decLedgerId = Convert.ToDecimal(dgvPaymentVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value.ToString()); if (!isAutomatic) { frmPartyBalanceObj.CallFromPaymentVoucher(this, decLedgerId, dtblPartyBalance, decPaymentVoucherTypeId, txtVoucherNo.Text, Convert.ToDateTime(txtDate.Text), arrlstOfDeletedPartyBalanceRow); } else { frmPartyBalanceObj.CallFromPaymentVoucher(this, decLedgerId, dtblPartyBalance, decPaymentVoucherTypeId, strVoucherNo, Convert.ToDateTime(txtDate.Text), arrlstOfDeletedPartyBalanceRow); } } } } } catch (Exception ex) { MessageBox.Show("PV52:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Cell begin edit event of grid, its for removing the item from the list once its added or Selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPaymentVoucher_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { try { inUpdatingRowIndexForPartyRemove = -1; decUpdatingLedgerForPartyremove = 0; List<DataTable> ListObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index) { ListObj = bllAccountLedger.AccountLedgerViewAll(); if (ListObj[0].Rows.Count < 2) { DataRow dr = ListObj[0].NewRow(); dr[0] = string.Empty; dr[1] = string.Empty; ListObj[0].Rows.InsertAt(dr, 0); } if (dgvPaymentVoucher.RowCount > 1) { int inGridRowCount = dgvPaymentVoucher.RowCount; for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (inI != e.RowIndex) { int inTableRowcount = ListObj[0].Rows.Count; for (int inJ = 0; inJ < inTableRowcount; inJ++) { if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (ListObj[0].Rows[inJ]["ledgerId"].ToString() == dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()) { ListObj[0].Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccCashOrBank = (DataGridViewComboBoxCell)dgvPaymentVoucher[dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index, e.RowIndex]; DataRow drow = ListObj[0].NewRow(); drow["ledgerId"] = "0"; drow["ledgerName"] = string.Empty; ListObj[0].Rows.InsertAt(drow, 0); dgvccCashOrBank.DataSource = ListObj[0]; dgvccCashOrBank.ValueMember = "ledgerId"; dgvccCashOrBank.DisplayMember = "ledgerName"; } if (dgvPaymentVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbAccountLedger") { if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (bllAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString())) { inUpdatingRowIndexForPartyRemove = e.RowIndex; decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString()); } } } if (dgvPaymentVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr") { if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (bllAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString())) { inUpdatingRowIndexForPartyRemove = e.RowIndex; decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString()); } } } } catch (Exception ex) { MessageBox.Show("PV54:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save the service voucher /// </summary> public void SaveFunction() { try { ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo(); ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo(); ServicesBll BllService = new ServicesBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); int inRowCount = dgvServiceVoucher.RowCount; int inValue = 0; for (int ini = 0; ini < inRowCount - 1; ini++) { if (dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { inValue++; } } if (inValue > 0) { txtDiscount.Enabled = true; infoServiceMaster.InvoiceNo = txtInvoiceNumber.Text; if (isAutomatic) { infoServiceMaster.VoucherNo = strVoucherNo; } else { infoServiceMaster.VoucherNo = Convert.ToString(BllService.ServiceMasterGetMax(DecServicetVoucherTypeId) + 1); } infoServiceMaster.SuffixPrefixId = decServiceSuffixPrefixId; infoServiceMaster.Date = Convert.ToDateTime(txtVoucherDate.Text); infoServiceMaster.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoServiceMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoServiceMaster.Narration = txtNarration.Text.Trim(); infoServiceMaster.UserId = PublicVariables._decCurrentUserId; infoServiceMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoServiceMaster.ServiceAccount = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); decimal decExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());//spExchangeRate.GetExchangeRateByCurrencyId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoServiceMaster.ExchangeRateId = decExchangeRateId; infoServiceMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); infoServiceMaster.Customer = txtCustomer.Text.Trim(); infoServiceMaster.Discount = Convert.ToDecimal(txtDiscount.Text.Trim()); infoServiceMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); infoServiceMaster.VoucherTypeId = DecServicetVoucherTypeId; infoServiceMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoServiceMaster.ExtraDate = PublicVariables._dtCurrentDate; infoServiceMaster.Extra1 = string.Empty; infoServiceMaster.Extra2 = string.Empty; decServiceMasterId = BllService.ServiceMasterAddReturnWithIdentity(infoServiceMaster); infoServiceDetails.ServiceMasterId = decServiceMasterId; infoServiceDetails.Extra1 = string.Empty; infoServiceDetails.Extra2 = string.Empty; infoServiceDetails.ExtraDate = PublicVariables._dtCurrentDate; for (int i = 0; i < inRowCount - 1; i++) { if (dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString()); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString() != string.Empty) { infoServiceDetails.Measure = dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString(); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { infoServiceDetails.Amount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString()); decAmount += Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value); } decServiceDetailsId = BllService.ServiceDetailsAddReturnWithIdentity(infoServiceDetails); } decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(infoServiceMaster.ExchangeRateId); decConvertRate = decAmount * decSelectedCurrencyRate; decCredit = 0; decDebit = decConvertRate; decLedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); LedgerPosting(decLedgerId, decCredit, decDebit, decServiceDetailsId, infoServiceMaster.VoucherNo); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(cmbCashParty.Text)); if (decI > 0) { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoPartyBalance.VoucherTypeId = DecServicetVoucherTypeId; infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.InvoiceNo = strInvoiceNo; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = decAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoPartyBalance.ExchangeRateId = decExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceAdd(infoPartyBalance); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decServiceMasterId); } else { Print(decServiceMasterId, infoServiceMaster.ExchangeRateId); } } Clear(); } else { Messages.InformationMessage("Can't save Service Voucher without atleast one ledger with complete details"); dgvServiceVoucher.ClearSelection(); dgvServiceVoucher.CurrentCell = dgvServiceVoucher.Rows[0].Cells["dgvcmbParticulars"]; dgvServiceVoucher.Rows[0].Cells["dgvcmbParticulars"].Selected = true; } } catch (Exception ex) { MessageBox.Show("SV 19 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void cmbCashParty_SelectedIndexChanged(object sender, EventArgs e) { try { AccountLedgerInfo InfoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (cmbCashParty.SelectedValue.ToString() != "System.Data.DataRowView" && cmbCashParty.Text != "System.Data.DataRowView") { InfoAccountLedger = bllAccountLedger.accountLedgerviewbyId(Convert.ToDecimal(cmbCashParty.SelectedValue.ToString())); txtCustomer.Text = InfoAccountLedger.LedgerName; txtCreditPeriod.Text = InfoAccountLedger.CreditPeriod.ToString(); } } catch (Exception ex) { MessageBox.Show("SV 63 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Account Ledger Combofill function /// </summary> public void cmbAccountNameFill() { try { isWorkLedgerIndexChange = false; AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); cmbAccountLedger.DataSource = null; List<DataTable> ListObj= bllAccountLedger.AccountLedgerViewAll(); cmbAccountLedger.DataSource = ListObj[0]; cmbAccountLedger.DisplayMember = "ledgerName"; cmbAccountLedger.ValueMember = "ledgerId"; isWorkLedgerIndexChange = true; } catch (Exception ex) { MessageBox.Show("PR2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Ledger posting Save function /// </summary> public void LedgerPosting() { LedgerPostingInfo InfoPosting = new LedgerPostingInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); AccountLedgerBll bllLedger = new AccountLedgerBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); decimal decOldExchange = 0; decimal decNewExchangeRate = 0; decimal decNewExchangeRateId = 0; decimal decSelectedCurrencyRate = 0; decimal decAmount = 0; decimal decConvertRate = 0; string strReferenceType = string.Empty; decimal decOldExchangeId = 0; try { if (!btnAgainRef.Enabled) { infoLedgerPosting.VoucherTypeId = decPDCReceivableVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoLedgerPosting.Date = PublicVariables._dtCurrentDate; infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = Convert.ToDecimal(txtAmount.Text); infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtCheckDate.Text); infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim(); infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } else { infoLedgerPosting.VoucherTypeId = decPDCReceivableVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoLedgerPosting.Date = PublicVariables._dtCurrentDate; infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Debit = 0; foreach (DataRow dr in dtblPartyBalance.Rows) { if (infoLedgerPosting.LedgerId == Convert.ToDecimal(dr["LedgerId"].ToString())) { decOldExchange = Convert.ToDecimal(dr["OldExchangeRate"].ToString()); decNewExchangeRateId = Convert.ToDecimal(dr["CurrencyId"].ToString()); decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(decOldExchange); decAmount = Convert.ToDecimal(dr["Amount"].ToString()); decConvertRate = decConvertRate + (decAmount * decSelectedCurrencyRate); } } infoLedgerPosting.Credit = decConvertRate; infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtCheckDate.Text); infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim(); infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.LedgerId = 12; foreach (DataRow dr in dtblPartyBalance.Rows) { if (Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()) == Convert.ToDecimal(dr["LedgerId"].ToString())) { if (dr["ReferenceType"].ToString() == "Against") { decNewExchangeRateId = Convert.ToDecimal(dr["CurrencyId"].ToString()); decNewExchangeRate = BllExchangeRate.GetExchangeRateByExchangeRateId(decNewExchangeRateId); decOldExchangeId = Convert.ToDecimal(dr["OldExchangeRate"].ToString()); decOldExchange = BllExchangeRate.GetExchangeRateByExchangeRateId(decOldExchangeId); decAmount = Convert.ToDecimal(dr["Amount"].ToString()); decimal decForexAmount = (decAmount * decNewExchangeRate) - (decAmount * decOldExchange); if (decForexAmount >= 0) { infoLedgerPosting.Credit = decForexAmount; infoLedgerPosting.Debit = 0; } else { infoLedgerPosting.Debit = -1 * decForexAmount; infoLedgerPosting.Credit = 0; } BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } } } infoLedgerPosting.LedgerId = 7; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoLedgerPosting.Date = PublicVariables._dtCurrentDate; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Debit = Convert.ToDecimal(txtAmount.Text); infoLedgerPosting.Credit = 0; infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtCheckDate.Text); infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim(); infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } catch (Exception ex) { MessageBox.Show("PR11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Print function for Dotmatrix Printer /// </summary> /// <param name="decMasterId"></param> public void PrintForDotMatrix(decimal decMasterId) { try { DataTable dtblOtherDetails = new DataTable(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); dtblOtherDetails = bllCompanyCreation.CompanyViewForDotMatrix(); DataTable dtblGridDetails = new DataTable(); dtblGridDetails.Columns.Add("SlNo"); dtblGridDetails.Columns.Add("BankAccount"); dtblGridDetails.Columns.Add("ChequeNo"); dtblGridDetails.Columns.Add("ChequeDate"); dtblGridDetails.Columns.Add("Amount"); DataRow dr = dtblGridDetails.NewRow(); dr["SlNo"] = 1; dr["ChequeNo"] = txtcheckNo.Text; dr["BankAccount"] = cmbBank.Text; dr["ChequeDate"] = txtCheckDate.Text; dr["Amount"] = txtAmount.Text; dtblGridDetails.Rows.Add(dr); dtblOtherDetails.Columns.Add("voucherNo"); dtblOtherDetails.Columns.Add("date"); dtblOtherDetails.Columns.Add("ledgerName"); dtblOtherDetails.Columns.Add("Narration"); dtblOtherDetails.Columns.Add("TotalAmount"); dtblOtherDetails.Columns.Add("AmountInWords"); dtblOtherDetails.Columns.Add("Declaration"); dtblOtherDetails.Columns.Add("Heading1"); dtblOtherDetails.Columns.Add("Heading2"); dtblOtherDetails.Columns.Add("Heading3"); dtblOtherDetails.Columns.Add("Heading4"); dtblOtherDetails.Columns.Add("CustomerAddress"); DataRow dRowOther = dtblOtherDetails.Rows[0]; dRowOther["voucherNo"] = txtVoucherNo.Text; dRowOther["date"] = txtVoucherDate.Text; dRowOther["ledgerName"] = cmbAccountLedger.Text; dRowOther["Narration"] = txtNarration.Text; dRowOther["TotalAmount"] = txtAmount.Text; dRowOther["address"] = (dtblOtherDetails.Rows[0]["address"].ToString().Replace("\n", ", ")).Replace("\r", ""); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); infoAccountLedger = bllAccountLedger.AccountLedgerView(Convert.ToDecimal(cmbAccountLedger.SelectedValue)); dRowOther["CustomerAddress"] = (infoAccountLedger.Address.ToString().Replace("\n", ", ")).Replace("\r", ""); string s = new NumToText().AmountWords(Convert.ToDecimal(txtAmount.Text), PublicVariables._decCurrencyId); dRowOther["AmountInWords"] = new NumToText().AmountWords(Convert.ToDecimal(txtAmount.Text), PublicVariables._decCurrencyId); VoucherTypeBll BllVOucherType = new VoucherTypeBll(); DataTable dtblDeclaration = BllVOucherType.DeclarationAndHeadingGetByVoucherTypeId(decPDCReceivableVoucherTypeId); dRowOther["Declaration"] = dtblDeclaration.Rows[0]["Declaration"].ToString(); dRowOther["Heading1"] = dtblDeclaration.Rows[0]["Heading1"].ToString(); dRowOther["Heading2"] = dtblDeclaration.Rows[0]["Heading2"].ToString(); dRowOther["Heading3"] = dtblDeclaration.Rows[0]["Heading3"].ToString(); dRowOther["Heading4"] = dtblDeclaration.Rows[0]["Heading4"].ToString(); int inFormId = BllVOucherType.FormIdGetForPrinterSettings(Convert.ToInt32(dtblDeclaration.Rows[0]["masterId"].ToString())); PrintWorks.DotMatrixPrint.PrintDesign(inFormId, dtblOtherDetails, dtblGridDetails, dtblOtherDetails); } catch (Exception ex) { MessageBox.Show("PR22:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill accountledger combobox /// </summary> /// <param name="cmbAccountLedger"></param> public void AccountLedgerComboFill(ComboBox cmbAccountLedger) { try { cmbAccountLedger.Enabled = true; AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); bllAccountLedger.BillAllocationLedgerFill(cmbAccountLedger, cmbAccountGroup.Text, true); } catch (Exception ex) { MessageBox.Show("BA:03" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// editing the ledger on update /// </summary> public void LedgerEdit() { try { AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); infoAccountLedger.LedgerId = decLedgerId; infoAccountLedger.AccountGroupId = 20; infoAccountLedger.LedgerName = txtTaxName.Text; infoAccountLedger.OpeningBalance = 0; infoAccountLedger.IsDefault = false; infoAccountLedger.CrOrDr = "Cr"; infoAccountLedger.Narration = string.Empty; infoAccountLedger.MailingName = txtTaxName.Text; infoAccountLedger.Address = 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.BankAccountNumber = string.Empty; infoAccountLedger.BranchCode = string.Empty; infoAccountLedger.BranchName = string.Empty; infoAccountLedger.ExtraDate = DateTime.Now; infoAccountLedger.Extra1 = string.Empty; infoAccountLedger.Extra2 = string.Empty; infoAccountLedger.AreaId = 1; bllAccountLedger.AccountLedgerEdit(infoAccountLedger); } catch(Exception ex) { MessageBox.Show("TAX:13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// delete function /// </summary> public void Delete() { try { if (PublicVariables.isMessageDelete) { if (Messages.DeleteMessage()) { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); bool isExist = bllTax.TaxReferenceCheck(decTaxId); if (!isExist) { if ((bllTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1) { Messages.ReferenceExistsMessage(); } else { bllTax.TaxDetailsDeleteWithTaxId(decTaxId); bllAccountLedger.AccountLedgerDelete(decLedgerId); Messages.DeletedMessage(); TaxSearchGridFill(); TaxSelectionGridFill(); Clear(); SearchClear(); } } else { Messages.ReferenceExistsMessage(); } } } else { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); bool isExist = bllTax.TaxReferenceCheck(decTaxId); if (!isExist) { if ((bllTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1) { Messages.ReferenceExistsMessage(); } else { bllTax.TaxDetailsDeleteWithTaxId(decTaxId); Messages.DeletedMessage(); TaxSearchGridFill(); TaxSelectionGridFill(); Clear(); SearchClear(); } } else { Messages.ReferenceExistsMessage(); } } } catch (Exception ex) { MessageBox.Show("TC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Gridview cell value changed , doing basic calculations and checking invalid entries /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPaymentVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1 && e.ColumnIndex != -1) { TotalAmount(); if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == string.Empty) { dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1); } } AccountGroupBll bllAccountGroup = new AccountGroupBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString().Trim() != string.Empty) { if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].ColumnIndex) { /*************Remove partybalance while changing the ledger ************/ if (inUpdatingRowIndexForPartyRemove != -1) { int inTableRowCount = dtblPartyBalance.Rows.Count; for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dtblPartyBalance.Rows.Count == inJ) { break; } if (Convert.ToDecimal(dtblPartyBalance.Rows[inJ]["ledgerId"].ToString()) == decUpdatingLedgerForPartyremove) { if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0") { arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]); } dtblPartyBalance.Rows.RemoveAt(inJ); inJ--; } } dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; decUpdatingLedgerForPartyremove = 0; inUpdatingRowIndexForPartyRemove = -1; } /*************************************************************************/ decimal decLedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString()); bool IsBankAccount = bllAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].FormattedValue.ToString())); if (decI > 0)//to make amount and currency read only when party is choosen as ledger { dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].ReadOnly = true; dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].Value = string.Empty; dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1); dgvPaymentVoucher.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = true; } else { dgvPaymentVoucher.CurrentRow.Cells["dgvtxtAmount"].ReadOnly = false; SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("MultiCurrency") == "Yes") { dgvcmbCurrency.ReadOnly = false; } else { dgvcmbCurrency.ReadOnly = true; } } } } CheckColumnMissing(); DateValidation objVal = new DateValidation(); TextBox txtDate1 = new TextBox(); if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value != null) { txtDate1.Text = dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString(); bool isDate = objVal.DateValidationFunction(txtDate1); if (isDate) { dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = txtDate1.Text; } else { dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } } } } catch (Exception ex) { MessageBox.Show("PV48:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Checking invalid entries for save or update and call its curresponding function /// </summary> public void SaveOrEditFuction() { try { decimal decCalcAmount = 0; decimal decBalance = 0; string strStatus = string.Empty; //ContraMasterSP spContraMaster = new ContraMasterSP(); ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); SettingsBll BllSettings = new SettingsBll(); if (txtVoucherNo.Text == string.Empty) { Messages.InformationMessage("Enter voucher number"); txtVoucherNo.Focus(); } else if (cmbBankAccount.SelectedIndex == -1) { Messages.InformationMessage("Select cash or bank account"); cmbBankAccount.Focus(); } else { if (RemoveIncompleteRowsFromGrid()) { if (dtpContraVoucherDate.Value.ToString() != string.Empty) { strStatus = BllSettings.SettingsStatusCheck("NegativeCashTransaction"); if (rbtnWithdrawal.Checked) { decBalance = bllAccountLedger.CheckLedgerBalance(Convert.ToDecimal(cmbBankAccount.SelectedValue.ToString())); decCalcAmount = decBalance - Convert.ToDecimal(txtTotal.Text); if (decCalcAmount < 0) { if (strStatus == "Warn") { if (MessageBox.Show("Negative balance exists,Do you want to Continue", "Openmiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveOrEdit(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative balance", "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { SaveOrEdit(); } } else { SaveOrEdit(); } } else { bool isNegativeLedger = false; int inRowCount = dgvContraVoucher.RowCount; for (int i = 0; i < inRowCount - 1; i++) { decCalcAmount = 0; decimal decledgerId = 0; if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != "") { decledgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString()); } decBalance = bllAccountLedger.CheckLedgerBalance(decledgerId); decCalcAmount = decBalance - Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString()); if (decCalcAmount < 0) { isNegativeLedger = true; break; } } if (isNegativeLedger) { if (strStatus == "Warn") { if (MessageBox.Show("Negative balance exists,Do you want to Continue", "Openmiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveOrEdit(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative balance", "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { SaveOrEdit(); } } else { SaveOrEdit(); } } } } } } catch (Exception ex) { MessageBox.Show("CV:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// fill the curresponding details for update /// </summary> public void TaxSelectionFillForUpdate() { try { int inRowCount = dgvTaxSelection.RowCount; for (int i = 0; i < inRowCount; i++) { dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = false; } decTaxId = Convert.ToDecimal(dgvTaxSearch.CurrentRow.Cells["dgvtxtTaxIdSearch"].Value.ToString()); TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); infoTax = bllTax.TaxView(decTaxId); txtTaxName.Text = infoTax.TaxName; txtRate.Text = infoTax.Rate.ToString(); cmbApplicableFor.Text = infoTax.ApplicableOn; cmbCalculationMode.Text = infoTax.CalculatingMode; txtNarration.Text = infoTax.Narration; if (infoTax.IsActive.ToString() == "True") { cbxActive.Checked = true; } else { cbxActive.Checked = false; } strTaxName = infoTax.TaxName; decTaxIdForEdit = infoTax.TaxId; btnSave.Text = "Update"; btnDelete.Enabled = true; List<DataTable> ListObj = new List<DataTable>(); ListObj = bllTax.TaxIdForTaxSelectionUpdate(decTaxId); foreach (DataRow dr in ListObj[0].Rows) { string strTaxId = dr["selectedtaxId"].ToString(); for (int i = 0; i < inRowCount; i++) { if (dgvTaxSelection.Rows[i].Cells["dgvtxtTaxId"].Value.ToString() == strTaxId) { dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = true; } } } AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decLedgerId = bllAccountLedger.AccountLedgerIdGetByName(txtTaxName.Text); } catch (Exception ex) { MessageBox.Show("TC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Account ledger combobox index changed, get the id for party balance and chwcking the ledger comes under sundry dr /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbAccountLedger_SelectedIndexChanged(object sender, EventArgs e) { AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); try { strAccNameText = cmbAccountLedger.Text; if (isWorkLedgerIndexChange) { if (cmbAccountLedger.SelectedValue != null && cmbAccountLedger.SelectedValue.ToString() != string.Empty) { if (bllAccountLedger.AccountGroupIdCheckSundryDeptor(cmbAccountLedger.Text)) { btnAgainRef.Enabled = true; txtAmount.ReadOnly = true; decLedgerIdForPartyBalance = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()); } else { btnAgainRef.Enabled = false; txtAmount.ReadOnly = false; } } strOldLedgerId = (cmbAccountLedger.SelectedValue.ToString()); txtAmount.Clear(); } } catch (Exception ex) { MessageBox.Show("PR33:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fill function from coming from register or report or other forms /// </summary> public void FillRegisterOrReport() { //SalesMasterSP spSalesMaster = new SalesMasterSP(); //SalesDetailsSP spSalesDetails = new SalesDetailsSP(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); //SalesBillTaxSP spSalesBillTax = new SalesBillTaxSP(); SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); try { isFromEditMode = true; btnSave.Text = "Update"; btnDelete.Enabled = true; txtInvoiceNo.ReadOnly = true; List<DataTable> listMaster = BllSalesInvoice.SalesInvoiceSalesMasterViewBySalesMasterId(decSalesInvoiceIdToEdit); DecSalesInvoiceVoucherTypeId = Convert.ToDecimal(listMaster[0].Rows[0]["voucherTypeId"].ToString()); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); infoVoucherType = BllVoucherType.VoucherTypeView(DecSalesInvoiceVoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; txtDate.Text = listMaster[0].Rows[0]["date"].ToString(); dtpDate.Value = DateTime.Parse(txtDate.Text); CurrencyComboFill(); txtInvoiceNo.Text = listMaster[0].Rows[0]["invoiceNo"].ToString(); txtCreditPeriod.Text = listMaster[0].Rows[0]["creditPeriod"].ToString(); strVoucherNo = listMaster[0].Rows[0]["voucherNo"].ToString(); decSalseInvoiceSuffixPrefixId = Convert.ToDecimal(listMaster[0].Rows[0]["suffixPrefixId"].ToString()); isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(DecSalesInvoiceVoucherTypeId); cmbCashOrParty.SelectedValue = listMaster[0].Rows[0]["ledgerId"].ToString(); cmbSalesAccount.SelectedValue = listMaster[0].Rows[0]["salesAccount"].ToString(); cmbSalesMan.SelectedValue = listMaster[0].Rows[0]["employeeId"].ToString(); txtCustomer.Text = listMaster[0].Rows[0]["customerName"].ToString(); txtTransportCompany.Text = listMaster[0].Rows[0]["transportationCompany"].ToString(); txtVehicleNo.Text = listMaster[0].Rows[0]["lrNo"].ToString(); txtNarration.Text = listMaster[0].Rows[0]["narration"].ToString(); cmbCurrency.SelectedValue = Convert.ToDecimal(listMaster[0].Rows[0]["exchangeRateId"].ToString()); txtTotalAmount.Text = listMaster[0].Rows[0]["totalAmount"].ToString(); lblTaxTotalAmount.Text = listMaster[0].Rows[0]["taxAmount"].ToString(); cmbPricingLevel.SelectedValue = Convert.ToDecimal(listMaster[0].Rows[0]["pricingLevelId"].ToString()); if (listMaster[0].Rows[0]["quotationMasterId"].ToString() != "0") { cmbSalesMode.Text = "Against Quotation"; againstOrderComboFill(); cmbSalesModeOrderNo.SelectedValue = listMaster[0].Rows[0]["quotationMasterId"].ToString(); lblSalesModeOrderNo.Text = "Quotation No"; cmbCurrency.Enabled = false; cmbPricingLevel.Enabled = false; } else if (listMaster[0].Rows[0]["orderMasterId"].ToString() != "0") { cmbSalesMode.Text = "Against SalesOrder"; againstOrderComboFill(); cmbSalesModeOrderNo.SelectedValue = listMaster[0].Rows[0]["orderMasterId"].ToString(); lblSalesModeOrderNo.Text = "Order No"; cmbCurrency.Enabled = false; cmbPricingLevel.Enabled = false; } else if (listMaster[0].Rows[0]["deliveryNoteMasterId"].ToString() != "0") { cmbSalesMode.Text = "Against Delivery Note"; againstOrderComboFill(); cmbSalesModeOrderNo.SelectedValue = listMaster[0].Rows[0]["deliveryNoteMasterId"].ToString(); lblSalesModeOrderNo.Text = "Delivery Note No"; cmbCurrency.Enabled = false; cmbPricingLevel.Enabled = false; } else { cmbSalesMode.SelectedText = "NA"; } if (txtInvoiceNo.Enabled) { txtDate.Focus(); } else { txtInvoiceNo.Focus(); } //DataTable dtblDetails = new DataTable(); List<DataTable> listObj = new List<DataTable>(); listObj = BllSalesInvoice.SalesInvoiceSalesDetailsViewBySalesMasterId(decSalesInvoiceIdToEdit); dgvSalesInvoiceTaxComboFill(); dgvSalesInvoice.Rows.Clear(); for (int i = 0; i < listObj[0].Rows.Count; i++) { dgvSalesInvoice.Rows.Add(); IsSetGridValueChange = false; dgvSalesInvoice.Rows[i].HeaderCell.Value = string.Empty; dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value = Convert.ToDecimal(listObj[0].Rows[i]["salesDetailsId"].ToString()); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSlno"].Value = listObj[0].Rows[i]["slNo"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBarcode"].Value = listObj[0].Rows[i]["barcode"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductCode"].Value = listObj[0].Rows[i]["productCode"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductName"].Value = listObj[0].Rows[i]["productName"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value = listObj[0].Rows[i]["productId"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBrand"].Value = listObj[0].Rows[i]["brandName"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value = listObj[0].Rows[i]["qty"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = listObj[0].Rows[i]["purchaseRate"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceAmount"].Value = listObj[0].Rows[i]["amount"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceGrossValue"].Value = listObj[0].Rows[i]["grossAmount"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(listObj[0].Rows[i]["unitId"].ToString()); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceRate"].Value = listObj[0].Rows[i]["rate"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceGodown"].Value = Convert.ToDecimal(listObj[0].Rows[i]["godownId"].ToString()); RackComboFill(Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()), i, dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceRack"].ColumnIndex); dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceRack"].Value = Convert.ToDecimal(listObj[0].Rows[i]["rackId"].ToString()); if (listObj[0].Rows[i]["batchId"] != null && listObj[0].Rows[i]["batchId"].ToString() != string.Empty) { dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(listObj[0].Rows[i]["batchId"].ToString()); } else { dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value = string.Empty; } dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceMrp"].Value = listObj[0].Rows[i]["mrp"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesRate"].Value = listObj[0].Rows[i]["salesRate"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value = listObj[0].Rows[i]["discount"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceNetAmount"].Value = listObj[0].Rows[i]["netAmount"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceTaxName"].Value = Convert.ToDecimal(listObj[0].Rows[i]["taxId"].ToString()); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceTaxAmount"].Value = listObj[0].Rows[i]["taxAmount"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = listObj[0].Rows[i]["unitConversionId"].ToString(); lblTotalQuantitydisplay.Text = listObj[0].Rows[i]["qty"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSISalesOrderDetailsId"].Value = Convert.ToDecimal(listObj[0].Rows[i]["orderDetailsId"].ToString()); // here get fill the grid colum for the editing prps dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value = listObj[0].Rows[i]["deliveryNoteDetailsId"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value = listObj[0].Rows[i]["quotationDetailsId"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = Convert.ToDecimal(listObj[0].Rows[i]["voucherTypeRefNo"].ToString()); // here get fill the grid colum for the editing prps dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = listObj[0].Rows[i]["voucherRefNo"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = listObj[0].Rows[i]["invoiceRefNo"].ToString(); dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBarcode"].ReadOnly = true; dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductCode"].ReadOnly = true; dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductName"].ReadOnly = true; dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBrand"].ReadOnly = true; dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].ReadOnly = true; if (cmbSalesMode.SelectedIndex != 0) { strVoucherNoTostockPost = dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString(); strInvoiceNoTostockPost = dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString(); decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value); } GrossValueCalculation(i); DiscountCalculation(i, dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDiscountAmount"].ColumnIndex); taxAndGridTotalAmountCalculation(i); decCurrentRate = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); decCurrentConversionRate = Convert.ToDecimal(listObj[0].Rows[i]["conversionRate"].ToString()); UnitConversionCalc(i); if (cmbSalesModeOrderNo.Visible == true) { dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true; } } List<DataTable> listAdditionalCost = new List<DataTable>(); listAdditionalCost = BllSalesInvoice.SalesInvoiceAdditionalCostViewByVoucherNoUnderVoucherType(DecSalesInvoiceVoucherTypeId, strVoucherNo); for (int i = 0; i < listAdditionalCost[0].Rows.Count; i++) { dgvSalesInvoiceLedger.Rows.Add(); dgvSalesInvoiceLedger.Rows[i].Cells["dgvtxtAdditionalCostId"].Value = listAdditionalCost[0].Rows[i]["additionalCostId"].ToString(); dgvSalesInvoiceLedger.Rows[i].Cells["dgvCmbAdditionalCostledgerName"].Value = Convert.ToDecimal(listAdditionalCost[0].Rows[i]["ledgerId"].ToString()); dgvSalesInvoiceLedger.Rows[i].Cells["dgvtxtAdditionalCoastledgerAmount"].Value = listAdditionalCost[0].Rows[i]["amount"].ToString(); List<DataTable> ListObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); ListObj = bllAccountLedger.AccountLedgerViewForAdditionalCost(); DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvSalesInvoiceLedger[dgvSalesInvoiceLedger.Columns["dgvCmbAdditionalCostledgerName"].Index, i]; dgvccVoucherType.DataSource = ListObj[0]; dgvccVoucherType.ValueMember = "ledgerId"; dgvccVoucherType.DisplayMember = "ledgerName"; } List<DataTable> ListDrOrCr = BllSalesInvoice.salesinvoiceAdditionalCostCheckdrOrCrforSiEdit(DecSalesInvoiceVoucherTypeId, strVoucherNo); if (ListDrOrCr[0].Rows.Count > 0) { if (Convert.ToDecimal(ListDrOrCr[0].Rows[0]["credit"].ToString()) != 0) { cmbCashOrbank.SelectedValue = Convert.ToDecimal(ListDrOrCr[0].Rows[0]["ledgerId"].ToString()); cmbCashOrbank.Visible = true; lblcashOrBank.Visible = true; cmbDrorCr.SelectedIndex = 0; decBankOrCashIdForEdit = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); } else { cmbDrorCr.SelectedIndex = 1; } } taxGridFill(); List<DataTable> listTax = new List<DataTable>(); listTax = BllSalesInvoice.SalesInvoiceSalesBillTaxViewAllBySalesMasterId(decSalesInvoiceIdToEdit); foreach (DataGridViewRow dgvrowTax in dgvSalesInvoiceTax.Rows) { for (int ini = 0; ini < listTax[0].Rows.Count; ini++) { if (dgvrowTax.Cells["dgvtxtTtaxId"].Value != null && dgvrowTax.Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty) { decimal decId = Convert.ToDecimal(listTax[0].Rows[ini]["taxId"].ToString()); if (dgvrowTax.Cells["dgvtxtTtaxId"].Value.ToString() == decId.ToString()) { dgvrowTax.Cells["dgvtxtTtaxAmount"].Value = listTax[0].Rows[ini]["taxAmount"].ToString(); break; } else { dgvrowTax.Cells["dgvtxtTtaxAmount"].Value = "0.00"; } } } } LedgerGridTotalAmountCalculation(); SiGridTotalAmountCalculation(); txtGrandTotal.Text = listMaster[0].Rows[0]["grandTotal"].ToString(); txtBillDiscount.Text = listMaster[0].Rows[0]["billDiscount"].ToString(); bool isPartyBalanceRef = false; AccountLedgerBll bllAccountLedger1 = new AccountLedgerBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); isPartyBalanceRef = bllAccountLedger1.PartyBalanceAgainstReferenceCheck(strVoucherNo, DecSalesInvoiceVoucherTypeId); if (isPartyBalanceRef) { cmbCashOrParty.Enabled = false; } else { cmbCashOrParty.Enabled = true; } } catch (Exception ex) { MessageBox.Show("SI: 77" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Delete Function, Checking the References and Check other forms are opend or not /// </summary> /// <param name="decPDCReceivableMasterId"></param> public void DeleteFunction(decimal decPDCReceivableMasterId) { try { PDCRecivebleBll BllPdcRecieveble = new PDCRecivebleBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (!BllPartyBalance.PartyBalanceCheckReference(decPDCReceivableVoucherTypeId, strVoucherNo)) { BllPdcRecieveble.PDCReceivableDeleteMaster(decPDCReceivableMasterId, decPDCReceivableVoucherTypeId, strVoucherNo); Messages.DeletedMessage(); } else { Messages.InformationMessage("Reference exist. Cannot delete"); txtVoucherDate.Focus(); } if (PDCReceivableRegisterObj != null) { this.Close(); PDCReceivableRegisterObj.Show(); } else if (PDCReceivableReportObj != null) { this.Close(); PDCReceivableReportObj.Show(); } else if (frmLedgerDetailsObj != null) { this.Close(); frmLedgerDetailsObj.Show(); } else if (objVoucherSearch != null) { this.Close(); objVoucherSearch.GridFill(); } else { ClearFunction(); } if (frmDayBookObj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("PR20:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public int PartyBalanceCheckWithReference() { int inF1 = 0; decimal decPartyBalanceAmount = 0; decimal decGrandTotal = 0; try { bool isRef = false; AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); isRef = bllAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, DecSalesInvoiceVoucherTypeId); if (isRef) { decPartyBalanceAmount = BllPartyBalance.PartyBalanceAmountViewForSalesInvoice(strVoucherNo, DecSalesInvoiceVoucherTypeId, "Against"); decGrandTotal = Convert.ToDecimal(txtGrandTotal.Text); if (decGrandTotal >= decPartyBalanceAmount) { inF1 = 1; } else { inF1 = 0; Messages.InformationMessage("There is a Receipt voucher against this invoice so grand total should not be less than " + decPartyBalanceAmount); } } else { inF1 = 1; } } catch (Exception ex) { MessageBox.Show("SI36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return inF1; }
/// <summary> /// Adding columns to print /// </summary> /// <param name="decDeliveryNoteMasterId"></param> public void PrintForDotMatrix(decimal decDeliveryNoteMasterId) { try { DataTable dtblOtherDetails = new DataTable(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); dtblOtherDetails = bllCompanyCreation.CompanyViewForDotMatrix(); //-------------Grid Details-------------------\\ DataTable dtblGridDetails = new DataTable(); dtblGridDetails.Columns.Add("SlNo"); dtblGridDetails.Columns.Add("BarCode"); dtblGridDetails.Columns.Add("ProductCode"); dtblGridDetails.Columns.Add("ProductName"); dtblGridDetails.Columns.Add("Qty"); dtblGridDetails.Columns.Add("Unit"); dtblGridDetails.Columns.Add("Godown"); dtblGridDetails.Columns.Add("Rack"); dtblGridDetails.Columns.Add("Batch"); dtblGridDetails.Columns.Add("Rate"); dtblGridDetails.Columns.Add("Amount"); int inRowCount = 0; foreach (DataGridViewRow dRow in dgvProduct.Rows) { if (!dRow.IsNewRow) { DataRow dr = dtblGridDetails.NewRow(); dr["SlNo"] = ++inRowCount; if (dRow.Cells["dgvtxtBarcode"].Value != null) { dr["BarCode"] = dRow.Cells["dgvtxtBarcode"].Value.ToString(); } if (dRow.Cells["dgvtxtProductCode"].Value != null) { dr["ProductCode"] = dRow.Cells["dgvtxtProductCode"].Value.ToString(); } if (dRow.Cells["dgvtxtProductName"].Value != null) { dr["ProductName"] = dRow.Cells["dgvtxtProductName"].Value.ToString(); } if (dRow.Cells["dgvtxtQty"].Value != null) { dr["Qty"] = dRow.Cells["dgvtxtQty"].Value.ToString(); } if (dRow.Cells["dgvcmbUnit"].Value != null) { dr["Unit"] = dRow.Cells["dgvcmbUnit"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbGodown"].Value != null) { dr["Godown"] = dRow.Cells["dgvcmbGodown"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbRack"].Value != null) { dr["Rack"] = dRow.Cells["dgvcmbRack"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbBatch"].Value != null) { dr["Batch"] = dRow.Cells["dgvcmbBatch"].FormattedValue.ToString(); } if (dRow.Cells["dgvtxtRate"].Value != null) { dr["Rate"] = dRow.Cells["dgvtxtRate"].Value.ToString(); } if (dRow.Cells["dgvtxtAmount"].Value != null) { dr["Amount"] = dRow.Cells["dgvtxtAmount"].Value.ToString(); } dtblGridDetails.Rows.Add(dr); } } //-------------Other Details-------------------\\ dtblOtherDetails.Columns.Add("voucherNo"); dtblOtherDetails.Columns.Add("date"); dtblOtherDetails.Columns.Add("ledgerName"); dtblOtherDetails.Columns.Add("Narration"); dtblOtherDetails.Columns.Add("Currency"); dtblOtherDetails.Columns.Add("TotalAmount"); dtblOtherDetails.Columns.Add("DeliveryMode"); dtblOtherDetails.Columns.Add("PricingLevel"); dtblOtherDetails.Columns.Add("Type"); dtblOtherDetails.Columns.Add("SalesMan"); dtblOtherDetails.Columns.Add("CustomerAddress"); dtblOtherDetails.Columns.Add("CustomerTIN"); dtblOtherDetails.Columns.Add("CustomerCST"); dtblOtherDetails.Columns.Add("AmountInWords"); dtblOtherDetails.Columns.Add("Declaration"); dtblOtherDetails.Columns.Add("Heading1"); dtblOtherDetails.Columns.Add("Heading2"); dtblOtherDetails.Columns.Add("Heading3"); dtblOtherDetails.Columns.Add("Heading4"); DataRow dRowOther = dtblOtherDetails.Rows[0]; dRowOther["voucherNo"] = txtDeliveryNoteNo.Text; dRowOther["date"] = txtDate.Text; dRowOther["ledgerName"] = cmbCashOrParty.Text; dRowOther["Narration"] = txtNarration.Text; dRowOther["Currency"] = cmbCurrency.Text; dRowOther["TotalAmount"] = txtTotalAmnt.Text; dRowOther["DeliveryMode"] = cmbDeliveryMode.Text; dRowOther["PricingLevel"] = cmbPricingLevel.Text; dRowOther["Type"] = cmbType.Text; dRowOther["SalesMan"] = cmbSalesMan.Text; dRowOther["address"] = (dtblOtherDetails.Rows[0]["address"].ToString().Replace("\n", ", ")).Replace("\r", ""); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); infoAccountLedger = bllAccountLedger.AccountLedgerView(Convert.ToDecimal(cmbCashOrParty.SelectedValue)); dRowOther["CustomerAddress"] = (infoAccountLedger.Address.ToString().Replace("\n", ", ")).Replace("\r", ""); dRowOther["CustomerTIN"] = infoAccountLedger.Tin; dRowOther["CustomerCST"] = infoAccountLedger.Cst; dRowOther["AmountInWords"] = new NumToText().AmountWords(Convert.ToDecimal(txtTotalAmnt.Text), PublicVariables._decCurrencyId); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); DataTable dtblDeclaration = BllVoucherType.DeclarationAndHeadingGetByVoucherTypeId(decDeliveryNoteVoucherTypeId); dRowOther["Declaration"] = dtblDeclaration.Rows[0]["Declaration"].ToString(); dRowOther["Heading1"] = dtblDeclaration.Rows[0]["Heading1"].ToString(); dRowOther["Heading2"] = dtblDeclaration.Rows[0]["Heading2"].ToString(); dRowOther["Heading3"] = dtblDeclaration.Rows[0]["Heading3"].ToString(); dRowOther["Heading4"] = dtblDeclaration.Rows[0]["Heading4"].ToString(); int inFormId = BllVoucherType.FormIdGetForPrinterSettings(Convert.ToInt32(dtblDeclaration.Rows[0]["masterId"].ToString())); PrintWorks.DotMatrixPrint.PrintDesign(inFormId, dtblOtherDetails, dtblGridDetails, dtblOtherDetails); } catch (Exception ex) { MessageBox.Show("DN41:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Print function for dotmatrix printer /// </summary> /// <param name="decSalesMasterId"></param> public void PrintForDotMatrix(decimal decSalesMasterId) { try { DataTable dtblOtherDetails = new DataTable(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); dtblOtherDetails = bllCompanyCreation.CompanyViewForDotMatrix(); DataTable dtblGridDetails = new DataTable(); dtblGridDetails.Columns.Add("SlNo"); dtblGridDetails.Columns.Add("BarCode"); dtblGridDetails.Columns.Add("ProductCode"); dtblGridDetails.Columns.Add("ProductName"); dtblGridDetails.Columns.Add("Qty"); dtblGridDetails.Columns.Add("Unit"); dtblGridDetails.Columns.Add("Godown"); dtblGridDetails.Columns.Add("Brand"); dtblGridDetails.Columns.Add("Tax"); dtblGridDetails.Columns.Add("TaxAmount"); dtblGridDetails.Columns.Add("NetAmount"); dtblGridDetails.Columns.Add("DiscountAmount"); dtblGridDetails.Columns.Add("DiscountPercentage"); dtblGridDetails.Columns.Add("SalesRate"); dtblGridDetails.Columns.Add("PurchaseRate"); dtblGridDetails.Columns.Add("MRP"); dtblGridDetails.Columns.Add("Rack"); dtblGridDetails.Columns.Add("Batch"); dtblGridDetails.Columns.Add("Rate"); dtblGridDetails.Columns.Add("Amount"); int inRowCount = 0; foreach (DataGridViewRow dRow in dgvSalesInvoice.Rows) { if (!dRow.IsNewRow) { DataRow dr = dtblGridDetails.NewRow(); dr["SlNo"] = ++inRowCount; if (dRow.Cells["dgvtxtSalesInvoiceBarcode"].Value != null) { dr["BarCode"] = dRow.Cells["dgvtxtSalesInvoiceBarcode"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceProductCode"].Value != null) { dr["ProductCode"] = dRow.Cells["dgvtxtSalesInvoiceProductCode"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceProductName"].Value != null) { dr["ProductName"] = dRow.Cells["dgvtxtSalesInvoiceProductName"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceQty"].Value != null) { dr["Qty"] = dRow.Cells["dgvtxtSalesInvoiceQty"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoicembUnitName"].Value != null) { dr["Unit"] = dRow.Cells["dgvtxtSalesInvoicembUnitName"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbSalesInvoiceGodown"].Value != null) { dr["Godown"] = dRow.Cells["dgvcmbSalesInvoiceGodown"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbSalesInvoiceRack"].Value != null) { dr["Rack"] = dRow.Cells["dgvcmbSalesInvoiceRack"].FormattedValue.ToString(); } if (dRow.Cells["dgvcmbSalesInvoiceBatch"].Value != null) { dr["Batch"] = dRow.Cells["dgvcmbSalesInvoiceBatch"].FormattedValue.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceRate"].Value != null) { dr["Rate"] = dRow.Cells["dgvtxtSalesInvoiceRate"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceAmount"].Value != null) { dr["Amount"] = dRow.Cells["dgvtxtSalesInvoiceAmount"].Value.ToString(); } if (dRow.Cells["dgvcmbSalesInvoiceTaxName"].Value != null) { dr["Tax"] = dRow.Cells["dgvcmbSalesInvoiceTaxName"].FormattedValue.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceBrand"].Value != null) { dr["Brand"] = dRow.Cells["dgvtxtSalesInvoiceBrand"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceTaxAmount"].Value != null) { dr["TaxAmount"] = dRow.Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceNetAmount"].Value != null) { dr["NetAmount"] = dRow.Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceDiscountAmount"].Value != null) { dr["DiscountAmount"] = dRow.Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value != null) { dr["DiscountPercentage"] = dRow.Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceSalesRate"].Value != null) { dr["SalesRate"] = dRow.Cells["dgvtxtSalesInvoiceSalesRate"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoicePurchaseRate"].Value != null) { dr["PurchaseRate"] = dRow.Cells["dgvtxtSalesInvoicePurchaseRate"].Value.ToString(); } if (dRow.Cells["dgvtxtSalesInvoiceMrp"].Value != null) { dr["MRP"] = dRow.Cells["dgvtxtSalesInvoiceMrp"].Value.ToString(); } dtblGridDetails.Rows.Add(dr); } } dtblOtherDetails.Columns.Add("voucherNo"); dtblOtherDetails.Columns.Add("date"); dtblOtherDetails.Columns.Add("ledgerName"); dtblOtherDetails.Columns.Add("SalesMode"); dtblOtherDetails.Columns.Add("SalesAccount"); dtblOtherDetails.Columns.Add("SalesMan"); dtblOtherDetails.Columns.Add("CreditPeriod"); dtblOtherDetails.Columns.Add("VoucherType"); dtblOtherDetails.Columns.Add("PricingLevel"); dtblOtherDetails.Columns.Add("Customer"); dtblOtherDetails.Columns.Add("CustomerAddress"); dtblOtherDetails.Columns.Add("CustomerTIN"); dtblOtherDetails.Columns.Add("CustomerCST"); dtblOtherDetails.Columns.Add("Narration"); dtblOtherDetails.Columns.Add("Currency"); dtblOtherDetails.Columns.Add("TotalAmount"); dtblOtherDetails.Columns.Add("BillDiscount"); dtblOtherDetails.Columns.Add("GrandTotal"); dtblOtherDetails.Columns.Add("AmountInWords"); dtblOtherDetails.Columns.Add("Declaration"); dtblOtherDetails.Columns.Add("Heading1"); dtblOtherDetails.Columns.Add("Heading2"); dtblOtherDetails.Columns.Add("Heading3"); dtblOtherDetails.Columns.Add("Heading4"); DataRow dRowOther = dtblOtherDetails.Rows[0]; dRowOther["voucherNo"] = txtInvoiceNo.Text; dRowOther["date"] = txtDate.Text; dRowOther["ledgerName"] = cmbCashOrParty.Text; dRowOther["Narration"] = txtNarration.Text; dRowOther["Currency"] = cmbCurrency.Text; dRowOther["SalesMode"] = cmbSalesMode.Text; dRowOther["SalesAccount"] = cmbSalesAccount.Text; dRowOther["SalesMan"] = cmbSalesMan.SelectedText; dRowOther["CreditPeriod"] = (txtCreditPeriod.Text) + " Days"; dRowOther["PricingLevel"] = cmbPricingLevel.Text; dRowOther["Customer"] = txtCustomer.Text; dRowOther["BillDiscount"] = txtBillDiscount.Text; dRowOther["GrandTotal"] = txtGrandTotal.Text; dRowOther["TotalAmount"] = txtTotalAmount.Text; dRowOther["VoucherType"] = cmbVoucherType.Text; dRowOther["address"] = (dtblOtherDetails.Rows[0]["address"].ToString().Replace("\n", ", ")).Replace("\r", ""); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); infoAccountLedger = bllAccountLedger.AccountLedgerView(Convert.ToDecimal(cmbCashOrParty.SelectedValue)); dRowOther["CustomerAddress"] = (infoAccountLedger.Address.ToString().Replace("\n", ", ")).Replace("\r", ""); dRowOther["CustomerTIN"] = infoAccountLedger.Tin; dRowOther["CustomerCST"] = infoAccountLedger.Cst; dRowOther["AmountInWords"] = new NumToText().AmountWords(Convert.ToDecimal(txtGrandTotal.Text), PublicVariables._decCurrencyId); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); DataTable dtblDeclaration = BllVoucherType.DeclarationAndHeadingGetByVoucherTypeId(DecSalesInvoiceVoucherTypeId); dRowOther["Declaration"] = dtblDeclaration.Rows[0]["Declaration"].ToString(); dRowOther["Heading1"] = dtblDeclaration.Rows[0]["Heading1"].ToString(); dRowOther["Heading2"] = dtblDeclaration.Rows[0]["Heading2"].ToString(); dRowOther["Heading3"] = dtblDeclaration.Rows[0]["Heading3"].ToString(); dRowOther["Heading4"] = dtblDeclaration.Rows[0]["Heading4"].ToString(); int inFormId = BllVoucherType.FormIdGetForPrinterSettings(Convert.ToInt32(dtblDeclaration.Rows[0]["masterId"].ToString())); PrintWorks.DotMatrixPrint.PrintDesign(inFormId, dtblOtherDetails, dtblGridDetails, dtblOtherDetails); } catch (Exception ex) { MessageBox.Show("SI: 74" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the service account combo box /// </summary> public void ServiceAcoountComboFill() { try { List<DataTable> ListObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); ListObj = bllAccountLedger.AccountLedgerSearchForServiceAccountUnderIncome(); cmbServiceAC.DataSource = ListObj[0]; cmbServiceAC.DisplayMember = "ledgerName"; cmbServiceAC.ValueMember = "ledgerId"; cmbServiceAC.SelectedText = "Service Account"; } catch (Exception ex) { MessageBox.Show("SV 07 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Cash or party combo changed, call the order combofill function and fill the basic functions /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbCashOrParty_SelectedIndexChanged(object sender, EventArgs e) { try { GetSalesDetailsIdToDelete(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); AccountLedgerInfo InfoAccountLedger = new AccountLedgerInfo(); if (isFromEditMode == false) { if (cmbCashOrParty.Text != string.Empty) { if (cmbCashOrParty.SelectedValue.ToString() != "System.Data.DataRowView" && cmbCashOrParty.Text != "System.Data.DataRowView") { InfoAccountLedger = bllAccountLedger.accountLedgerviewbyId(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString())); txtCustomer.Text = InfoAccountLedger.LedgerName; cmbPricingLevel.SelectedValue = InfoAccountLedger.PricinglevelId == 0 ? 1 : InfoAccountLedger.PricinglevelId; if (InfoAccountLedger.PricinglevelId == 0) { cmbPricingLevel.SelectedIndex = 0; } txtCreditPeriod.Text = InfoAccountLedger.CreditPeriod.ToString(); } } } else if (cmbSalesMode.SelectedIndex != 0) { Clear(); } againstOrderComboFill(); } catch (Exception ex) { MessageBox.Show("SI: 98" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit the service voucher /// </summary> /// <param name="decServiceMasterId"></param> public void EditFunction(decimal decServiceMasterId) { try { ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo(); ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo(); ServicesBll BllService = new ServicesBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); int inRowCount = dgvServiceVoucher.RowCount; int inValue = 0; decimal decLedgerPostingId1 = 0; decimal decLedgerPostingId2 = 0; List<DataTable> listObjLedgerPostingId = new List<DataTable>(); listObjLedgerPostingId = BllService.LedgerPostingIdByServiceMaasterId(decServiceMasterId); decLedgerPostingId1 = Convert.ToDecimal(listObjLedgerPostingId[0].Rows[0]["ledgerPostingId"].ToString()); decLedgerPostingId2 = Convert.ToDecimal(listObjLedgerPostingId[0].Rows[1]["ledgerPostingId"].ToString()); for (int ini = 0; ini < inRowCount - 1; ini++) { if (dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { inValue++; } } if (inValue > 0) { infoServiceMaster.ServiceMasterId = decServiceMasterId; infoServiceMaster.SuffixPrefixId = decServiceSuffixPrefixId; infoServiceMaster.Date = Convert.ToDateTime(txtVoucherDate.Text); infoServiceMaster.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoServiceMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoServiceMaster.Narration = txtNarration.Text.Trim(); infoServiceMaster.UserId = PublicVariables._decCurrentUserId; infoServiceMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoServiceMaster.ServiceAccount = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); decimal decExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());//spExchangeRate.GetExchangeRateByCurrencyId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoServiceMaster.ExchangeRateId = decExchangeRateId; infoServiceMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); infoServiceMaster.Customer = txtCustomer.Text.Trim(); infoServiceMaster.Discount = Convert.ToDecimal(txtDiscount.Text); infoServiceMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); infoServiceMaster.VoucherTypeId = DecServicetVoucherTypeId; infoServiceMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoServiceMaster.ExtraDate = PublicVariables._dtCurrentDate; infoServiceMaster.Extra1 = string.Empty; infoServiceMaster.Extra2 = string.Empty; //------------------deleting removed rows----------------------------------------// BankReconciliationBll BllBankReconciliation = new BankReconciliationBll(); foreach (object obj in strArrOfRemove) { string str = Convert.ToString(obj); BllService.ServiceDetailsDelete(Convert.ToDecimal(str)); } BllService.ServiceMasterEdit(infoServiceMaster); infoServiceDetails.ServiceMasterId = decServiceMasterId; infoServiceDetails.Extra1 = string.Empty; infoServiceDetails.Extra2 = string.Empty; infoServiceDetails.ExtraDate = PublicVariables._dtCurrentDate; for (int i = 0; i < inRowCount - 1; i++) { if (dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString()); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString() != string.Empty) { infoServiceDetails.Measure = dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString(); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { infoServiceDetails.Amount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString()); if (dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceDetailsId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString()); infoServiceDetails.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); BllService.ServiceDetailsEdit(infoServiceDetails); } else { infoServiceDetails.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); decServiceDetailsId = BllService.ServiceDetailsAddReturnWithIdentity(infoServiceDetails); } decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value); decConvertRate += decAmount * decSelectedCurrencyRate; } } decCredit = 0; decDebit = decConvertRate; decLedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); LedgerPostingEdit(decLedgerPostingId1, decLedgerId, decCredit, decDebit); decCredit = decConvertRate; decDebit = 0; decLedgerId = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); LedgerPostingEdit(decLedgerPostingId2, decLedgerId, decCredit, decDebit); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(cmbCashParty.Text)); if (decI > 0) { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); infoPartyBalance.PartyBalanceId = decPartyBalanceId; infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoPartyBalance.VoucherTypeId = DecServicetVoucherTypeId; infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.InvoiceNo = strInvoiceNo; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = decAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoPartyBalance.ExchangeRateId = decExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceEdit(infoPartyBalance); } Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decServiceMasterId); } else { Print(decServiceMasterId, infoServiceMaster.ExchangeRateId); } } this.Close(); if (frmServiceVoucherRegisterObj != null) { frmServiceVoucherRegisterObj.Show(); frmServiceVoucherRegisterObj.GridFill(); } else if (frmServiceReportObj != null) { frmServiceReportObj.Show(); frmServiceReportObj.GridFill(); } } else { Messages.InformationMessage("Can't save Service Voucher without atleast one ledger with complete details"); } } catch (Exception ex) { MessageBox.Show("SV 24 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Ledger grid cell begin edit for Combo box item fill and remove from the list once it has selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSalesInvoiceLedger_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { try { if (dgvSalesInvoice.RowCount > 1) { List<DataTable> ListObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (dgvSalesInvoiceLedger.CurrentCell.ColumnIndex == dgvSalesInvoiceLedger.Columns["dgvCmbAdditionalCostledgerName"].Index) { ListObj = bllAccountLedger.AccountLedgerViewForAdditionalCost(); if (ListObj[0].Rows.Count > 0) { if (dgvSalesInvoiceLedger.RowCount > 1) { int inGridRowCount = dgvSalesInvoiceLedger.RowCount; for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (inI != e.RowIndex) { int inTableRowcount = ListObj[0].Rows.Count; for (int inJ = 0; inJ < inTableRowcount; inJ++) { if (dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { if (ListObj[0].Rows[inJ]["ledgerId"].ToString() == dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()) { ListObj[0].Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvSalesInvoiceLedger[dgvSalesInvoiceLedger.Columns["dgvCmbAdditionalCostledgerName"].Index, e.RowIndex]; dgvccVoucherType.DataSource = ListObj[0]; dgvccVoucherType.ValueMember = "ledgerId"; dgvccVoucherType.DisplayMember = "ledgerName"; } } } } catch (Exception ex) { MessageBox.Show("SI: 106" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }