private void get_sal(string Fdat, string Ldat) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "select * from v_rptSal where Saldat between '" + Fdat + "' and '" + Ldat + "' and CompanyId = '" + Session["CompanyID"] + "' and BranchId= '" + Session["BranchID"] + "'"; //cmd.CommandText = "select * from v_rptDSal where Saldat between '" + Fdat + "' and '" + Ldat + "'"; cmd.Connection = con; // con.Open(); DataTable dtsal = new DataTable(); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(dtsal); if (dtsal.Rows.Count > 0) { GV_SAL.DataSource = dtsal; GV_SAL.DataBind(); //Get Total double GTotal = 0; double QGTotal = 0; // Total for (int j = 0; j < GV_SAL.Rows.Count; j++) { Label total = (Label)GV_SAL.Rows[j].FindControl("lbl_GTtl"); GTotal += Convert.ToDouble(total.Text); } //Quantity for (int j = 0; j < GV_SAL.Rows.Count; j++) { Label totalqty = (Label)GV_SAL.Rows[j].FindControl("lbl_Qty"); QGTotal += Convert.ToDouble(totalqty.Text); } ttl_qty.Text = QGTotal.ToString(); lbl_ttl.Text = GTotal.ToString(); } con.Close(); } }
private void get_sal(string dsrdat) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "select * from v_dsr where billdat = '" + dsrdat + "'"; cmd.Connection = con; con.Open(); DataTable dtsal = new DataTable(); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(dtsal); if (dtsal.Rows.Count > 0) { GV_SAL.DataSource = dtsal; GV_SAL.DataBind(); //Get Total double GTotal = 0; double QGTotal = 0; // Total for (int j = 0; j < GV_SAL.Rows.Count; j++) { Label total = (Label)GV_SAL.Rows[j].FindControl("lbl_amt"); GTotal += Convert.ToDouble(total.Text); } //Quantity for (int j = 0; j < GV_SAL.Rows.Count; j++) { Label totalqty = (Label)GV_SAL.Rows[j].FindControl("lbl_Qty"); QGTotal += Convert.ToDouble(totalqty.Text); } ttl_qty.Text = QGTotal.ToString(); lbl_ttl.Text = GTotal.ToString(); } con.Close(); } }