/// <summary> /// Fill the corresponding details of party and calculations on cell value changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPartyBalance_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); if (e.RowIndex != -1 && e.ColumnIndex != -1) { if (dgvPartyBalance.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value == null || dgvPartyBalance.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value.ToString() == string.Empty) { dgvPartyBalance.Rows[e.RowIndex].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(1);//decExchangeRateId; } if (dgvPartyBalance.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtAmount" || dgvPartyBalance.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbCurrency") { TotalAmount(); } //---------------------check column missing---------------------------------// CheckColumnMissing(e); //==========================================================================// if (dgvPartyBalance.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbReference") { if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value != null)//&& dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() != string.Empty) { //to fill combo without filling the already selected value if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() == "Against") { dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].ReadOnly = false; if (frmJournalVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = strDebitOrCredit; } else if (frmPaymentVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr"; } else if (frmReceiptVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr"; } else if (frmPdcpayableObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr"; } else if (frmPdcReceivableObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr"; } } else if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() == "New") { dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].ReadOnly = true; dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value = string.Empty; dgvPartyBalance.CurrentRow.Cells["dgvtxtVoucherNo"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = false; if (frmJournalVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = strDebitOrCredit; } else if (frmPaymentVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr"; } else if (frmReceiptVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr"; } else if (frmPdcpayableObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr"; } else if (frmPdcReceivableObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr"; } } // else if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() == "OnAccount") { dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].ReadOnly = true; dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value = string.Empty; dgvPartyBalance.CurrentRow.Cells["dgvtxtVoucherNo"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = false; if (frmJournalVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = strDebitOrCredit; } else if (frmPaymentVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr"; } else if (frmReceiptVoucherObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr"; } else if (frmPdcpayableObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Dr"; } else if (frmPdcReceivableObj != null) { dgvPartyBalance.CurrentRow.Cells["dgvtxtCrDr"].Value = "Cr"; } } } } else if (dgvPartyBalance.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbVoucherType") { if (dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value != null && dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value.ToString().Trim() != string.Empty) { ExchangeRateSP spExchangeRate = new ExchangeRateSP(); ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo(); string str = dgvPartyBalance.CurrentRow.Cells["dgvcmbVoucherType"].Value.ToString(); string[] words; words = str.Split('_'); DataTable dtbl = new DataTable(); dtbl = SpPartyBalance.PartyBalanceComboViewByLedgerId(decLedgerId, strDebitOrCredit, decVoucherTypeId, strVoucherNo); for (int inD = 0; inD < dtbl.Rows.Count; inD++) { if (dgvPartyBalance.Rows[e.RowIndex].Cells["dgvcmbVoucherType"].Value.ToString() == dtbl.Rows[inD]["value"].ToString()) { dgvPartyBalance.CurrentRow.Cells["dgvtxtVoucherNo"].Value = dtbl.Rows[inD]["voucherNo"].ToString(); dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value = Math.Round(Convert.ToDecimal(dtbl.Rows[inD]["balance"].ToString()), PublicVariables._inNoOfDecimalPlaces); dgvPartyBalance.CurrentRow.Cells["dgvtxtOldExchangeRateId"].Value = dtbl.Rows[inD]["exchangeRateId"].ToString(); if (Convert.ToDecimal(dtbl.Rows[inD]["exchangeRateId"].ToString()) != 1m) { infoExchangeRate = spExchangeRate.ExchangeRateView(Convert.ToDecimal(dtbl.Rows[inD]["exchangeRateId"].ToString())); decimal decCurrentExchangeRateId = spExchangeRate.GetExchangeRateId(infoExchangeRate.CurrencyId, dtmVoucherDate); if (decCurrentExchangeRateId == 0) { CurrencySP spCurrency = new CurrencySP(); CurrencyInfo infoCurrency = new CurrencyInfo(); infoCurrency = spCurrency.CurrencyView(infoExchangeRate.CurrencyId); dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].Value = decCurrentExchangeRateId; Messages.InformationMessage("Set ExchangeRate for "+infoCurrency.CurrencyName); } else { dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].Value = decCurrentExchangeRateId; } } else { dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].Value = 1m; } dgvPartyBalance.CurrentRow.Cells["dgvtxtInvoiceNo"].Value = dtbl.Rows[inD]["invoiceNo"].ToString(); } } dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].ReadOnly = true; } //to make voucherno,pendingamount,invoiceno,currency as null when vouchertype is selected as empty else { dgvPartyBalance.CurrentRow.Cells["dgvtxtVoucherNo"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvtxtInvoiceNo"].Value = null; dgvPartyBalance.CurrentRow.Cells["dgvcmbCurrency"].Value = null; SettingsSP spSettings = new SettingsSP(); if (spSettings.SettingsStatusCheck("MultiCurrency") == "Yes") { dgvcmbCurrency.ReadOnly = false; } else { dgvcmbCurrency.ReadOnly = true; } } } } } catch (Exception ex) { MessageBox.Show("PB:16" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// To change the currency from currency popup /// </summary> /// <param name="frmCurrencyDetails"></param> /// <param name="decId"></param> public void CallFromCurrenCyDetails(frmCurrencyDetails frmCurrencyDetails, decimal decId) //PopUp { ExchangeRateSP spExchangeRate = new ExchangeRateSP(); try { frmCurrencyObj.Close(); CurrencyComboFill(); decId = spExchangeRate.GetExchangeRateId(decId, Convert.ToDateTime(txtDate.Text)); dgvJournalVoucher.CurrentRow.Cells["dgvcmbCurrency"].Value = decId; dgvJournalVoucher.Focus(); } catch (Exception ex) { MessageBox.Show("JV3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Its for Search and fill the Currency's are available in current date /// </summary> /// <param name="frmCurrencyDetails"></param> /// <param name="decId"></param> public void CallFromCurrenCyDetails(frmCurrencyDetails frmCurrencyDetails, decimal decId) { try { decimal decExchangeRateId = 0; ExchangeRateSP spExchangeRate = new ExchangeRateSP(); decExchangeRateId = spExchangeRate.GetExchangeRateId(decId, Convert.ToDateTime(txtContraVoucherDate.Text)); dgvContraVoucher.CurrentRow.Cells["dgvcmbCurrency"].Value = decExchangeRateId; base.Show(); this.frmCurrencyObj = frmCurrencyDetails; frmCurrencyObj.Close(); frmCurrencyObj = null; } catch (Exception ex) { MessageBox.Show("CV:06" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }