using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml; using System.Data.SqlClient; using System.Data.SqlTypes; using System.IO; using System.Drawing; public partial class ViewReciept : System.Web.UI.Page { SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connect"].ConnectionString); DataSet ds = new DataSet(); DataTable dt = null; SqlDataAdapter da = null; string query; int row; Label lb; Label lbltotal; Label lblpst; string yy; string payid; Label lblpay; protected void Page_Load(object sender, EventArgs e) { if (Session["MemberId1"] != null) { if (!Page.IsPostBack) { filltable(); fillgrid(); } } else { Response.Redirect("MemberLogin.aspx"); } } void filltable() { query = "SELECT tbl_UserAccount.Id, tbl_UserAccount.FirstName, Payment.PayID,Convert(Nvarchar(20),PaymentDate,105) as PaymentDate, Payment.DId, RCBK_Demand.DId AS Expr1, " + " RCBK_Demand.DDCode,Convert(Nvarchar(20),DemandDate,105) as DemandDate, Payment.EntryBy " + " FROM RCBK_Demand INNER JOIN "+ "Payment ON RCBK_Demand.DId = Payment.DId INNER JOIN "+ "tbl_UserAccount ON Payment.EntryBy = tbl_UserAccount.FirstName where RCBK_Demand.DDCode='D002'"; da = new SqlDataAdapter(query, con); dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { lblDemandDate.Text = dt.Rows[0]["DemandDate"].ToString(); lbldemandId.Text = dt.Rows[0]["DDCode"].ToString(); lblPaymentDate.Text = dt.Rows[0]["PaymentDate"].ToString(); lblID.Text = dt.Rows[0]["FirstName"].ToString(); string pay = dt.Rows[0]["PayID"].ToString(); payid = "P" + "00" + pay; lblRecid.Text = payid; } } void fillgrid() { query = "SELECT RCBK_Demand.DId, RCBK_Member.MemberId, RCBK_Member.M_FirstName, Payment.MemberId AS Expr1, Payment.PayID, Payment.DId AS Expr2, " + " Payment.Dr, Payment.Cr,Convert(Nvarchar(20),PaymentDate,105) as PaymentDate, Payment.Balance, Payment.EntryBy, RCBK_Demand.DDCode,Convert(Nvarchar(20),DemandDate,105) as DemandDate, " + " RCBK_Demand.DueDate, RCBK_Demand.Head, RCBK_Demand.Particulars, RCBK_Demand.Amount, RCBK_Demand.Payed, RCBK_Demand.Status, " + " RCBK_Demand.Balance AS Expr3 " + " FROM RCBK_Member INNER JOIN " + " RCBK_Demand INNER JOIN " + " Payment ON RCBK_Demand.DId = Payment.DId ON RCBK_Member.MemberId = Payment.MemberId where RCBK_Member.MemberId='" + Session["MemberId1"] + "'"; da = new SqlDataAdapter(query, con); dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { ViewState["payment"] = dt; // Panel1.Visible = true; GridView1.DataSource = dt; GridView1.DataBind(); } else { // Panel1.Visible = false; lblMsg.ForeColor = Color.Red; lblMsg.Visible = true; lblMsg.Text = "No records found"; } } int r = 0; protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (ViewState["payment"] != null) { int a = 0; DataTable dtCurrentTable = (DataTable)ViewState["payment"]; /// LinkButton lb = (LinkButton)e.Row.FindControl("lbkPay"); lblpay = (Label)e.Row.FindControl("lblpay"); Label lblps = (Label)e.Row.FindControl("lblps"); //lblPar lblDDID if (dtCurrentTable.Rows[r].ItemArray[7].ToString() != "") { //----- for round up values -------------------- lblpay.Text = dtCurrentTable.Rows[r].ItemArray[7].ToString(); // lbltotal.Text = dtCurrentTable.Rows[r].ItemArray[7].ToString(); // lbldb.Text = dtCurrentTable.Rows[r].ItemArray[7].ToString(); double u = Convert.ToDouble(lblpay.Text); // double cr = Convert.ToDouble(lbltotal.Text); double ui = Math.Round(u, 3); // double crp = Math.Round(cr, 3); lblpay.Text = u.ToString(); // lbltotal.Text = crp.ToString(); string c = lblpay.Text; // string b = lbltotal.Text; if (dtCurrentTable.Rows[r].ItemArray[7].ToString() != "0.0000") { //lblpay.Visible = false; //if (!b.Contains(".")) //{ // if (lbltotal.Text == "0") // { // lbltotal.Text = "-"; // } //} } else { //lbltotal.Text = b + ".00"; //lblpar.Text = "Pay against Demand"; } if (dtCurrentTable.Rows[r].ItemArray[13].ToString() != "0.0000") { if (!c.Contains(".")) { if (lblpay.Text == "0") { lblpay.Visible = false; lblps.Visible = false; } lblpay.Text = c + ".00"; string strDatefrm = lblpay.Text; string[] strDate = new string[12]; strDate = strDatefrm.Split('.'); lblps.Text = strDate[1]; if (lblpay.Text != "0") { yy=lblpay.Text; } } } else { // lblpar.Text = "Demand"; } } a = r; r++; if (dtCurrentTable.Rows.Count - 1 == a) { r = 0; } } } if (e.Row.RowType == DataControlRowType.Footer) { lbltotal = (Label)e.Row.FindControl("lblTotal"); lblpst = (Label)e.Row.FindControl("lblpst"); //lbltotal.Text = yy; if (lblpay.Text != "") { if (lblpay.Text != "") { float payment = float.Parse(lblpay.Text); lbltotal.Text += payment; lbltotal.Text = lbltotal.Text + ".00"; lblpst.Text = lbltotal.Text; } if (lblpst.Text != "") { string strDatefrm = lblpst.Text; string[] strDate = new string[12]; strDate = strDatefrm.Split('.'); lblpst.Text = strDate[1]; } } } } }