public string InsertSanPham(EC_SANPHAM et) { string sql = "ThemSP"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@tensp", et.TenSP); cmd.Parameters.AddWithValue("@malh", et.MaLH); cmd.Parameters.AddWithValue("@soluong", et.SoLuong); cmd.Parameters.AddWithValue("@loinhuan", et.LoiNhuan); cmd.Parameters.AddWithValue("@gianhap", et.GiaNhap); cmd.Parameters.AddWithValue("@mota", et.MoTa); cmd.Parameters.AddWithValue("@nsx", et.NSX); cmd.Parameters.AddWithValue("@hinhanh", et.HinhAnh); DataTable dt = new DataTable(); SqlDataAdapter ad = new SqlDataAdapter(cmd); ad.Fill(dt); string ma = dt.Rows[0].ItemArray[0].ToString(); cmd.Dispose(); con.Close(); return(ma); }
public void DeleteSanPham(EC_SANPHAM et) { string sql = "XoaSP"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@masp", et.MaSP); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public void UpdateSoLuong(EC_SANPHAM et) { string sql = "SuaSL"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@masp", et.MaSP); cmd.Parameters.AddWithValue("@sl", et.SoLuong); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public void DeleteSanPham(EC_SANPHAM sp) { string sql = "XoaSP"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@masp", sp.MaSP); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public void UpdateSanPham(EC_SANPHAM et) { string sql = "SuaSP"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@masp", et.MaSP); cmd.Parameters.AddWithValue("@tensp", et.TenSP); cmd.Parameters.AddWithValue("@malh", et.MaLH); cmd.Parameters.AddWithValue("@soluong", et.SoLuong); cmd.Parameters.AddWithValue("@loinhuan", et.LoiNhuan); cmd.Parameters.AddWithValue("@gianhap", et.GiaNhap); cmd.Parameters.AddWithValue("@mota", et.MoTa); cmd.Parameters.AddWithValue("@nsx", et.NSX); cmd.Parameters.AddWithValue("@hinhanh", et.HinhAnh); cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }
public string InsertSanPham(EC_SANPHAM et) { string sql = "ThemSP"; SqlConnection con = new SqlConnection(KetNoiDB.getconnect()); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@tensp", et.TenSP); cmd.Parameters.AddWithValue("@malh", et.MaLH); cmd.Parameters.AddWithValue("@soluong", et.SoLuong); cmd.Parameters.AddWithValue("@loinhuan", et.LoiNhuan); cmd.Parameters.AddWithValue("@gianhap", et.GiaNhap); cmd.Parameters.AddWithValue("@mota", et.MoTa); cmd.Parameters.AddWithValue("@nsx", et.NSX); cmd.Parameters.AddWithValue("@hinhanh", et.HinhAnh); DataTable dt = new DataTable(); SqlDataAdapter ad = new SqlDataAdapter(cmd); ad.Fill(dt); string ma = dt.Rows[0].ItemArray[0].ToString(); cmd.Dispose(); con.Close(); return ma; }