public static bool deleteSP(EC_SanPham sp)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "SanPham_Delete";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MASP", SqlDbType.NVarChar).Value = sp.MaSP;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            conn.Close();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
        public static bool updateNSX(EC_NhaSanXuat nsx)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "NhaSanXuat_Update";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MANSX", SqlDbType.NVarChar).Value  = nsx.MANSX;
            cmd.Parameters.Add("@TENNSX", SqlDbType.NVarChar).Value = nsx.TENNSX;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
예제 #3
0
        public static bool updateHDB(EC_HDB cthd)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "HoaDonBan_Update";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MAHDB", SqlDbType.NVarChar).Value = cthd.MaHDB;
            cmd.Parameters.Add("@NGAYBAN", SqlDbType.Date).Value   = cthd.NgayBan;
            cmd.Parameters.Add("@MANV", SqlDbType.NVarChar).Value  = cthd.MaNV;
            cmd.Parameters.Add("@MAKH", SqlDbType.NVarChar).Value  = cthd.MaKH;
            cmd.Parameters.Add("@TONGTIEN", SqlDbType.Float).Value = cthd.TongTien;


            cmd.ExecuteNonQuery();
            cmd.Dispose();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
예제 #4
0
        public static bool insertHDN(EC_HDN cthd)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "HoaDonNhap_Insert";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MAHDN", SqlDbType.NVarChar).Value = cthd.MaHDN;
            cmd.Parameters.Add("@NGAYNHAP", SqlDbType.Date).Value  = cthd.NgayNhap;
            cmd.Parameters.Add("@MANV", SqlDbType.NVarChar).Value  = cthd.MaNV;
            cmd.Parameters.Add("@MANCC", SqlDbType.NVarChar).Value = cthd.MaNCC;
            cmd.Parameters.Add("@TONGTIEN", SqlDbType.Float).Value = cthd.TongTien;

            cmd.ExecuteNonQuery();
            cmd.Dispose();

            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
        public static bool updateKH(EC_KhachHang khach)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "KhachHang_Update";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MAKH", SqlDbType.NVarChar).Value      = khach.MaKH;
            cmd.Parameters.Add("@TENKH", SqlDbType.NVarChar).Value     = khach.TenKH;
            cmd.Parameters.Add("@DIENTHOAI", SqlDbType.NVarChar).Value = khach.DienThoai;
            cmd.Parameters.Add("@DIACHI", SqlDbType.NVarChar).Value    = khach.DiaChi;
            cmd.Parameters.Add("@EMAIL", SqlDbType.NVarChar).Value     = khach.Email;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
        public static bool updateNV(EC_NhanVien nv)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "NhanVien_Update";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MANV", SqlDbType.NVarChar).Value      = nv.MaNV;
            cmd.Parameters.Add("@TENNV", SqlDbType.NVarChar).Value     = nv.TenNV;
            cmd.Parameters.Add("@NGAYSINH", SqlDbType.NVarChar).Value  = nv.NgaySinh;
            cmd.Parameters.Add("@GIOITINH", SqlDbType.NVarChar).Value  = nv.GioiTinh;
            cmd.Parameters.Add("@DIENTHOAI", SqlDbType.NVarChar).Value = nv.DienThoai;
            cmd.Parameters.Add("@DIACHI", SqlDbType.NVarChar).Value    = nv.DiaChi;
            cmd.Parameters.Add("@EMAIL", SqlDbType.NVarChar).Value     = nv.Email;
            cmd.Parameters.Add("@CHUCVU", SqlDbType.NVarChar).Value    = nv.ChucVu;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
