selvi subramanian

selvi subramanian

  • NA
  • 799
  • 572.5k

After insert my discount is changed in asp.net

Jun 15 2015 2:58 AM
private void BindListView()
{
string constr = ConfigurationManager.AppSettings["s"].ToString();
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand())
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
cmd.CommandText = "select distinct sectionname,lotno,Productname,mrp from purchase where lotno='" + txtBarcode.Text + "'";
cmd.Connection = con;
// DataTable dt = new DataTable();
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
DataTable products = new DataTable();
if (ViewState["Products"] == null)
{
products.Merge(dt, true);
}
else
{
products = (DataTable)ViewState["Products"];
products.Merge(dt, true);
}
ViewState["Products"] = products;
ddsales.DataSource = products;
ddsales.DataBind();
double total = dt.AsEnumerable().Sum(row => row.Field<double>("mrp"));
ddsales.FooterRow.Cells[3].Text = "Total";
ddsales.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Right;
ddsales.FooterRow.Cells[4].Text = total.ToString("N2");
}
}
}
}
txtBarcode.Text = "";
txtBarcode.Focus();
}
 
 
 
protected void txtdispr_TextChanged(object sender, EventArgs e)
{
if (txtdispr.Text != "")
{
foreach (GridViewRow gvr in this.ddsales.Rows)
{
if (((CheckBox)gvr.FindControl("chkSelect")).Checked == true)
{
string bqno = (gvr.FindControl("lblmrp") as Label).Text;
double dis, mmr, pmr, totdis, nowdis;
dis = int.Parse(txtdispr.Text);
mmr = int.Parse(bqno);
pmr = dis * mmr;
totdis = pmr / 100;
nowdis = mmr - totdis;
(gvr.FindControl("lblmrp") as Label).Text = Convert.ToString(nowdis);
}
txtdispr.Text = "";
break;
}
}
else
{
txtdispr.Focus();
}
}
 
http://s280.photobucket.com/user/celvsubramanian/library/

in this it shows the discount