public void FillGrid() { try { dt_ = new DataTable(); dt_ = DBConnection.GetQueryData(" SELECT * FROM v_rptmdn where Mdn_id='" + MDNID + "'"); if (dt_.Rows.Count > 0) { lblbilno.Text = dt_.Rows[0]["Mdn_id"].ToString(); lblmdndat.Text = dt_.Rows[0]["Mdn_dat"].ToString(); lblsalNo.Text = dt_.Rows[0]["MSal_id"].ToString(); lbl_saldat.Text = dt_.Rows[0]["Mdn_SalDat"].ToString(); lbl_intro.Text = dt_.Rows[0]["SubHeadCategoriesName"].ToString(); lbladd.Text = dt_.Rows[0]["Address"].ToString(); lblph.Text = dt_.Rows[0]["PhoneNo"].ToString(); GVSal.DataSource = dt_; GVSal.DataBind(); } } catch (Exception ex) { throw ex; } }
public void FillGrid() { try { dt_ = new DataTable(); dt_ = DBConnection.GetQueryData(" SELECT * FROM v_salrecipt where MSal_id='" + SalID + "'"); if (dt_.Rows.Count > 0) { lbl_intro.Text = dt_.Rows[0]["Customer"].ToString(); lb_preout.Text = dt_.Rows[0]["Outstanding"].ToString(); lblbilno.Text = dt_.Rows[0]["Bill"].ToString(); lblsaldat.Text = dt_.Rows[0]["SalDat"].ToString(); lbladd.Text = dt_.Rows[0]["Address"].ToString(); lblph.Text = dt_.Rows[0]["PhoneNo"].ToString(); lbldisc.Text = dt_.Rows[0]["Dis"].ToString(); lbldiscamt.Text = dt_.Rows[0]["DisAmt"].ToString(); lbl_grrsttl.Text = dt_.Rows[0]["GTtl"].ToString(); lbl_salreturn.Text = dt_.Rows[0]["isreturn"].ToString(); } //For Details DataTable dtdetail_ = new DataTable(); dtdetail_ = DBConnection.GetQueryData(" SELECT * FROM v_saldrecipt where MSal_id='" + SalID + "'"); if (dtdetail_.Rows.Count > 0) { GVSal.DataSource = dtdetail_; GVSal.DataBind(); decimal GTotal = 0; for (int j = 0; j < GVSal.Rows.Count; j++) { Label total = (Label)GVSal.Rows[j].FindControl("lbl_afterdis"); GTotal += Convert.ToDecimal(total.Text); } lb_currnetpay.Text = (Convert.ToDecimal(lbl_grrsttl.Text) - Convert.ToDecimal(lbldiscamt.Text)).ToString(); //dtdetail_.Rows[0]["NetAmount"].ToString(); //GTotal.ToString(); } } catch (Exception ex) { throw ex; } }
private void BindGrid() { string SALID; SALID = Request.QueryString["SalID"]; string query = " select ROW_NUMBER() OVER(ORDER BY tbl_MSal.MSal_id DESC) AS [ID],Msal_sono,tbl_MSal.MSal_id,ProductName,DSal_ItmQty,rat,Amt, customername,saleper, " + " Discount= Amt * (saleper/100), AfterDiscount= Amt - (Amt * (saleper/100)), " + " (Amt - (Amt * (saleper/100))) Total, convert(date, cast(tbl_MSal.CreatedAt as date) ,103) as [CreatedAt] from tbl_MSal " + " inner join tbl_DSal on tbl_MSal.MSal_id = tbl_DSal.MSal_id inner join Products on tbl_DSal.ProductID = Products.ProductID " + " inner join Customers_ on tbl_MSal.CustomerID = Customers_.CustomerID where tbl_MSal.MSal_id = " + SALID + ""; string constr = ConfigurationManager.ConnectionStrings["D"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(query)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); GVSal.DataSource = dt; GVSal.DataBind(); //Calculate Sum and display in Footer Row double total = dt.AsEnumerable().Sum(row => row.Field <double>("Total")); double Qty = dt.AsEnumerable().Sum(row => row.Field <double>("DSal_ItmQty")); GVSal.FooterRow.Cells[5].Text = "Total"; GVSal.FooterRow.Cells[6].HorizontalAlign = HorizontalAlign.Right; GVSal.FooterRow.Cells[6].Text = total.ToString("N2"); GVSal.FooterRow.Cells[1].Text = "Total Qty"; GVSal.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Right; GVSal.FooterRow.Cells[2].Text = Qty.ToString("N2"); } } } } }