using Swift.DAL.VoucherReport; using Swift.web.Library; using System; using System.Data; using System.Text; namespace Swift.web.BillVoucher.DollarVoucherEntry { public partial class List : System.Web.UI.Page { private const string ViewFunctionId = "20150080"; private const string DateFunctionId = "20150040"; private readonly RemittanceLibrary _sdd = new RemittanceLibrary(); private readonly VoucherReportDAO _vrd = new VoucherReportDAO(); protected void Page_Load(object sender, EventArgs e) { Authenticate(); if (!IsPostBack) { AllowChangeDate(); Misc.MakeAmountTextBox(ref usdAmt); Misc.MakeAmountTextBox(ref rate); Misc.MakeAmountTextBox(ref lcAmt); transactionDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); transactionDate.Attributes.Add("readonly", "readonly"); lcAmt.Attributes.Add("readonly", "readonly"); //transactionDate.ReadOnly = true; } } private void Authenticate() { _sdd.CheckAuthentication(ViewFunctionId); } protected bool AllowChangeDate() { return _sdd.HasRight(DateFunctionId); } protected void addBtn_Click(object sender, EventArgs e) { if (GetStatic.ParseDouble(usdAmt.Text) <= 0) { GetStatic.AlertMessage(this, "Please enter valid Amount! "); usdAmt.Text = " "; usdAmt.Focus(); return; } var result = _vrd.InsertTempVoucherEntryUSD(GetStatic.GetSessionId(), GetStatic.GetUser(), acInfo.Value, trantype.SelectedValue, usdAmt.Text, rate.Text, lcAmt.Text); if (result.ErrorCode == "1") { GetStatic.AlertMessage(this, result.Msg); } else { ShowTempVoucher(); } } private void ShowTempVoucher() { //show data on div int sno = 0, drCount = 0, crCount = 0; double drTotal = 0, crTotal = 0; var dt = _vrd.GetTempVoucherEntryDataFRV(GetStatic.GetSessionId()); var sb = new StringBuilder(""); sb.AppendLine("
"); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); if (dt == null || dt.Rows.Count == 0) { sb.AppendLine("
S. NoAC informationType(USD) AmountEx. RateLC AmtSelect
No transaction found!
"); rpt_tempVoucherTrans.InnerHtml = sb.ToString(); return; } foreach (DataRow item in dt.Rows) { sno++; if (item["part_tran_type"].ToString().ToLower() == "dr") { drCount++; drTotal = drTotal + Convert.ToDouble(item["tran_amt"]); } else if (item["part_tran_type"].ToString().ToLower() == "cr") { crCount++; crTotal = crTotal + Convert.ToDouble(item["tran_amt"]); } sb.AppendLine(""); sb.AppendLine("" + sno.ToString() + " "); sb.AppendLine(" " + item["acct_num"].ToString() + ""); sb.AppendLine("" + item["part_tran_type"].ToString() + " "); sb.AppendLine("
" + GetStatic.ShowDecimal(item["tran_amt"].ToString()) + "
"); sb.AppendLine("
" + GetStatic.ShowDecimal(item["usd_rate"].ToString()) + "
"); sb.AppendLine("
" + GetStatic.ShowDecimal(item["lc_amt_cr"].ToString()) + "
"); sb.AppendLine("
"); sb.AppendLine(""); } sb.AppendLine(""); sb.AppendLine("
Total Dr (" + drCount.ToString() + "):    " + GetStatic.ShowDecimal(drTotal.ToString()) + "
"); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine("
Total Cr (" + crCount.ToString() + "):    " + GetStatic.ShowDecimal(crTotal.ToString()) + "
"); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); rpt_tempVoucherTrans.InnerHtml = sb.ToString(); } protected void btnDelete_Click(object sender, EventArgs e) { var res = _vrd.DeleteRecordVoucherEntryFRV(hdnRowId.Value); if (res.ErrorCode == "0") { GetStatic.AlertMessage(this, res.Msg); } ShowTempVoucher(); } protected void btnUnSave_Click(object sender, EventArgs e) { ShowTempVoucher(); } protected void btnSave_Click(object sender, EventArgs e) { string date = transactionDate.Text; var res = _vrd.SaveTempTransactionUSD(GetStatic.GetSessionId(), date, narrationField.Text, chequeNumber.Text, "J", GetStatic.GetUser(), ""); if (res.ErrorCode == "0") { narrationField.Text = ""; rpt_tempVoucherTrans.InnerHtml = res.Msg; } else { GetStatic.AlertMessage(this, res.Msg); } } } }