我想在单击插入/更新按钮时显示进度条,因为按钮具有一些验证/更新/插入功能,因此我无法计算特定按钮单击过程的时间。这是我的代码。
try
{
dt = myDbGL.SelectQuery("Select ComCreationDate from GASCompanyDetail where ComCode = '" + DropDownCompany.SelectedItem.Value + "' And ComCreationDate is not NULL");
if (dt.Rows.Count != 0)
{
DateTime ComDate = DateTime.Parse(dt.Rows[0]["ComCreationDate"].ToString());
DateTime TRDate = DateTime.Parse(TB_TRDate.Text);
DateTime GLDate = DateTime.Parse(TB_GLDate.Text);
int result = DateTime.Compare(TRDate, ComDate);
if (result < 0)
{
DisplayMessage = "Transaction Date is not less then to Company Creation Date!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true); return;
}
result = DateTime.Compare(GLDate, ComDate);
if (result < 0)
{
DisplayMessage = "GL Date is not less then to Company Creation Date!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true); return;
}
}
GridTotal();
dt = myDbGL.SelectQuery("Select * from GLSBankAccountDetailView where AccCode = '" + DropDownType.SelectedItem.Value + "'");
if (dt.Rows.Count != 0)
{
ChequeBankName = ""; // dt.Rows[0]["BankName"].ToString();
ChequeBranchName = ""; // dt.Rows[0]["BranchName"].ToString();
ChequeAccountNo = dt.Rows[0]["BacAccountNumber"].ToString();
}
TRTotalAmount = 0;
TRTotalAmount = myDbGL.ConvertStringToNumber(TB_TRTotalAmount.Text);
if (TRTotalAmount < 0)
{
DisplayMessage = "Cannot Save Negative Transaction!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
ExchangeRate = myDbGL.ConvertStringToNumber(TB_TRExchangeRate.Text);
if (ExchangeRate == 0)
{
DisplayMessage = "Please enter valid Exchange Rate!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
dt = myDbGL.SelectQuery("Select EntryFrom from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And EntryFrom = 'Payment Detail'");
if (dt.Rows.Count == 0)
{
DisplayMessage = "This Transaction is not related to this Entry Form";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
dt = myDbGL.SelectQuery("Select EnterBy, EnterDate from GLTPaymentMaster where TRNo = '" + TB_TRCode_Hidden.Text + "'");
if (dt.Rows.Count != 0)
{
EnterBy = dt.Rows[0]["EnterBy"].ToString();
EnterDate = dt.Rows[0]["EnterDate"].ToString();
}
if (TB_TRCode.Text.Left(2) == "BP") { VoucherType = "BANK"; } else { VoucherType = "CASH"; }
if (CB_Reverse.Checked) { ReverseDateCheck = TB_ReverseDate.Text; } else { ReverseDateCheck = null; }
if (!CB_Reverse.Checked)
{
dt = myDbGL.SelectQuery("Select TRPostStatus, TRPostStatusReverse from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And (TRPostStatusReverse = 'UN-POST')");
if (dt.Rows.Count != 0)
{
myDbGL.deleteTable("Delete from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And TRReverseStatus = 1");
myDbGL.UpdatePaymentMaster(TB_TRCode_Hidden.Text, CB_Reverse.Checked.ToString(), ReverseDateCheck, EnterBy.ToString(), EnterDate.ToString(), LoginUserID.ToString(), myDbGL.GetServerDateTime());
}
dt = myDbGL.SelectQuery("Select TRPostStatus, TRPostStatusReverse from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And (TRPostStatus = 'POST')");
if (dt.Rows.Count != 0)
{
DisplayMessage = "Cannot Change Posted Transaction!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
dt = myDbGL.SelectQuery("Select TRPostStatus, TRPostStatusReverse from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And (TRPostStatusReverse = 'POST')");
if (dt.Rows.Count != 0)
{
DisplayMessage = "Cannot Change Posted Transaction!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
}
TRApprovedLevel = 0; TRCurrentLevel = 0; TRUserLevel = 0;
dt = myDbGL.SelectQuery("Select PagWebAddress from UMSPageDetail where PagWebAddress like '%" + Path.GetFileName(Request.PhysicalPath) + "%' And PagApprove = 'True'");
if (dt.Rows.Count != 0)
{
dt1 = myDbGL.SelectQuery("Select * from GLTPostingDetail where PosPageName not like '%Reverse%' And PosPageWebAddress like '" + Path.GetFileName(Request.PhysicalPath) + "'");
if (dt1.Rows.Count != 0)
{
dt2 = myDbGL.SelectQuery("Select TOP (1) ApvSerialNo from GASApprovalPolicyDetailView where ApvTType = '" + dt1.Rows[0]["PosPageName"].ToString() + "' And SitCode like '" + LoginUserIDSitCode.ToString() + "' Order by ApvSerialNo Desc");
if (dt2.Rows.Count != 0) { TRApprovedLevel = myDbGL.ConvertStringToNumber(dt2.Rows[0]["ApvSerialNo"].ToString()); }
dt2 = myDbGL.SelectQuery("Select TOP (1) ApvSerialNo from GASApprovalPolicyDetailView where ApvTType = '" + dt1.Rows[0]["PosPageName"].ToString() + "' And SitCode like '" + LoginUserIDSitCode.ToString() + "' AND UseID = '" + LoginUserID.ToString() + "' Order by ApvSerialNo Desc");
if (dt2.Rows.Count != 0) { TRUserLevel = myDbGL.ConvertStringToNumber(dt2.Rows[0]["ApvSerialNo"].ToString()); }
dt2 = myDbGL.SelectQuery("Select ApprovedLevel from [" + dt1.Rows[0]["PosTableMaster"].ToString() + "] where [" + dt1.Rows[0]["PosColumnWhereMaster"].ToString() + "] = '" + TB_TRCode.Text + "'");
if (dt2.Rows.Count != 0) { TRCurrentLevel = myDbGL.ConvertStringToNumber(dt2.Rows[0]["ApprovedLevel"].ToString()); }
if (TRApprovedLevel != 0 && TRCurrentLevel > TRUserLevel)
{
DisplayMessage = "Cannot Change as This Transaction approved by Higher Authority!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true); return;
}
}
}
if (CB_Reverse.Checked)
{
dt = myDbGL.SelectQuery("Select TRPostStatus, TRPostStatusReverse from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And (TRPostStatus <> 'POST')");
if (dt.Rows.Count != 0)
{
DisplayMessage = "Cannot Reverse Un-Posted Transaction!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
dt = myDbGL.SelectQuery("Select TRPostStatus, TRPostStatusReverse from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And (TRPostStatusReverse = 'POST')");
if (dt.Rows.Count != 0)
{
DisplayMessage = "Cannot Reverse Posted Transaction!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
if (TB_ReverseDate.Text.ToString().Equals(""))
{
DisplayMessage = "Please Enter Any Reverse Date!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
DateTime GLDate = DateTime.Parse(TB_GLDate.Text);
DateTime ReverseDate = DateTime.Parse(TB_ReverseDate.Text);
int result = DateTime.Compare(ReverseDate, GLDate);
if (result < 0)
{
DisplayMessage = "Reverse Date is not less then/equals to GL Date. Please enter correct Reverse Date!";
ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + DisplayMessage + "');", true);
return;
}
//myDbGL.deleteTable("Delete from GLTPaymentMaster where TRNo = '" + TB_TRCode_Hidden.Text + "'");
myDbGL.deleteTable("Delete from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And TRReverseStatus = 1");
dt = myDbGL.SelectQuery("Select * from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "' And TRReverseStatus = 0");
for (int i = 0; i < dt.Rows.Count; i++)
{
dt1 = myDbGL.SelectQuery("Select TRSerialNo from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "'");
myDbGL.InsertLedgerDetail(dt.Rows[i]["TRNo"].ToString(), dt.Rows[i]["TRDate"].ToString(), ReverseDateCheck, dt.Rows[i]["TRType"].ToString(), "POST", "UN-POST", CB_Reverse.Checked.ToString(), ReverseDateCheck, (myDbGL.ConvertStringToNumber(dt1.Rows.Count.ToString()) + 1).ToString(), dt.Rows[i]["TRAccCode"].ToString(), dt.Rows[i]["TRRefAccCode"].ToString(), dt.Rows[i]["TRDocReference"].ToString(), myDbGL.ConvertStringToNumber(dt.Rows[i]["TRDocRefTotalAmount"].ToString()), myDbGL.ConvertStringToNumber(dt.Rows[i]["TRDocRefBalanceAmount"].ToString()), myDbGL.ConvertStringToNumber(dt.Rows[i]["TRCredit"].ToString()), myDbGL.ConvertStringToNumber(dt.Rows[i]["TRDebit"].ToString()), myDbGL.ConvertStringToNumber(dt.Rows[i]["TRExchangeRate"].ToString()), myDbGL.ConvertStringToNumber(dt.Rows[i]["TRAmountConverted"].ToString()), dt.Rows[i]["TRCurCode"].ToString(), dt.Rows[i]["TRTxsCode"].ToString(), myDbGL.ConvertStringToNumber(dt.Rows[i]["TRTaxPercent"].ToString()), dt.Rows[i]["TRChequeNo"].ToString(), dt.Rows[i]["TRChequeDate"].ToString(), dt.Rows[i]["TRChequeMaturityDate"].ToString(), dt.Rows[i]["TRChequeDepositDate"].ToString(), dt.Rows[i]["TRDepositNo"].ToString(), dt.Rows[i]["TRChequeBankName"].ToString(), dt.Rows[i]["TRChequeBranchName"].ToString(), dt.Rows[i]["TRChequeAccountNo"].ToString(), dt.Rows[i]["TRRefNo"].ToString(), dt.Rows[i]["TRGrpCode"].ToString(), dt.Rows[i]["TRComCode"].ToString(), dt.Rows[i]["TRBsuCode"].ToString(), dt.Rows[i]["TRCosCode"].ToString(), dt.Rows[i]["TRDepCode"].ToString(), dt.Rows[i]["TRSecCode"].ToString(), dt.Rows[i]["TRProCode"].ToString(), dt.Rows[i]["TRFucCode"].ToString(), dt.Rows[i]["TRCusAccCode"].ToString(), dt.Rows[i]["TRSupAccCode"].ToString(), dt.Rows[i]["TRConAccCode"].ToString(), dt.Rows[i]["TRAgtAccCode"].ToString(), dt.Rows[i]["TRIvtAccCode"].ToString(), dt.Rows[i]["TRInvCode"].ToString(), dt.Rows[i]["TRRemarks"].ToString(), dt.Rows[i]["TREntryType"].ToString(), EnterBy.ToString(), EnterDate.ToString(), LoginUserID.ToString(), myDbGL.GetServerDateTime(), "Payment Detail", dt.Rows[i]["EntryTypeDoc"].ToString());
}
myDbGL.UpdatePaymentMaster(TB_TRCode_Hidden.Text, CB_Reverse.Checked.ToString(), ReverseDateCheck, EnterBy.ToString(), EnterDate.ToString(), LoginUserID.ToString(), myDbGL.GetServerDateTime());
myDbGL.InsertUserLog("General Ledger", "Transaction", "Payment Detail", "Update", TB_TRCode.Text, LoginUserID.ToString(), myDbGL.GetUserPCName(), myDbGL.GetUserPCIP(), myDbGL.GetUserPCMAC(), myDbGL.GetServerDateTime(), myDbGL.GetServerDateTime());
Response.Redirect(Request.Url.AbsoluteUri);
return;
}
myDbGL.deleteTable("Delete from GLTPaymentMaster where TRNo = '" + TB_TRCode_Hidden.Text + "'");
myDbGL.deleteTable("Delete from GLTLedger where TRNo = '" + TB_TRCode_Hidden.Text + "'");
TRTotalAmount = 0;
TRCount = 1;
foreach (GridViewRow gvRow in gvTransaction.Rows)
{
TRDebit = 0;
TRCredit = 0;
if (((DropDownList)gvRow.FindControl("DropDownGridAccount")).SelectedItem.Value != "-1")
{
if (((DropDownList)gvRow.FindControl("DropDownGridDebitCredit")).SelectedItem.Text == "DEBIT")
{
TRDebit = myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRAmountConverted")).Text);
TRCredit = 0;
}
else
{
TRDebit = 0;
TRCredit = myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRAmountConverted")).Text);
}
//if (myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRAmount")).Text) != 0 && ((DropDownList)gvRow.FindControl("DropDownGridAccount")).SelectedValue.ToString() != "-1")
if (myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRAmountConverted")).Text) != 0)
{
myDbGL.InsertLedgerDetail(TB_TRCode.Text, TB_TRDate.Text, TB_GLDate.Text, VoucherType, "UN-POST", "UN-POST", CB_Reverse.Checked.ToString(), ReverseDateCheck, TRCount.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridAccount")).SelectedValue.ToString(), DropDownType.SelectedItem.Value, ((DropDownList)gvRow.FindControl("DropDownGridDocRef")).SelectedValue.ToString(), myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRTotalDocAmount")).Text), myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRTotalDocBalAmount")).Text), TRDebit, TRCredit, myDbGL.ConvertStringToNumber(TB_TRExchangeRate.Text), myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRAmountConverted")).Text), DropDownCurrency.SelectedItem.Value, ((DropDownList)gvRow.FindControl("DropDownGridTaxSlab")).SelectedValue.ToString(), myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRTaxPercent")).Text), ((TextBox)gvRow.FindControl("TB_TRChequeNo")).Text, ((TextBox)gvRow.FindControl("TB_TRChequeDate")).Text, ((TextBox)gvRow.FindControl("TB_TRChequeMaturityDate")).Text, ((TextBox)gvRow.FindControl("TB_TRChequeDepositDate")).Text, "", ChequeBankName, ChequeBranchName, ChequeAccountNo, TB_TRRefNo.Text, DropDownGroup.SelectedItem.Value, DropDownCompany.SelectedItem.Value, ((DropDownList)gvRow.FindControl("DropDownGridBU")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridCostCenter")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridDepartment")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridSection")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridProject")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridFunction")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridCustomer")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridSupplier")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridContractor")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridAgent")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridInvestor")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridItem")).SelectedValue.ToString(), ((TextBox)gvRow.FindControl("TB_TRRemarks")).Text, "CHILD", EnterBy.ToString(), EnterDate.ToString(), LoginUserID.ToString(), myDbGL.GetServerDateTime(), "Payment Detail", "CHILD");
TRCount = TRCount + 1;
myDbGL.InsertLedgerDetail(TB_TRCode.Text, TB_TRDate.Text, TB_GLDate.Text, VoucherType, "UN-POST", "UN-POST", CB_Reverse.Checked.ToString(), ReverseDateCheck, TRCount.ToString(), DropDownType.SelectedItem.Value, ((DropDownList)gvRow.FindControl("DropDownGridAccount")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridDocRef")).SelectedValue.ToString(), myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRTotalDocAmount")).Text), myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRTotalDocBalAmount")).Text), TRCredit, TRDebit, myDbGL.ConvertStringToNumber(TB_TRExchangeRate.Text), myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRAmountConverted")).Text), DropDownCurrency.SelectedItem.Value, ((DropDownList)gvRow.FindControl("DropDownGridTaxSlab")).SelectedValue.ToString(), myDbGL.ConvertStringToNumber(((TextBox)gvRow.FindControl("TB_TRTaxPercent")).Text), ((TextBox)gvRow.FindControl("TB_TRChequeNo")).Text, ((TextBox)gvRow.FindControl("TB_TRChequeDate")).Text, ((TextBox)gvRow.FindControl("TB_TRChequeMaturityDate")).Text, ((TextBox)gvRow.FindControl("TB_TRChequeDepositDate")).Text, "", ChequeBankName, ChequeBranchName, ChequeAccountNo, TB_TRRefNo.Text, DropDownGroup.SelectedItem.Value, DropDownCompany.SelectedItem.Value, ((DropDownList)gvRow.FindControl("DropDownGridBU")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridCostCenter")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridDepartment")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridSection")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridProject")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridFunction")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridCustomer")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridSupplier")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridContractor")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridAgent")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridInvestor")).SelectedValue.ToString(), ((DropDownList)gvRow.FindControl("DropDownGridItem")).SelectedValue.ToString(), ((TextBox)gvRow.FindControl("TB_TRRemarks")).Text, "CHILD", EnterBy.ToString(), EnterDate.ToString(), LoginUserID.ToString(), myDbGL.GetServerDateTime(), "Payment Detail", "PARENT");
TRCount = TRCount + 1;
}
}
TRTotalAmount = TRTotalAmount + (TRDebit - TRCredit);
}
if (TRTotalAmount != 0) { myDbGL.InsertLedgerDetail(TB_TRCode.Text, TB_TRDate.Text, TB_GLDate.Text, VoucherType, "UN-POST", "UN-POST", CB_Reverse.Checked.ToString(), ReverseDateCheck, "0", DropDownType.SelectedItem.Value, DropDownType.SelectedItem.Value, "-1", 0, 0, 0, TRTotalAmount, myDbGL.ConvertStringToNumber(TB_TRExchangeRate.Text), TRTotalAmount, DropDownCurrency.SelectedItem.Value, "-1", 0, "", "", "", "", "", ChequeBankName, ChequeBranchName, ChequeAccountNo, TB_TRRefNo.Text, DropDownGroup.SelectedItem.Value, DropDownCompany.SelectedItem.Value, "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", TB_Remarks.Text, "TOTAL", EnterBy.ToString(), EnterDate.ToString(), LoginUserID.ToString(), myDbGL.GetServerDateTime(), "Payment Detail", "TOTAL"); }
if (TRTotalAmount != 0) { myDbGL.InsertPaymentMaster(TB_TRCode.Text, TB_TRDate.Text, TB_GLDate.Text, TRTotalAmount, VoucherType, DropDownType.SelectedItem.Value, DropDownType.SelectedItem.Text, TB_Remarks.Text, myDbGL.ConvertStringToNumber(TB_TRExchangeRate.Text), DropDownCurrency.SelectedItem.Value, DropDownGroup.SelectedItem.Value, DropDownCompany.SelectedItem.Value, CB_Reverse.Checked.ToString(), ReverseDateCheck, "UN-POST", "UN-POST", TRCurrentLevel, EnterBy.ToString(), EnterDate.ToString(), LoginUserID.ToString(), myDbGL.GetServerDateTime()); }
myDbGL.InsertUserLog("General Ledger", "Transaction", "Payment Detail", "Update", TB_TRCode.Text, LoginUserID.ToString(), myDbGL.GetUserPCName(), myDbGL.GetUserPCIP(), myDbGL.GetUserPCMAC(), myDbGL.GetServerDateTime(), myDbGL.GetServerDateTime());
Response.Redirect(Request.Url.AbsoluteUri);
}
catch (Exception ex)
{
myDbGL.CatchException(this, ex);
}
答案 0 :(得分:0)
您可以使用OnClientClick
事件处理程序在服务器请求之前添加css类以显示无限进度。
<asp:Button ID="uniqueID" ClientIdMode="Static" OnClientClick="GetData()" ... />
function GetData() {
$('#uniqueID').addClass('loading');
$.ajax(...).then(function() {
//update cell data
$('#uniqueID').removeClass('loading');
});
}
响应结束后,将使用新数据刷新页面元素。
但是为了实现客户端友好的解决方案,您需要使用AJAX来获取数据,因为当使用经典的ASP.NET回发方法时,您的页面将处于重新加载状态。使用ClientIdMode="Static"
在客户端获取控件标识符。