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); } } } }
public void BindReport() { CheckNarration(); //ApplicationResult objResult = new ApplicationResult(); var objJournalRegisterBl = new JournalVoucherMBL(); int intIsNarration; if (chkNarration.Checked) { intIsNarration = 1; //var bfield = new BoundField { HeaderText = "Narration", DataField = "Description" }; //bfield.HeaderStyle.Width = new Unit("30%"); //bfield.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; //bfield.HeaderStyle.VerticalAlign = VerticalAlign.Top; //bfield.ItemStyle.Width = new Unit("30%"); //bfield.ItemStyle.HorizontalAlign = HorizontalAlign.Left; //bfield.ItemStyle.VerticalAlign = VerticalAlign.Top; //bfield.ItemStyle.Wrap = false; //gvJournalRegisterReport.Columns.Add(bfield); } else { intIsNarration = 0; } var objResult = objJournalRegisterBl.JournalRegisterReport(Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]), txtFromDate.Text, txtToDate.Text, intIsNarration); if (objResult.resultDT.Rows.Count > 0) { gvJournalRegisterReport.DataSource = objResult.resultDT; gvJournalRegisterReport.DataBind(); lblHeading.Text = "<b>Journal Register </b><br/>" + txtFromDate.Text + " To " + txtToDate.Text; } }
public void GetMaxDate() { JournalVoucherMBL objJournalVoucherMBL = new JournalVoucherMBL(); ApplicationResult objresult = new ApplicationResult(); objresult = objJournalVoucherMBL.GetMaxDate(Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]), "Payment", Convert.ToInt32(Session[ApplicationSession.FINANCIALYEAR])); if (objresult != null) { DataTable dt = objresult.resultDT; if (dt.Rows[0][0].ToString() != "") { txtDate.Text = dt.Rows[0][0].ToString(); } else { txtDate.Text = Session[ApplicationSession.ACCOUNTTODATE].ToString(); } } }
public void BindGrid() { try { JournalVoucherMBL objJournalVoucherMBL = new JournalVoucherMBL(); JournalVoucherMBO objJournalVoucherMBO = new JournalVoucherMBO(); ApplicationResult objResultSelectAll = new ApplicationResult(); objResultSelectAll = objJournalVoucherMBL.JournalVoucherM_SelectAll(Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]), Convert.ToInt32(Session[ApplicationSession.FINANCIALYEAR]), "Contra", Session[ApplicationSession.ACCOUNTFROMDATE].ToString(), Session[ApplicationSession.ACCOUNTTODATE].ToString()); if (objResultSelectAll != null) { DataTable dtSelectAll = new DataTable(); dtSelectAll = objResultSelectAll.resultDT; gvJournalContraEntry.DataSource = dtSelectAll; gvJournalContraEntry.DataBind(); } } 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>"); } }
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>"); } }
protected void btnSave_Click(object sender, EventArgs e) { try { string strVouchersDate = txtDate.Text; string strFromDate = Session[ApplicationSession.ACCOUNTFROMDATE].ToString(); string strToDate = Session[ApplicationSession.ACCOUNTTODATE].ToString(); string strYear; DateTime FromDate = Convert.ToDateTime(strFromDate); DateTime ToDate = Convert.ToDateTime(strToDate); DateTime VoucherDate = Convert.ToDateTime(strVouchersDate); strYear = Session[ApplicationSession.FINANCIALYEAR].ToString(); if (VoucherDate >= FromDate && VoucherDate <= ToDate) { //intOrgID = Convert.ToInt32(Session["Org_ID"].ToString()); getDebitCreditSum(); string strDebitSum, strCreditSum; strDebitSum = ((System.Web.UI.HtmlControls.HtmlInputText)(GvContraEntry.FooterRow.Cells[2].FindControl("txtDebitSum"))).Value; strCreditSum = ((System.Web.UI.HtmlControls.HtmlInputText)(GvContraEntry.FooterRow.Cells[3].FindControl("txtCreditSum"))).Value; // CHECK WHETHER ANY AMOUNT IS WITHOUT ACCOUNT SELECTION int intvalidate = 0; for (int i = 0; i < GvContraEntry.Rows.Count; i++) { string ddlVal = ((DropDownList)(GvContraEntry.Rows[i].Cells[0].FindControl("ddlAccountName"))).SelectedItem.Value; string strDebitAmt = ((TextBox)(GvContraEntry.Rows[i].Cells[2].FindControl("txtDebitAmount"))).Text; string strCreditAmt = ((TextBox)(GvContraEntry.Rows[i].Cells[3].FindControl("txtCreditAmount"))).Text; if (strDebitAmt != "" || strCreditAmt != "") { if (ddlVal == "-1") { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Select Account or enter amount before save Contra entry.');</script>"); return; } } else { intvalidate = intvalidate + 1; } if (GvContraEntry.Rows.Count == intvalidate) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Select Account or enter amount before save Contra entry.');</script>"); return; } } if (strDebitSum == strCreditSum) // CHECKS WHETHER THE AMOUNTS MATCHES OR NOT { JournalVoucherMBL objJournalVoucherMBL = new JournalVoucherMBL(); JournalVoucherMBO objJournalVoucherMBO = new JournalVoucherMBO(); //JournalVoucherTBL objJournalVoucherTBL = new JournalVoucherTBL(); //JournalVoucherTBO objJournalVoucherTBO = new JournalVoucherTBO(); DatabaseTransaction.OpenConnectionTransation(); if (ViewState["Mode"].ToString() == "Save") { ApplicationResult objResultInsert = new ApplicationResult(); objJournalVoucherMBO.TrustMID = Convert.ToInt32(Session[ApplicationSession.TRUSTID]); objJournalVoucherMBO.SchoolMID = Convert.ToInt32(Session[ApplicationSession.SCHOOLID]); objJournalVoucherMBO.VoucherDate = txtDate.Text; if (txtChequeNo.Text != "") { objJournalVoucherMBO.ChequeNumber = Convert.ToInt32(txtChequeNo.Text); } objJournalVoucherMBO.OperationType = "Contra"; objJournalVoucherMBO.Description = txtNarration.Text; objJournalVoucherMBO.CreatedBy = Convert.ToInt32(Session[ApplicationSession.USERID]); objJournalVoucherMBO.CreatedDate = DateTime.UtcNow.AddHours(5.5).ToString("dd/MM/yyyy"); objJournalVoucherMBO.IsDeleted = 0; objJournalVoucherMBO.LastModifideDate = DateTime.UtcNow.AddHours(5.5).ToString("dd/MM/yyyy"); objJournalVoucherMBO.LastModifideUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objJournalVoucherMBO.Year = Convert.ToInt32(strYear); for (int i = 0; i < GvContraEntry.Rows.Count; i++) { string strAccountID = ((DropDownList)(GvContraEntry.Rows[i].Cells[0].FindControl("ddlAccountName"))).SelectedItem.Value; string strDebit = ((TextBox)(GvContraEntry.Rows[i].Cells[2].FindControl("txtDebitAmount"))).Text; string strCredit = ((TextBox)(GvContraEntry.Rows[i].Cells[3].FindControl("txtCreditAmount"))).Text; if ((strAccountID == "-1" && strDebit == "") || (strAccountID == "-1" && strCredit == "")) { continue; } if (strAccountID != "-1") { objJournalVoucherMBO.LedgerID = Convert.ToInt32(strAccountID); if (strDebit == "") { objJournalVoucherMBO.TransactionType = "Credit"; objJournalVoucherMBO.Amount = Convert.ToDouble(strCredit); } else { objJournalVoucherMBO.TransactionType = "Debit"; objJournalVoucherMBO.Amount = Convert.ToDouble(strDebit); } objResultInsert = objJournalVoucherMBL.JournalVoucherM_Insert(objJournalVoucherMBO); if (i == 0) { if (objResultInsert != null) { DataTable dt = new DataTable(); dt = objResultInsert.resultDT; if (dt.Rows.Count > 0) { if (dt.Rows[0][0].ToString() == "0") { DatabaseTransaction.RollbackTransation(); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Please Initialize Voucher Start No. For This Year.');</script>"); goto Exit; } else { ViewState["VoucherNo"] = Convert.ToInt32(dt.Rows[0][0]); ViewState["VoucherCode"] = dt.Rows[0][1].ToString(); objJournalVoucherMBO.VoucherNo = Convert.ToInt32(ViewState["VoucherNo"]); objJournalVoucherMBO.VoucherCode = ViewState["VoucherCode"].ToString(); } } } } else { objJournalVoucherMBO.VoucherNo = Convert.ToInt32(ViewState["VoucherNo"]); objJournalVoucherMBO.VoucherCode = ViewState["VoucherCode"].ToString(); } } } insertLedgerTransaction(ViewState["VoucherCode"].ToString()); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Contra Saved Successfully. Voucher No is " + ViewState["VoucherCode"].ToString() + "');</script>"); } else if (ViewState["Mode"].ToString() == "Edit") // UPDATE THE EXISTING JOURNAL { ApplicationResult objResulUpdate = new ApplicationResult(); objJournalVoucherMBO.TrustMID = Convert.ToInt32(Session[ApplicationSession.TRUSTID]); objJournalVoucherMBO.SchoolMID = Convert.ToInt32(Session[ApplicationSession.SCHOOLID]); objJournalVoucherMBO.VoucherDate = txtDate.Text; if (txtChequeNo.Text != "") { objJournalVoucherMBO.ChequeNumber = Convert.ToInt32(txtChequeNo.Text); } objJournalVoucherMBO.OperationType = "Contra"; objJournalVoucherMBO.Description = txtNarration.Text; objJournalVoucherMBO.CreatedBy = Convert.ToInt32(Session[ApplicationSession.USERID]); objJournalVoucherMBO.CreatedDate = DateTime.UtcNow.AddHours(5.5).ToString("dd/MM/yyyy"); objJournalVoucherMBO.IsDeleted = 0; objJournalVoucherMBO.LastModifideDate = DateTime.UtcNow.AddHours(5.5).ToString("dd/MM/yyyy"); objJournalVoucherMBO.LastModifideUserID = Convert.ToInt32(Session[ApplicationSession.USERID]); objJournalVoucherMBO.Year = Convert.ToInt32(strYear); objJournalVoucherMBO.VoucherNo = Convert.ToInt32(txtVoucherCode.Text.ToString().Substring(6, txtVoucherCode.Text.Length - 6)); objJournalVoucherMBO.VoucherCode = txtVoucherCode.Text; int intActRows = 0; for (int i = 0; i < GvContraEntry.Rows.Count; i++) { string strAccId = ((DropDownList)(GvContraEntry.Rows[i].Cells[0].FindControl("ddlAccountName"))).SelectedItem.Value; if (strAccId != "-1") { intActRows++; } else { break; } } if (intActRows == Convert.ToInt32(ViewState["VoucherRow"])) // CHECKS WHETHER THE JOURNAL RECORD IS LARGER OR SMALLER THEN EXIXTING RECORD { for (int i = 0; i < GvContraEntry.Rows.Count; i++) { GvContraEntry.Columns[4].Visible = true; if (GvContraEntry.Rows[i].Cells[4].Text.ToString() != "") { string strAccountID = ((DropDownList)(GvContraEntry.Rows[i].Cells[0].FindControl("ddlAccountName"))).SelectedItem.Value; string strDebit = ((TextBox)(GvContraEntry.Rows[i].Cells[2].FindControl("txtDebitAmount"))).Text; string strCredit = ((TextBox)(GvContraEntry.Rows[i].Cells[3].FindControl("txtCreditAmount"))).Text; if (strAccountID != "-1") { objJournalVoucherMBO.LedgerID = Convert.ToInt32(strAccountID); if (strDebit == "") { objJournalVoucherMBO.TransactionType = "Credit"; objJournalVoucherMBO.Amount = Convert.ToDouble(strCredit); } else { objJournalVoucherMBO.TransactionType = "Debit"; objJournalVoucherMBO.Amount = Convert.ToDouble(strDebit); } } objJournalVoucherMBO.JournalID = Convert.ToInt32(GvContraEntry.Rows[i].Cells[4].Text.ToString()); objResulUpdate = objJournalVoucherMBL.JournalVoucherM_Update(objJournalVoucherMBO, Session[ApplicationSession.ACCOUNTFROMDATE].ToString()); } GvContraEntry.Columns[4].Visible = false; } } else { ApplicationResult objResultInsert = new ApplicationResult(); ApplicationResult objResultDelete = new ApplicationResult(); objResultDelete = objJournalVoucherMBL.JournalVoucherM_Delete_Transaction(txtVoucherCode.Text, "Journal"); if (objResultDelete.status == ApplicationResult.CommonStatusType.SUCCESS) { } for (int i = 0; i < GvContraEntry.Rows.Count; i++) { string strAccountID = ((DropDownList)(GvContraEntry.Rows[i].Cells[0].FindControl("ddlAccountName"))).SelectedItem.Value; string strDebit = ((TextBox)(GvContraEntry.Rows[i].Cells[2].FindControl("txtDebitAmount"))).Text; string strCredit = ((TextBox)(GvContraEntry.Rows[i].Cells[3].FindControl("txtCreditAmount"))).Text; if (strAccountID != "-1") { objJournalVoucherMBO.LedgerID = Convert.ToInt32(strAccountID); if (strDebit == "") { objJournalVoucherMBO.TransactionType = "Credit"; objJournalVoucherMBO.Amount = Convert.ToDouble(strCredit); } else { objJournalVoucherMBO.TransactionType = "Debit"; objJournalVoucherMBO.Amount = Convert.ToDouble(strDebit); } objResultInsert = objJournalVoucherMBL.JournalVoucherM_Insert(objJournalVoucherMBO); } else { break; } } insertLedgerTransaction(txtVoucherCode.Text); } ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Contra Updated Successfully...');</script>"); } DatabaseTransaction.CommitTransation(); clear(); PanelVisibility(1); BindGrid(); } else // WHEN THE AMOUNTS DOESNOT MATCH { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Total amounts of Debit and Credit donot match...');</script>"); return; } } else { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Select Date according to your Accounting Period.');</script>"); return; } GvContraEntry.Visible = true; Exit :; } catch (Exception ex) { DatabaseTransaction.RollbackTransation(); logger.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>"); } finally { DatabaseTransaction.connection.Close(); } }