protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { string strMsg = string.Empty; if (e.CommandName == "cmdedit") { Response.Redirect("ChlnAmntPayment.aspx?q=" + e.CommandArgument, true); } if (e.CommandName == "cmddelete") { Int64 UserIdno = Convert.ToInt64(Session["UserIdno"]); challanAmntpaymentDAL obj = new challanAmntpaymentDAL(); Int32 intValue = obj.Delete(Convert.ToInt32(e.CommandArgument), UserIdno, ApplicationFunction.ConnectionString()); obj = null; if (intValue > 0) { this.BindGrid(); strMsg = "Record deleted successfully."; txtRcptNo.Focus(); } else { if (intValue == -1) { strMsg = "Record can not be deleted. It is in use."; } else { strMsg = "Record not deleted."; } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); } }
//private void bindsender() //{ // BindDropdownDAL obj = new BindDropdownDAL(); // var senderLst = obj.BindSender(); // ddlSender.DataSource = senderLst; // ddlSender.DataTextField = "Acnt_Name"; // ddlSender.DataValueField = "Acnt_Idno"; // ddlSender.DataBind(); // ddlSender.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0")); //} public void Countall() { challanAmntpaymentDAL obj = new challanAmntpaymentDAL(); Int64 count = obj.Countall(); if (count > 0) { lblTotalRecord.Text = "T. Record (s):" + count; } }
private void BindGrid() { challanAmntpaymentDAL obj = new challanAmntpaymentDAL(); DateTime?dtfrom = null; DateTime?dtto = null; Int64 InvoiceNo = Convert.ToInt64(Convert.ToString(txtRcptNo.Text) == "" ? 0 : Convert.ToInt64(txtRcptNo.Text)); if (string.IsNullOrEmpty(Convert.ToString(txtGrDatefrom.Text)) == false) { dtfrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtGrDatefrom.Text)); } if (string.IsNullOrEmpty(Convert.ToString(txtGrDatefrom.Text)) == false) { dtto = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtGrDateto.Text)); } var lstGridData = obj.search(Convert.ToInt32(ddldateRange.SelectedValue), InvoiceNo, dtfrom, dtto, Convert.ToInt32(drpCityFrom.SelectedValue), Convert.ToInt32(hfPartyNoId.Value == "" ? "0" : hfPartyNoId.Value)); obj = null; if (lstGridData != null && lstGridData.Count > 0) { DataTable dt = new DataTable(); dt.Columns.Add("SrNo", typeof(string)); dt.Columns.Add("Payment No", typeof(string)); dt.Columns.Add("Date", typeof(string)); dt.Columns.Add("Party Name", typeof(string)); dt.Columns.Add("Receipt Name", typeof(string)); dt.Columns.Add("Receipt No", typeof(string)); dt.Columns.Add("Receipt Date", typeof(string)); dt.Columns.Add("From City", typeof(string)); dt.Columns.Add("Net Amount", typeof(string)); dt.AcceptChanges(); double TNet = 0; for (int i = 0; i < lstGridData.Count; i++) { DataRow dr = dt.NewRow(); dr["SrNo"] = Convert.ToString(i + 1); dr["Payment No"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "Rcpt_No")); dr["Date"] = Convert.ToDateTime(DataBinder.Eval(lstGridData[i], "Rcpt_date")).ToString("dd-MM-yyyy"); dr["Party Name"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "Acnt_Name")); dr["From City"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "FromCity")); dr["Net Amount"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "Net_Amnt")); dr["Receipt Name"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "ReciptName")); dr["Receipt No"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "Inst_No")); dr["Receipt Date"] = string.IsNullOrEmpty(Convert.ToString(DataBinder.Eval(lstGridData[i], "Inst_Dt"))) ? "" : Convert.ToDateTime(DataBinder.Eval(lstGridData[i], "Inst_Dt")).ToString("dd-MM-yyyy"); dt.Rows.Add(dr); TNet += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Net_Amnt")); if (i == lstGridData.Count - 1) { DataRow drr = dt.NewRow(); drr["From City"] = "Total"; drr["Net Amount"] = (TNet).ToString("N2"); dt.Rows.Add(drr); } } dt.AcceptChanges(); if (dt != null && dt.Rows.Count > 0) { ViewState["Dt"] = dt; } grdMain.DataSource = lstGridData; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count; Double TotalNetAmount = 0; for (int i = 0; i < lstGridData.Count; i++) { TotalNetAmount += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Net_Amnt")); } lblNetTotalAmount.Text = TotalNetAmount.ToString("N2"); int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1; int lastRowOnPage = startRowOnPage + grdMain.Rows.Count - 1; lblcontant.Text = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString(); lblcontant.Visible = true; divpaging.Visible = true; imgBtnExcel.Visible = true; } else { grdMain.DataSource = null; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): 0 "; lblcontant.Visible = false; divpaging.Visible = false; imgBtnExcel.Visible = false; } }