/// <summary> /// Call the totalamount,SlNo,InvalidEntry functions to do the all are the process even if change one value of the grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvContraVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { AccountGroupBll bllAccountGroup = new AccountGroupBll(); if (e.RowIndex != -1 && e.ColumnIndex != -1) { if (dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbBankorCashAccount"].Value.ToString() != "") { if (dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == "") { dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1);//PublicVariables._decCurrencyId; } } TotalAmount(); SlNo(); if (dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbBankorCashAccount"].Value != null) { decimal decLedger = Convert.ToDecimal(dgvContraVoucher.Rows[e.RowIndex].Cells["dgvcmbBankorCashAccount"].Value.ToString()); isBankAcocunt = bllAccountGroup.AccountGroupwithLedgerId(decLedger); if (isBankAcocunt) { dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].ReadOnly = false; dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeNo"].ReadOnly = false; } else { dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].ReadOnly = true; dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeNo"].ReadOnly = true; dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = string.Empty; dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeNo"].Value = string.Empty; } } CheckColumnMissing(e); if (!dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].ReadOnly) { DateValidation objVal = new DateValidation(); TextBox txtDate = new TextBox(); if (dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value != null) { txtDate.Text = dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value.ToString(); bool isDate = objVal.DateValidationFunction(txtDate); if (isDate) { dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = txtDate.Text; } else { dgvContraVoucher.Rows[e.RowIndex].Cells["dgvtxtChequeDate"].Value = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); } } } } } catch (Exception ex) { MessageBox.Show("CV:42" + 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(); PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); AccountGroupBll bllAccountGroup = new AccountGroupBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); InfoPaymentMaster = BllPaymentVoucher.PaymentMasterViewByMasterId(decPaymentmasterId);//view master details isAutomatic = BllVoucherType.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(); List<DataTable> listObj1 = new List<DataTable>(); listObj1 = BllPaymentVoucher.PaymentDetailsViewByMasterId(decPaymentmasterId);//view details details for (int inI = 0; inI < listObj1[0].Rows.Count; inI++) { dgvPaymentVoucher.Rows.Add(); dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(listObj1[0].Rows[inI]["ledgerId"].ToString()); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentMasterId"].Value = listObj1[0].Rows[inI]["paymentMasterId"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value = listObj1[0].Rows[inI]["paymentDetailsId"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = listObj1[0].Rows[inI]["amount"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(listObj1[0].Rows[inI]["exchangeRateId"].ToString()); decimal decDetailsId1 = Convert.ToDecimal(listObj1[0].Rows[inI]["paymentDetailsId"].ToString()); decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decPaymentVoucherTypeId); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); decimal decLedgerId = Convert.ToDecimal(listObj1[0].Rows[inI]["ledgerId"].ToString()); bool IsBankAccount = bllAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(bllAccountLedger.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 = listObj1[0].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(listObj1[0].Rows[inI]["ChequeDate"].ToString()).ToString("dd-MMM-yyyy"); } dgvPaymentVoucher.Rows[inI].HeaderCell.Value = string.Empty; } List<DataTable> listObj = new List<DataTable>(); listObj = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decPaymentVoucherTypeId, strVoucherNo, InfoPaymentMaster.Date); dtblPartyBalance = listObj[0]; } catch (Exception ex) { MessageBox.Show("PV36:" + 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> /// Fill function for updation /// </summary> public void FillFunction() { try { isValueChange = false; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); RecieptVoucherBll bllRecieptVoucherBll = new RecieptVoucherBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); AccountGroupBll BllAccountGroup = new AccountGroupBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); InfoReceiptMaster = bllRecieptVoucherBll.ReceiptMasterViewByMasterId(decRecieptmasterId); isAutomatic = BllVoucherType.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; List<DataTable> listobj = new List<DataTable>(); listobj = bllRecieptVoucherBll.ReceiptDetailsViewByMasterId(decRecieptmasterId); for (int inI = 0; inI < listobj[0].Rows.Count; inI++) { dgvReceiptVoucher.Rows.Add(); dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(listobj[0].Rows[inI]["ledgerId"].ToString()); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptMasterId"].Value = listobj[0].Rows[inI]["receiptMasterId"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptDetailsId"].Value = listobj[0].Rows[inI]["receiptDetailsId"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = listobj[0].Rows[inI]["amount"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(listobj[0].Rows[inI]["exchangeRateId"].ToString()); decimal decDetailsId1 = Convert.ToDecimal(listobj[0].Rows[inI]["receiptDetailsId"].ToString()); decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decReceiptVoucherTypeId); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); decimal decLedgerId = Convert.ToDecimal(listobj[0].Rows[inI]["ledgerId"].ToString()); bool IsBankAccount = BllAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(bllAccountLedger.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 (listobj[0].Rows[inI]["chequeNo"].ToString() != string.Empty) { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = listobj[0].Rows[inI]["chequeNo"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = Convert.ToDateTime(listobj[0].Rows[inI]["chequeDate"].ToString()).ToString("dd-MMM-yyyy"); } dgvReceiptVoucher.Rows[inI].HeaderCell.Value = string.Empty; } List<DataTable> listObj = new List<DataTable>(); listObj = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decReceiptVoucherTypeId, strVoucherNo, InfoReceiptMaster.Date); dtblPartyBalance = listObj[0]; isValueChange = true; } catch (Exception ex) { MessageBox.Show("RV34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }