/// <summary> /// Function to fill the fields for edit or delete /// </summary> public void FillFunction() { try { DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo(); //DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); DebitNoteBll bllDebitNote = new DebitNoteBll(); infoDebitNoteMaster = bllDebitNote.DebitNoteMasterView(decDebitNoteMasterIdForEdit); txtVoucherNo.ReadOnly = false; strVoucherNo = infoDebitNoteMaster.VoucherNo; strInvoiceNo = infoDebitNoteMaster.InvoiceNo; txtVoucherNo.Text = strInvoiceNo; decDebitNoteSuffixPrefixId = infoDebitNoteMaster.SuffixPrefixId; decDebitNoteVoucherTypeId = infoDebitNoteMaster.VoucherTypeId; dtpVoucherDate.Value = infoDebitNoteMaster.Date; txtNarration.Text = infoDebitNoteMaster.Narration; VoucherTypeBll BllVoucherType = new VoucherTypeBll(); isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDebitNoteVoucherTypeId); if (isAutomatic) { txtVoucherNo.ReadOnly = true; } else { txtVoucherNo.ReadOnly = false; } //GridFill List<DataTable> listObj = new List<DataTable>(); //DebitNoteDetailsSP spDebitNoteDetailsSp = new DebitNoteDetailsSP(); //DebitNoteBll bllDebitNote = new DebitNoteBll(); listObj = bllDebitNote.DebitNoteDetailsViewByMasterId(decDebitNoteMasterIdForEdit); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); for (int inI = 0; inI < listObj[0].Rows.Count; inI++) { dgvDebitNote.Rows.Add(); dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(listObj[0].Rows[inI]["ledgerId"].ToString()); if (Convert.ToDecimal(listObj[0].Rows[inI]["debit"].ToString()) == 0) { dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Cr"; dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(listObj[0].Rows[inI]["credit"].ToString()); } else { dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Dr"; dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(listObj[0].Rows[inI]["debit"].ToString()); } dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(listObj[0].Rows[inI]["exchangeRateId"].ToString()); if (listObj[0].Rows[inI]["chequeNo"].ToString() != string.Empty) { dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value = listObj[0].Rows[inI]["chequeNo"].ToString(); dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value = (Convert.ToDateTime(listObj[0].Rows[inI]["chequeDate"].ToString())).ToString(); } dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value = listObj[0].Rows[inI]["DebitNoteDetailsId"].ToString(); decimal decDetailsId1 = Convert.ToDecimal(listObj[0].Rows[inI]["DebitNoteDetailsId"].ToString()); decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decDebitNoteVoucherTypeId); dgvDebitNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); btnSave.Text = "Update"; } PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); List<DataTable> listObj1 = new List<DataTable>(); listObj1 = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decDebitNoteVoucherTypeId, strVoucherNo, infoDebitNoteMaster.Date); dtblPartyBalance = listObj1[0]; dgvDebitNote.ClearSelection(); txtDate.Focus(); } catch (Exception ex) { MessageBox.Show("DRNT37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }