protected void btnTransactionSubmit_Click(object sender, EventArgs e) { try { if (ddlProjFilter.Items.Count > 1 && ddlProjFilter.SelectedIndex == 0) { lblErrorMsg.Text = "Select Project to add new transaction"; ddlProjFilter.Focus(); return; } else if (ddlGrantee.Items.Count > 1 && ddlGrantee.SelectedIndex == 0) { lblErrorMsg.Text = "Select Grantee to add new transaction"; ddlGrantee.Focus(); return; } else if (txtTotAmt.Text.Trim() == "" || Convert.ToDecimal(txtTotAmt.Text) <= 0) { lblErrorMsg.Text = "Select a valid transaction amount"; txtTotAmt.Focus(); return; } lblErrorMsg.Text = ""; decimal TransAmount = Convert.ToDecimal(txtTotAmt.Text); this.hfTransAmt.Value = TransAmount.ToString(); this.hfBalAmt.Value = TransAmount.ToString(); //if (pnlTranDetails.Visible) // ClearTransactionDetailForm(); gvBCommit.DataSource = null; gvBCommit.DataBind(); pnlTranDetails.Visible = true; ClearTransactionDetailForm(); CommonHelper.EnableButton(btnDecommitmentSubmit); CommonHelper.DisableButton(btnTransactionSubmit); DataTable dtTrans = FinancialTransactions.AddBoardFinancialTransaction(Convert.ToInt32(ddlProjFilter.SelectedValue.ToString()), Convert.ToDateTime(txtTransDate.Text), -TransAmount, Convert.ToInt32(ddlGrantee.SelectedValue.ToString()), rdBtnFinancial.SelectedIndex == 0 ? "Board Commitment" : "Board DeCommitment", TRANS_PENDING_STATUS); gvPTrans.DataSource = dtTrans; gvPTrans.DataBind(); txtTransDate.Text = DateTime.Now.ToShortDateString(); txtTotAmt.Text = ""; } catch (Exception ex) { lblErrorMsg.Text = ex.Message; } }
protected void btnTransactionSubmit_Click(object sender, EventArgs e) { try { if (txtProjNum.Text == "") { lblErrorMsg.Text = "Select Project to add new transaction"; txtProjNum.Focus(); return; } else if (txtTotAmt.Text.Trim() == "") { lblErrorMsg.Text = "Select a valid transaction amount"; txtTotAmt.Focus(); return; } decimal n; bool isNumeric = decimal.TryParse(txtTotAmt.Text.Trim(), out n); if (!isNumeric) { lblErrorMsg.Text = "Must enter numbers in Total Amount"; return; } if (Convert.ToDecimal(txtTotAmt.Text.Trim()) <= 0) { lblErrorMsg.Text = "Select a valid transaction amount"; return; } if (hfProjId.Value == "") { lblErrorMsg.Text = "Select an existing project to make a commitment"; txtProjNum.Focus(); return; } lblErrorMsg.Text = ""; decimal TransAmount = Convert.ToDecimal(txtTotAmt.Text); this.hfTransAmt.Value = TransAmount.ToString(); this.hfBalAmt.Value = TransAmount.ToString(); gvBCommit.DataSource = null; gvBCommit.DataBind(); pnlTranDetails.Visible = true; ClearTransactionDetailForm(); int?granteeId = null; if (hfGrantee.Value != "") { granteeId = Convert.ToInt32(hfGrantee.Value); } DataTable dtTrans = FinancialTransactions.AddBoardFinancialTransaction(Convert.ToInt32(hfProjId.Value), Convert.ToDateTime(txtTransDate.Text), TransAmount, granteeId, "Board Commitment", TRANS_PENDING_STATUS); hfTransId.Value = dtTrans.Rows[0]["transid"].ToString(); BindTransGrid(GetTransId()); txtTransDate.Text = DateTime.Now.ToShortDateString(); txtTotAmt.Text = ""; CommonHelper.EnableButton(btnCommitmentSubmit); CommonHelper.DisableButton(btnTransactionSubmit); } catch (Exception ex) { lblErrorMsg.Text = ex.Message; } }
protected void btnTransactionSubmit_Click(object sender, EventArgs e) { try { if (txtProjNum.Text == "") { lblErrorMsg.Text = "Select Project to add new transaction"; txtProjNum.Focus(); return; } else if (txtTotAmt.Text.Trim() == "") { lblErrorMsg.Text = "Select a valid transaction amount"; txtTotAmt.Focus(); return; } decimal n; bool isNumeric = decimal.TryParse(txtTotAmt.Text.Trim(), out n); if (!isNumeric) { lblErrorMsg.Text = "Must enter numbers in Total Amount"; return; } if (Convert.ToDecimal(txtTotAmt.Text.Trim()) <= 0) { lblErrorMsg.Text = "Select a valid transaction amount"; return; } //DataTable dtCommitFund = FinancialTransactions.GetCommittedFundPerProject(txtProjNum.Text); //if (dtCommitFund != null) // if (dtCommitFund.Rows.Count > 0) // if (Convert.ToDecimal(dtCommitFund.Rows[0]["availFunds"].ToString()) < Convert.ToDecimal(txtTotAmt.Text.Trim())) // { // lblErrorMsg.Text = "Cash Refund amount can not be more than available funds : " + CommonHelper.myDollarFormat(dtCommitFund.Rows[0]["availFunds"].ToString()) + " for the selected project"; // return; // } if (txtTotAmt.Text.Trim() != "") { bool isDecimal = decimal.TryParse(txtTotAmt.Text.Trim(), out n); if (!isDecimal || Convert.ToDecimal(txtTotAmt.Text) <= 0) { lblErrorMsg.Text = "Select a valid cash refund amount"; txtTotAmt.Focus(); return; } bool availFunds = decimal.TryParse(lblAvailFund.Text.Trim(), out n); if (!availFunds || Convert.ToDecimal(txtTotAmt.Text) > Convert.ToDecimal(lblAvailFund.Text)) { if (!availFunds) { lblErrorMsg.Text = "Cash refund amount can't be more than available funds (" + CommonHelper.myDollarFormat(0) + ") for the selected project"; } else { lblErrorMsg.Text = "Cash refund amount can't be more than available funds (" + CommonHelper.myDollarFormat(lblAvailFund.Text) + ") for the selected project"; } txtTotAmt.Focus(); return; } } lblErrorMsg.Text = ""; decimal TransAmount = Convert.ToDecimal(txtTotAmt.Text); this.hfTransAmt.Value = TransAmount.ToString(); this.hfBalAmt.Value = TransAmount.ToString(); gvBCommit.DataSource = null; gvBCommit.DataBind(); pnlTranDetails.Visible = true; ClearTransactionDetailForm(); int?granteeId = null; if (hfGrantee.Value != "") { granteeId = Convert.ToInt32(hfGrantee.Value); } DataTable dtTrans = FinancialTransactions.AddBoardFinancialTransaction(Convert.ToInt32(hfProjId.Value), Convert.ToDateTime(txtTransDate.Text), TransAmount, granteeId, "Cash Refund", TRANS_PENDING_STATUS); hfTransId.Value = dtTrans.Rows[0]["transid"].ToString(); BindTransGrid(GetTransId()); txtTransDate.Text = DateTime.Now.ToShortDateString(); txtTotAmt.Text = ""; CommonHelper.EnableButton(btnCashRefundSubmit); CommonHelper.DisableButton(btnTransactionSubmit); } catch (Exception ex) { lblErrorMsg.Text = ex.Message; } }