public void themoi(EC_tb_Sanpham lg) { if (!spsql.Equals(lg.MASP)) { spsql.themmoiHang(lg); } else { MessageBox.Show("Mã này đã tồn tại,xin chọn Mã khác", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void themmoiHang(EC_tb_Sanpham hang) { SqlConnection con = cn.getcon(); try { con.Open(); string sql = @"INSERT INTO tb_Sanpham (masp, tensp, maloai, gianhap, giaban, soluong, macongdung, hinhanh) VALUES (N'" + hang.MASP + "',N'" + hang.TENSP + "',N'" + hang.MALOAI + "',N'" + hang.GIANHAP + "',N'" + hang.GIABAN + "',N'" + hang.SOLUONG + "',N'" + hang.MACONGDUNG + "',@hinhanh)"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.Add(new SqlParameter("@hinhanh", (object)hang.HINHANH)); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } }
public void suaHang(EC_tb_Sanpham hang) { SqlConnection con = cn.getcon(); try { con.Open(); string sql = @"UPDATE tb_Sanpham SET tensp =N'" + hang.TENSP + "', maloai =N'" + hang.MALOAI + "', giaban =N'" + hang.GIABAN + "', soluong =N'" + hang.SOLUONG + "', macongdung =N'" + hang.MACONGDUNG + "',hinhanh =@hinhanh where masp=N'" + hang.MASP + "'"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.Add(new SqlParameter("@hinhanh", (object)hang.HINHANH)); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } }
public void xoa(EC_tb_Sanpham lg) { spsql.xoaHang(lg); }
public void sua(EC_tb_Sanpham lg) { spsql.suaHang(lg); }
public void xoaHang(EC_tb_Sanpham hang) { cn.ExcuteNonQuery("DELETE FROM [tb_Sanpham] WHERE masp=N'" + hang.MASP + "'"); }