public void ThemSanPham(string masp, string tensp, float dongia, string maquicach, string maloai) { using (SqlCommand cmd = new SqlCommand("SP_THEMSANPHAM")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MASP", SqlDbType.Char).Value = masp; cmd.Parameters.Add("@TENSP", SqlDbType.Char).Value = tensp; cmd.Parameters.Add("@DONGIA", SqlDbType.Float).Value = dongia; cmd.Parameters.Add("@MAQUICACH", SqlDbType.Char).Value = maquicach; cmd.Parameters.Add("@MALOAI", SqlDbType.Char).Value = maloai; try { CDATABASE.ThucThiLenh(cmd); DevExpress.XtraEditors.XtraMessageBox.Show("Thêm sản phẩm thành công!", "Thông Báo!"); } catch (Exception ex) { DevExpress.XtraEditors.XtraMessageBox.Show("Lỗi!" + ex.Message, "Thông báo!"); } } }
//Lay ma qui cach tu ten qui cach public string LayMaQuiCachTuTenQuiCach(string ten) { dt = CDATABASE.ExecuteBang("SELECT MAQUICACH FROM QUICACH WHERE QUICACH='" + ten + "'"); s = dt.Rows[0]["MAQUICACH"].ToString(); return(s); }
//Lay qui cach public DataTable LayQuiCach() { return(CDATABASE.ExecuteBang("SELECT * FROM QUICACH")); }
public DataTable HienThiSPTheoLoaiSP(string tenloai) { return(CDATABASE.ExecuteBang("SELECT MASP, TENSP, DONGIA, QUICACH FROM SANPHAM A, LOAISANPHAM B, QUICACH C WHERE A.MALOAI=B.MALOAI AND A.MAQUICACH=C.MAQUICACH AND B.TENLOAI=N'" + tenloai + "'")); }
//CDATABASE db = new CDATABASE(); public DataTable LaySP() { return(CDATABASE.ExecuteBang("SELECT A.MASP, TENSP, MOTASP, DONGIA, TENLOAI, QUICACH FROM SANPHAM A, LOAISANPHAM B, QUICACH C WHERE A.MALOAI=B.MALOAI AND A.MAQUICACH=C.MAQUICACH")); }
//Lay ma loai san pham tu ten loai san pham public string LayMaLoaiTuTenLoai(string ten) { dt = CDATABASE.ExecuteBang("SELECT MALOAI FROM LOAISANPHAM WHERE TENLOAI=N'" + ten + "'"); s = dt.Rows[0]["MALOAI"].ToString(); return(s); }
//Lay danh sach loai san pham public DataTable LayLoaiSP() { return(CDATABASE.ExecuteBang("SELECT * FROM LOAISANPHAM")); }