public void insertLedgerTransaction(string strVoucherCode) { JournalVoucherMBL objJournalVoucherMBL = new JournalVoucherMBL(); JournalVoucherTBL objJournalVoucherTBL = new JournalVoucherTBL(); JournalVoucherTBO objJournalVoucherTBO = new JournalVoucherTBO(); ApplicationResult objResultSelect = new ApplicationResult(); ApplicationResult objResultInsert = new ApplicationResult(); DataTable dt = new DataTable(); objResultSelect = objJournalVoucherMBL.JournalVoucherM_Select(strVoucherCode, Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID])); if (objResultSelect != null) { dt = objResultSelect.resultDT; if (dt.Rows.Count > 0) { int intJournalID = Convert.ToInt32(dt.Rows[0][0].ToString()); for (int i = 1; i < dt.Rows.Count; i++) { int intOppJpurnaaID = Convert.ToInt32(dt.Rows[i][0].ToString()); objJournalVoucherTBO.JournalID = intJournalID; objJournalVoucherTBO.OppositeJournalID = intOppJpurnaaID; objJournalVoucherTBO.CreatedDate = DateTime.UtcNow.AddHours(5.5).ToString("dd/MM/yyyy"); objJournalVoucherTBO.CreatedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objJournalVoucherTBO.IsDeleted = 0; objJournalVoucherTBO.LastModifideDate = DateTime.UtcNow.AddHours(5.5).ToString("dd/MM/yyyy"); objJournalVoucherTBO.LastModifideUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objResultInsert = objJournalVoucherTBL.JournalVoucherT_Insert(objJournalVoucherTBO); } } } }
protected void gvJournalEntry_RowCommand(object sender, GridViewCommandEventArgs e) { try { JournalVoucherMBL objJournalVoucherMBL = new JournalVoucherMBL(); JournalVoucherMBO objJournalVoucherMBO = new JournalVoucherMBO(); ViewState["VoucherCode"] = e.CommandArgument.ToString(); if (e.CommandName.ToString() == "Edit1") { GvContraEntry.SelectedIndex = -1; ApplicationResult objResultSelect = new ApplicationResult(); objResultSelect = objJournalVoucherMBL.JournalVoucherM_Select(ViewState["VoucherCode"].ToString(), Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID])); if (objResultSelect != null) { DataTable dtSelect = new DataTable(); dtSelect = objResultSelect.resultDT; if (dtSelect.Rows.Count > 0) { ViewState["VoucherRow"] = dtSelect.Rows.Count; DataTable dt = new DataTable(); dt.Columns.Add("Number"); for (int i = 1; i <= Convert.ToInt32(ViewState["VoucherRow"]); i++) { dt.Rows.Add(i.ToString()); } GvContraEntry.DataSource = dt; GvContraEntry.DataBind(); BindAccountGroup(); for (int i = 0; i < dtSelect.Rows.Count; i++) { ((DropDownList)GvContraEntry.Rows[i].Cells[0].FindControl("ddlAccountName")).SelectedValue = dtSelect.Rows[i]["LedgerID"].ToString(); if (dtSelect.Rows[i]["TransactionType"].ToString() == "Debit") { ((TextBox)GvContraEntry.Rows[i].Cells[2].FindControl("txtDebitAmount")).Text = dtSelect.Rows[i]["Amount"].ToString(); } else { ((TextBox)GvContraEntry.Rows[i].Cells[3].FindControl("txtCreditAmount")).Text = dtSelect.Rows[i]["Amount"].ToString(); } GvContraEntry.Rows[i].Cells[4].Text = dtSelect.Rows[i][0].ToString(); txtNarration.Text = dtSelect.Rows[i]["Description"].ToString(); if (Convert.ToInt32(dtSelect.Rows[i]["ChequeNumber"]) != 0) { txtChequeNo.Text = dtSelect.Rows[i]["ChequeNumber"].ToString(); } txtVoucherCode.Text = ViewState["VoucherCode"].ToString(); txtDate.Text = dtSelect.Rows[i]["VoucherDate"].ToString(); } PanelVisibility(2); setControlScript(); enableDisableText(); getDebitCreditSum(); ViewState["Mode"] = "Edit"; } } } else if (e.CommandName.ToString() == "Delete1") { ApplicationResult objResultDelete = new ApplicationResult(); objResultDelete = objJournalVoucherMBL.JournalVoucherM_Delete(e.CommandArgument.ToString(), "Contra"); if (objResultDelete.status == ApplicationResult.CommonStatusType.SUCCESS) { BindGrid(); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Deleted Successfully.');</script>"); } } } catch (Exception ex) { logger.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>"); } }