예제 #7
0
        public static bool updateBaoHanh(EC_BaoHanh bh)
        {
            conn = GetData.KetNoi();
            string truyvan = "BaoHanh_Update";

            cmd             = new SqlCommand(truyvan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MABH", SqlDbType.NVarChar).Value   = bh.MaBH;
            cmd.Parameters.Add("@MAKH", SqlDbType.NVarChar).Value   = bh.MaKH;
            cmd.Parameters.Add("@MASP", SqlDbType.NVarChar).Value   = bh.MaSP;
            cmd.Parameters.Add("@IMEI", SqlDbType.NVarChar).Value   = bh.IMEI;
            cmd.Parameters.Add("@NGAYBD", SqlDbType.NVarChar).Value = bh.NgayBD;
            cmd.Parameters.Add("@NGAYKT", SqlDbType.NVarChar).Value = bh.NgayKT;
            cmd.Parameters.Add("@LOI", SqlDbType.NVarChar).Value    = bh.Loi;
            cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar).Value = bh.GhiChu;

            cmd.ExecuteNonQuery();
            cmd.Dispose();

            try
            {
                GetData.ThucThiTruyVanNonQuery(truyvan, conn);
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
        public static bool updateTK(EC_TaiKhoan tk)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "TaiKhoan_Update";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@TaiKhoan", SqlDbType.NVarChar).Value = tk.TaiKhoan;
            cmd.Parameters.Add("@MatKhau", SqlDbType.NVarChar).Value  = tk.MatKhau;
            cmd.Parameters.Add("@Quyen", SqlDbType.NVarChar).Value    = tk.Quyen;
            cmd.Parameters.Add("@MaNV", SqlDbType.NVarChar).Value     = tk.MaNV;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
        public static bool updateNCC(EC_NhaCungCap ncc)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "NhaCungCap_Update";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MANCC", SqlDbType.NVarChar).Value     = ncc.MaNCC;
            cmd.Parameters.Add("@TENNCC", SqlDbType.NVarChar).Value    = ncc.TenNCC;
            cmd.Parameters.Add("@DIENTHOAI", SqlDbType.NVarChar).Value = ncc.DienThoai;
            cmd.Parameters.Add("@DIACHI", SqlDbType.NVarChar).Value    = ncc.DiaChi;
            cmd.Parameters.Add("@EMAIL", SqlDbType.NVarChar).Value     = ncc.Email;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
예제 #10
0
        public static bool updateCTHDN(EC_CTHDN cthd)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "CTHDN_Update";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@MAHDN", SqlDbType.NVarChar).Value  = cthd.MaHDN;
            cmd.Parameters.Add("@MASP", SqlDbType.NVarChar).Value   = cthd.MaSP;
            cmd.Parameters.Add("@SOLUONG", SqlDbType.Int).Value     = cthd.SoLuong;
            cmd.Parameters.Add("@DONGIA", SqlDbType.Float).Value    = cthd.DonGia;
            cmd.Parameters.Add("@THANHTIEN", SqlDbType.Float).Value = cthd.ThanhTien;

            cmd.ExecuteNonQuery();
            cmd.Dispose();
            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }
        public static DataTable getAll()
        {
            conn = GetData.KetNoi();
            SqlDataAdapter adapter = new SqlDataAdapter("SanPham_SelectAll", conn);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            adapter.Dispose();
            return(table);
        }
        public static DataTable tkTenTK(string key)
        {
            conn            = GetData.KetNoi();
            cmd             = new SqlCommand("TaiKhoan_GetByID", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@TAIKHOAN", SqlDbType.NVarChar).Value = key;
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            cmd.Dispose();
            adapter.Dispose();
            return(table);
        }
예제 #13
0
        public static DataTable getAllByIDMaHDN(String key)
        {
            conn            = GetData.KetNoi();
            cmd             = new SqlCommand("CTHDN_GetByIDMaHDN", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MAHDN", SqlDbType.NVarChar).Value = key;
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            cmd.Dispose();
            adapter.Dispose();
            return(table);
        }
        public static bool insertSanPham(EC_SanPham sp)
        {
            conn = GetData.KetNoi();
            string sTruyVan = "SanPham_Insert";

            cmd             = new SqlCommand(sTruyVan, conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MASP", SqlDbType.NVarChar).Value      = sp.MaSP;
            cmd.Parameters.Add("@TENSP", SqlDbType.NVarChar).Value     = sp.TenSP;
            cmd.Parameters.Add("@SOLUONG", SqlDbType.Int).Value        = sp.SoLuong;
            cmd.Parameters.Add("@DONGIABAN", SqlDbType.Float).Value    = sp.DonGiaBan;
            cmd.Parameters.Add("@DONVITINH", SqlDbType.NVarChar).Value = sp.DonViTinh;
            //cmd.Parameters.Add("@HINHANH", SqlDbType.NVarChar).Value = sp.HinhAnh;
            cmd.Parameters.Add("@MANSX", SqlDbType.NVarChar).Value      = sp.MaNSX;
            cmd.Parameters.Add("@HEDIEUHANH", SqlDbType.NVarChar).Value = sp.HeDieuHanh;
            cmd.Parameters.Add("@CPU", SqlDbType.NVarChar).Value        = sp.Cpu;
            cmd.Parameters.Add("@RAM", SqlDbType.NVarChar).Value        = sp.Ram;
            cmd.Parameters.Add("@PIN", SqlDbType.NVarChar).Value        = sp.Pin;
            cmd.Parameters.Add("@KETNOI", SqlDbType.NVarChar).Value     = sp.KetNoi;
            cmd.Parameters.Add("@BONHO", SqlDbType.NVarChar).Value      = sp.BoNho;
            cmd.Parameters.Add("@CAMERA", SqlDbType.NVarChar).Value     = sp.Camera;
            cmd.ExecuteNonQuery();
            cmd.Dispose();

            try
            {
                GetData.ThucThiTruyVanNonQuery(sTruyVan, conn);
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(true);
            }
            catch (Exception ex)
            {
                //Đóng kết nối
                GetData.DongKetNoi(conn);
                return(false);
            }
        }