/// <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; DataTable dtbl = new DataTable(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index) { dtbl = spAccountLedger.AccountLedgerViewAll(); if (dtbl.Rows.Count < 2) { DataRow dr = dtbl.NewRow(); dr[0] = string.Empty; dr[1] = string.Empty; dtbl.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 = dtbl.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 (dtbl.Rows[inJ]["ledgerId"].ToString() == dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()) { dtbl.Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccCashOrBank = (DataGridViewComboBoxCell)dgvPaymentVoucher[dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index, e.RowIndex]; DataRow drow = dtbl.NewRow(); drow["ledgerId"] = "0"; drow["ledgerName"] = string.Empty; dtbl.Rows.InsertAt(drow, 0); dgvccCashOrBank.DataSource = dtbl; 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 (spAccountLedger.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 (spAccountLedger.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> /// 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); } } AccountGroupSP spAccountGroup = new AccountGroupSP(); AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); 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 = spAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(SpAccountLedger.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; SettingsSP spSettings = new SettingsSP(); if (spSettings.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> /// 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) { AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.Columns["dgvbtnAgainst"].Index) { decimal decI = Convert.ToDecimal(SpAccountLedger.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> /// For against button click in the grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvJournalVoucher_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { if (dgvJournalVoucher.CurrentCell.ColumnIndex == dgvJournalVoucher.Columns["dgvbtnAgainst"].Index) { AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); if (dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (dgvJournalVoucher.CurrentRow.Cells["dgvcmbDrOrCr"].Value != null && dgvJournalVoucher.CurrentRow.Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty) { if (SpAccountLedger.AccountGroupIdCheck(dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].FormattedValue.ToString())) { frmPartyBalanceObj = new frmPartyBalance(); frmPartyBalanceObj.MdiParent = formMDI.MDIObj; decimal decLedgerId = Convert.ToDecimal(dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value.ToString()); string strDebitOrCredit = dgvJournalVoucher.CurrentRow.Cells["dgvcmbDrOrCr"].Value.ToString(); if (!isAutomatic) { frmPartyBalanceObj.CallFromJournalVoucher(this, decLedgerId, dtblPartyBalance, strDebitOrCredit, decJournalVoucherTypeId, txtVoucherNo.Text, Convert.ToDateTime(txtDate.Text), arrlstOfDeletedPartyBalanceRow); } else { frmPartyBalanceObj.CallFromJournalVoucher(this, decLedgerId, dtblPartyBalance, strDebitOrCredit, decJournalVoucherTypeId, strVoucherNo, Convert.ToDateTime(txtDate.Text), arrlstOfDeletedPartyBalanceRow); } } } else { Messages.InformationMessage("Select debit or credit"); } } else { Messages.InformationMessage("Select any ledger"); } } } } catch (Exception ex) { MessageBox.Show("JV55:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Grid Fill function while coming from other form to update or delete /// </summary> public void FillFunction() { try { PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo(); PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); LedgerPostingSP SpLedgerPosting = new LedgerPostingSP(); VoucherTypeSP SpVoucherType = new VoucherTypeSP(); AccountGroupSP spAccountGroup = new AccountGroupSP(); AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); InfoPaymentMaster = SpPaymentMaster.PaymentMasterViewByMasterId(decPaymentmasterId);//view master details isAutomatic = SpVoucherType.CheckMethodOfVoucherNumbering(InfoPaymentMaster.VoucherTypeId); if (isAutomatic) { txtVoucherNo.ReadOnly = true; txtVoucherNo.Text = InfoPaymentMaster.InvoiceNo; txtDate.Focus(); } else { txtVoucherNo.ReadOnly = false; txtVoucherNo.Text = InfoPaymentMaster.InvoiceNo; txtVoucherNo.Focus(); } dtpDate.Text = InfoPaymentMaster.Date.ToString(); cmbBankorCash.SelectedValue = InfoPaymentMaster.LedgerId; txtNarration.Text = InfoPaymentMaster.Narration; txtTotal.Text = InfoPaymentMaster.TotalAmount.ToString(); decDailySuffixPrefixId = InfoPaymentMaster.SuffixPrefixId; decPaymentVoucherTypeId = InfoPaymentMaster.VoucherTypeId; strVoucherNo = InfoPaymentMaster.VoucherNo; strInvoiceNo = InfoPaymentMaster.InvoiceNo; DataTable dtbl = new DataTable(); dtbl = SpPaymentDetails.PaymentDetailsViewByMasterId(decPaymentmasterId);//view details details for (int inI = 0; inI < dtbl.Rows.Count; inI++) { dgvPaymentVoucher.Rows.Add(); dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentMasterId"].Value = dtbl.Rows[inI]["paymentMasterId"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value = dtbl.Rows[inI]["paymentDetailsId"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = dtbl.Rows[inI]["amount"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[inI]["exchangeRateId"].ToString()); decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[inI]["paymentDetailsId"].ToString()); decimal decLedgerPostingId = SpLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decPaymentVoucherTypeId); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); decimal decLedgerId = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); bool IsBankAccount = spAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(SpAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].FormattedValue.ToString())); if (decI > 0)//to make amount and currency read only when party is choosen as ledger { dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = true; dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = true; } else { dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = false; dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = false; } dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[inI]["ChequeNo"].ToString(); if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = Convert.ToDateTime(dtbl.Rows[inI]["ChequeDate"].ToString()).ToString("dd-MMM-yyyy"); } } DataTable dtbl1 = new DataTable(); dtbl1 = SpPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decPaymentVoucherTypeId, strVoucherNo, InfoPaymentMaster.Date); dtblPartyBalance = dtbl1; } catch (Exception ex) { MessageBox.Show("PV36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save the service voucher /// </summary> public void SaveFunction() { try { ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo(); ServiceMasterSP spServiceMaster = new ServiceMasterSP(); ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo(); ServiceDetailsSP spServiceDetails = new ServiceDetailsSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); 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(spServiceMaster.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 = spServiceMaster.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 = spServiceDetails.ServiceDetailsAddReturnWithIdentity(infoServiceDetails); } decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(infoServiceMaster.ExchangeRateId); decConvertRate = decAmount * decSelectedCurrencyRate; decCredit = 0; decDebit = decConvertRate; decLedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); LedgerPosting(decLedgerId, decCredit, decDebit, decServiceDetailsId, infoServiceMaster.VoucherNo); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); decimal decI = Convert.ToDecimal(spAccountLedger.AccountGroupIdCheck(cmbCashParty.Text)); if (decI > 0) { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); 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; spPartyBalance.PartyBalanceAdd(infoPartyBalance); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.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); } }
/// <summary> /// On cellvalueChanged of dgvCreditNote /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvJournalVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1 && e.ColumnIndex != -1) { DebitAndCreditTotal(); if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == string.Empty) { dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1); //decExchangeRateId; } } if (dgvJournalVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbAccountLedger") { /*************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--; } } dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; //reset decUpdatingLedgerForPartyremove = 0; inUpdatingRowIndexForPartyRemove = -1; } /*************************************************************************/ //-----------To make amount readonly when party is selected as ledger------------------------------// AccountLedgerSP spAccountLedger = new AccountLedgerSP(); if (spAccountLedger.AccountGroupIdCheck(dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString())) { dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].ReadOnly = true; } else { dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].ReadOnly = false; SettingsSP spSettings = new SettingsSP(); if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes") { dgvcmbCurrency.ReadOnly = false; } else { dgvcmbCurrency.ReadOnly = true; } } //========================================================================================// } if (dgvJournalVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr") { /*************Remove partybalance while changing the Dr/Cr ************/ 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--; } } dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; //reset decUpdatingLedgerForPartyremove = 0; inUpdatingRowIndexForPartyRemove = -1; } /*************************************************************************/ } //-----------------------------------Chequedate validation----------------------------------// DateValidation obj = new DateValidation(); TextBox txtDate1 = new TextBox(); if (dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value != null && dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { txtDate1.Text = dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString(); bool isInvalid = obj.DateValidationFunction(txtDate1); if (!isInvalid) { dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } else { dgvJournalVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = txtDate1.Text; } } //=========================================================================================// //---------------------check column missing---------------------------------// CheckColumnMissing(e); //==========================================================================// } } catch (Exception ex) { MessageBox.Show("JV50:" + 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(); ServiceMasterSP spServiceMaster = new ServiceMasterSP(); ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo(); ServiceDetailsSP spServiceDetails = new ServiceDetailsSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); int inRowCount = dgvServiceVoucher.RowCount; int inValue = 0; decimal decLedgerPostingId1 = 0; decimal decLedgerPostingId2 = 0; DataTable dtblLedgerPostingId = new DataTable(); dtblLedgerPostingId = spServiceMaster.LedgerPostingIdByServiceMaasterId(decServiceMasterId); decLedgerPostingId1 = Convert.ToDecimal(dtblLedgerPostingId.Rows[0]["ledgerPostingId"].ToString()); decLedgerPostingId2 = Convert.ToDecimal(dtblLedgerPostingId.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----------------------------------------// BankReconciliationSP spBankReconciliation = new BankReconciliationSP(); foreach (object obj in strArrOfRemove) { string str = Convert.ToString(obj); spServiceDetails.ServiceDetailsDelete(Convert.ToDecimal(str)); } spServiceMaster.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()); spServiceDetails.ServiceDetailsEdit(infoServiceDetails); } else { infoServiceDetails.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); decServiceDetailsId = spServiceDetails.ServiceDetailsAddReturnWithIdentity(infoServiceDetails); } decSelectedCurrencyRate = spExchangeRate.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); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); decimal decI = Convert.ToDecimal(spAccountLedger.AccountGroupIdCheck(cmbCashParty.Text)); if (decI > 0) { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); 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; spPartyBalance.PartyBalanceEdit(infoPartyBalance); } Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.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> /// Save Function /// </summary> public void SaveFunction() { try { DateValidation Objdatevalidation = new DateValidation(); OtherDateValidationFunction ObjotherdateValidation = new OtherDateValidationFunction(); Objdatevalidation.DateValidationFunction(txtVoucherDate); AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); SettingsSP spSettings = new SettingsSP(); txtVoucherDate.Text = txtVoucherDate.Text.Trim(); cmbvouchertype.Text = cmbvouchertype.Text.Trim(); txtAmount.Text = txtAmount.Text.Trim(); txtBank.Text = txtBank.Text.Trim(); txtcheckdate.Text = txtcheckdate.Text.Trim(); txtcheckNo.Text = txtcheckNo.Text.Trim(); txtNarration.Text = txtNarration.Text.Trim(); DataTable dtblMaster = new DataTable(); PDCClearanceMasterSP sppdcClearance = new PDCClearanceMasterSP(); PDCClearanceMasterInfo infoPdcclearance = new PDCClearanceMasterInfo(); infoPdcclearance.SuffixPrefixId = decSufixprefixPdcpayableID; infoPdcclearance.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString()); infoPdcclearance.VoucherNo = strVoucherNo; infoPdcclearance.InvoiceNo = txtvoucherNo.Text; if (txtVoucherDate.Text != string.Empty) infoPdcclearance.Date = Convert.ToDateTime(txtVoucherDate.Text); else infoPdcclearance.Date = DateTime.Now; infoPdcclearance.LedgerId = decimal.Parse(strledgerId.ToString()); infoPdcclearance.AgainstId = decmasterId; infoPdcclearance.UserId = PublicVariables._decCurrentUserId; infoPdcclearance.VoucherTypeId = decPDCclearanceVoucherTypeId; infoPdcclearance.Status = cmbStatus.Text.ToString(); infoPdcclearance.Type = cmbvouchertype.Text.ToString(); infoPdcclearance.ExtraDate = DateTime.Now; infoPdcclearance.Narration = txtNarration.Text; infoPdcclearance.Extra1 = string.Empty; infoPdcclearance.Extra2 = string.Empty; if (!isInEditMode) { decimal decIdentity = sppdcClearance.PDCClearanceMasterAdd(infoPdcclearance); LedgerPostingAdd(); if (cmbStatus.Text.ToString() == "Bounced") { if (SpAccountLedger.AccountGroupIdCheck(txtAccountLedger.Text.ToString())) { PartyBalanceAddOrEdit(); } } Messages.SavedMessage(); if (cbxPrint.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } ClearFunction(); } else { decimal decIdentity = decPDCClearanceEditId; infoPdcclearance.PDCClearanceMasterId = decPDCClearanceEditId; sppdcClearance.PDCClearanceMasterEdit(infoPdcclearance); SpAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decPDCclearanceVoucherTypeId); LedgerPostingAdd(); SpAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPDCclearanceVoucherTypeId); if (cmbStatus.Text.ToString() == "Bounced") { if (SpAccountLedger.AccountGroupIdCheck(txtAccountLedger.Text.ToString())) { PartyBalanceAddOrEdit(); } } Messages.UpdatedMessage(); if (cbxPrint.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } this.Close(); } } catch (Exception ex) { MessageBox.Show("PC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Against references button click for party balance calculations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAgainstRef_Click(object sender, EventArgs e) { try { AccountLedgerSP spaccountledger = new AccountLedgerSP(); if (spaccountledger.AccountGroupIdCheck(cmbAccountLedger.Text)) { frmPartyBalance frmpartybalance = new frmPartyBalance(); frmpartybalance.MdiParent = formMDI.MDIObj; if (!isAutomatic) { if (txtvoucherNo.Text == string.Empty) { MessageBox.Show("Voucher Number Empty", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); txtvoucherNo.Focus(); } else { frmpartybalance.CallThisFormFromPDCPayable(this, decLedgerIdForPartyBalance, dtblPartyBalance, decPDCpayableVoucherTypeId, txtvoucherNo.Text, DateTime.Parse(txtVoucherDate.Text)); } } else { frmpartybalance.CallThisFormFromPDCPayable(this, decLedgerIdForPartyBalance, dtblPartyBalance, decPDCpayableVoucherTypeId, strVoucherNo, DateTime.Parse(txtVoucherDate.Text)); } } } catch (Exception ex) { MessageBox.Show("PP43:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// datagridview cell beginend edit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvBudget_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { try { inUpdatingRowIndexForPartyRemove = -1; decUpdatingLedgerForPartyremove = 0; DataTable dtbl = new DataTable(); AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); if (cmbType.SelectedIndex == 0) { if (dgvBudget.CurrentCell.ColumnIndex == dgvBudget.Columns["dgvcmbParticular"].Index) { dtbl = SpAccountLedger.AccountLedgerViewAll(); DataRow dr = dtbl.NewRow(); dr[0] = 0; dr[2] = string.Empty; dtbl.Rows.InsertAt(dr, 0); if (dtbl.Rows.Count > 0) { if (dgvBudget.RowCount > 1) { int inGridRowCount = dgvBudget.RowCount; for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (inI != e.RowIndex) { int inTableRowcount = dtbl.Rows.Count; for (int inJ = 0; inJ < inTableRowcount; inJ++) { if (dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString() != string.Empty) { if (dtbl.Rows[inJ]["ledgerId"].ToString() == dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString()) { dtbl.Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvBudget[dgvBudget.Columns["dgvcmbParticular"].Index, e.RowIndex]; dgvccVoucherType.DataSource = dtbl; dgvccVoucherType.ValueMember = "ledgerId"; dgvccVoucherType.DisplayMember = "ledgerName"; } } if (dgvBudget.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbParticular") { if (dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString() != string.Empty) { AccountLedgerSP spAccountLedger = new AccountLedgerSP(); if (spAccountLedger.AccountGroupIdCheck(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].FormattedValue.ToString())) { inUpdatingRowIndexForPartyRemove = e.RowIndex; decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString()); } } } if (dgvBudget.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr") { if (dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString() != string.Empty) { AccountLedgerSP spAccountLedger = new AccountLedgerSP(); if (spAccountLedger.AccountGroupIdCheck(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].FormattedValue.ToString())) { inUpdatingRowIndexForPartyRemove = e.RowIndex; decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString()); } } } } else { if (dgvBudget.CurrentCell.ColumnIndex == dgvBudget.Columns["dgvcmbParticular"].Index) { AccountGroupSP spAccountGroup = new AccountGroupSP(); dtbl = spAccountGroup.GroupNameViewForComboFill(); DataRow dr = dtbl.NewRow(); dr[0] = 0; dtbl.Rows.InsertAt(dr, 0); if (dtbl.Rows.Count > 0) { if (dgvBudget.RowCount > 1) { int inGridRowCount = dgvBudget.RowCount; for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (inI != e.RowIndex) { int inTableRowcount = dtbl.Rows.Count; for (int inJ = 0; inJ < inTableRowcount; inJ++) { if (dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString() != string.Empty) { if (dtbl.Rows[inJ]["accountGroupName"].ToString() == dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString()) { dtbl.Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvBudget[dgvBudget.Columns["dgvcmbParticular"].Index, e.RowIndex]; dgvccVoucherType.DataSource = dtbl; dgvccVoucherType.ValueMember = "accountGroupId"; dgvccVoucherType.DisplayMember = "accountGroupName"; } } if (dgvBudget.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbParticular") { if (dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString() != string.Empty) { AccountLedgerSP spAccountLedger = new AccountLedgerSP(); if (spAccountLedger.AccountGroupIdCheck(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].FormattedValue.ToString())) { inUpdatingRowIndexForPartyRemove = e.RowIndex; decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString()); } } } if (dgvBudget.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr") { if (dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString() != string.Empty) { AccountLedgerSP spAccountLedger = new AccountLedgerSP(); if (spAccountLedger.AccountGroupIdCheck(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].FormattedValue.ToString())) { inUpdatingRowIndexForPartyRemove = e.RowIndex; decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString()); } } } } } catch (Exception ex) { MessageBox.Show("BU37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fill function for updation /// </summary> public void FillFunction() { try { isValueChange = false; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); ReceiptDetailsSP SpReceiptDetails = new ReceiptDetailsSP(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); LedgerPostingSP SpLedgerPosting = new LedgerPostingSP(); VoucherTypeSP SpVoucherType = new VoucherTypeSP(); AccountGroupSP spAccountGroup = new AccountGroupSP(); AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); InfoReceiptMaster = SpReceiptMaster.ReceiptMasterViewByMasterId(decRecieptmasterId); isAutomatic = SpVoucherType.CheckMethodOfVoucherNumbering(InfoReceiptMaster.VoucherTypeId); if (isAutomatic) { txtVoucherNo.ReadOnly = true; txtVoucherNo.Text = InfoReceiptMaster.InvoiceNo; } else { txtVoucherNo.ReadOnly = false; txtVoucherNo.Text = InfoReceiptMaster.VoucherNo; } dtpDate.Value = InfoReceiptMaster.Date; cmbCashOrBank.SelectedValue = InfoReceiptMaster.LedgerId; txtNarration.Text = InfoReceiptMaster.Narration; txtTotal.Text = InfoReceiptMaster.TotalAmount.ToString(); decDailySuffixPrefixId = InfoReceiptMaster.SuffixPrefixId; decReceiptVoucherTypeId = InfoReceiptMaster.VoucherTypeId; strVoucherNo = InfoReceiptMaster.VoucherNo; strInvoiceNo = InfoReceiptMaster.InvoiceNo; DataTable dtbl = new DataTable(); dtbl = SpReceiptDetails.ReceiptDetailsViewByMasterId(decRecieptmasterId); for (int inI = 0; inI < dtbl.Rows.Count; inI++) { dgvReceiptVoucher.Rows.Add(); dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptMasterId"].Value = dtbl.Rows[inI]["receiptMasterId"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptDetailsId"].Value = dtbl.Rows[inI]["receiptDetailsId"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = dtbl.Rows[inI]["amount"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[inI]["exchangeRateId"].ToString()); decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[inI]["receiptDetailsId"].ToString()); decimal decLedgerPostingId = SpLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decReceiptVoucherTypeId); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); decimal decLedgerId = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); bool IsBankAccount = spAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(SpAccountLedger.AccountGroupIdCheck(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].FormattedValue.ToString())); if (decI > 0) { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = true; dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = true; } else { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = false; dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = false; } if (dtbl.Rows[inI]["chequeNo"].ToString() != string.Empty) { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[inI]["chequeNo"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = Convert.ToDateTime(dtbl.Rows[inI]["chequeDate"].ToString()).ToString("dd-MMM-yyyy"); } dgvReceiptVoucher.Rows[inI].HeaderCell.Value = string.Empty; } DataTable dtbl1 = new DataTable(); dtbl1 = SpPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decReceiptVoucherTypeId, strVoucherNo, InfoReceiptMaster.Date); dtblPartyBalance = dtbl1; isValueChange = true; } catch (Exception ex) { MessageBox.Show("RV34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }