Guest User

Untitled

a guest
Nov 15th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. string t_qty = "";
  2.  
  3. SqlCommand cmd1 = new SqlCommand("select QTY from STOCK_ARRIVE where BARCODE = @barcode", d.con);
  4. cmd1.Parameters.AddWithValue("@barcode", txt_barcode.Text);
  5. d.con.Open();
  6. SqlDataReader dr = cmd1.ExecuteReader();
  7.  
  8.  
  9. while (dr.Read())
  10. {
  11. t_qty = dr["QTY"].ToString();
  12.  
  13. }
  14.  
  15.  
  16. d.con.Close();
  17.  
  18.  
  19. try
  20. {
  21.  
  22. int less = 0;
  23. less = int.Parse(t_qty) - int.Parse(txt_qty.Text);
  24.  
  25. SqlCommand cmd2 = new SqlCommand("update STOCK_ARRIVE set QTY=@pq where BARCODE=@barcode AND S_VC=@vc", d.con);
  26. cmd2.Parameters.AddWithValue("@pq", less);
  27.  
  28. cmd2.Parameters.AddWithValue("@barcode", txt_barcode.Text);
  29. cmd2.Parameters.AddWithValue("@vc", txt_vc.Text);
  30. d.con.Open();
  31. cmd2.ExecuteNonQuery();
  32. d.con.Close();
  33.  
  34. }
  35. catch (Exception ex)
  36. {
  37.  
  38. Response.Write(ex);
  39. }
  40.  
  41.  
  42. Response.Write("<script>alert('Data has been saved')</script>");
Add Comment
Please, Sign In to add comment