Beispiel #1
0
        public bool ThemSanPham(clsSanPham_DTO sanPham)
        {
            string strMaSP = "SP" + (ThaoTacDuLieu.DemSoDongCuaBang("SanPham") + 1);
            string query   = string.Format("insert into SanPham values('{0}',N'{1}','{2}','{3}','{4}','{5}',N'{6}','{7}','{8}','{9}','{10}','{11}',N'{12}','{13}')", strMaSP, sanPham.TenSanPham, sanPham.Hinh, sanPham.GiaMua, sanPham.GiaBan, sanPham.KhuyenMai, sanPham.MoTa, sanPham.BaoHanh, sanPham.SoLuong, sanPham.DonViTinh, sanPham.MaLoaiSanPham, sanPham.MaHangSanXuat, sanPham.GhiChu, 1);

            return(ThaoTacDuLieu.ThucThi(query));
        }
Beispiel #2
0
        public bool ThemNhanVien(clsNhanVien_DTO nhanvien)
        {
            string MaNV  = "NV" + (ThaoTacDuLieu.DemSoDongCuaBang("NhanVien") + 1);
            string query = string.Format("insert into NhanVien values('{0}',N'{1}','{2}','{3}','{4}',N'{5}','{6}','{7}','{8}','{9}','{10}','{11}')", MaNV, nhanvien.TenNV, nhanvien.TenDangNhap, nhanvien.MatKhau, nhanvien.Hinh, nhanvien.DiaChi, nhanvien.CMND, nhanvien.SDT, nhanvien.Email, nhanvien.Quyen, "", 1);

            return(ThaoTacDuLieu.ThucThi(query));
        }
        public bool ThemLoai(clsLoai_DTO loai)
        {
            string strMaLoai = "LSP" + (ThaoTacDuLieu.DemSoDongCuaBang("LoaiSanPham") + 1);
            string query     = string.Format("insert into LoaiSanPham values('{0}',N'{1}',N'{2}','{3}')", strMaLoai, loai.TenLoaiSanPham, loai.GhiChu, 1);

            return(ThaoTacDuLieu.ThucThi(query));
        }
Beispiel #4
0
        public bool ThemHSX(clsHangSanXuat_DTO HSX)
        {
            string strMaHSX = "HSX" + (ThaoTacDuLieu.DemSoDongCuaBang("HangSanXuat") + 1);
            string query    = string.Format("insert into HangSanXuat values('{0}',N'{1}',N'{2}','{3}')", strMaHSX, HSX.TenHangSanXuat, HSX.GhiChu, 1);

            return(ThaoTacDuLieu.ThucThi(query));
        }
        public string TaoPhieuNhap(clsPhieuNhap_DTO phieuNhap)
        {
            string strMaPhieu = "PN" + (ThaoTacDuLieu.DemSoDongCuaBang("PhieuNhap") + 1);
            string query      = string.Format("insert into PhieuNhap values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',1,1)", strMaPhieu, phieuNhap.MaNhaCungCap, phieuNhap.TongTien, phieuNhap.TienNo, phieuNhap.ChietKhau, phieuNhap.Thue, phieuNhap.NgayLap, phieuNhap.MaNVLap, phieuNhap.GhiChu);

            ThaoTacDuLieu.ThucThi(query);
            return(strMaPhieu);
        }
        public string ThemBaoHanh(clsBaoHanh_DTO baoHanh)
        {
            string strMaBH = "BH" + (ThaoTacDuLieu.DemSoDongCuaBang("BaoHanh") + 1);
            string query   = string.Format("insert into BaoHanh values('{0}','{1}','{2}','{3}',1)", strMaBH, baoHanh.MaKhachHang, baoHanh.MaNhanVien, baoHanh.NgayBaoHanh);

            ThaoTacDuLieu.ThucThi(query);
            return(strMaBH);
        }
Beispiel #7
0
        public string ThemNCC(clsNhaCungCap_DTO NCC)
        {
            string strMaNCC = "NCC" + (ThaoTacDuLieu.DemSoDongCuaBang("NhaCungCap") + 1);
            string query    = string.Format("insert into NhaCungCap values('{0}',N'{1}',N'{2}',N'{3}',N'{4}',1)", strMaNCC, NCC.TenNhaCungCap, NCC.DiaChi, NCC.SoDT, NCC.GhiChu);

            ThaoTacDuLieu.ThucThi(query);
            return(strMaNCC);
        }
Beispiel #8
0
 public void ThemSoSerial(string strMaSP, int iSL, string strMaPhieu)
 {
     for (int i = 0; i < iSL; i++)
     {
         string strMaSR     = "SER" + (ThaoTacDuLieu.DemSoDongCuaBang("Serial") + 1);
         string strSoSerial = PhatSinhSerial();
         string query       = string.Format("insert into Serial values('{0}','{1}',NULL,'{2}',NULL,NULL,'{3}',1)", strMaSR, strSoSerial, strMaSP, strMaPhieu);
         ThaoTacDuLieu.ThucThi(query);
     }
 }
Beispiel #9
0
        public string ThemKhachHang(clsKhachHang_DTO khachHang) // thêm và lấy id kh về để thêm vào hoá đơn
        {
            string        strMaKH = "KH" + (ThaoTacDuLieu.DemSoDongCuaBang("KhachHang") + 1);
            SqlConnection conn    = ThaoTacDuLieu.TaoVaMoKetNoi();
            string        query   = string.Format("insert into KhachHang values (N'{0}',N'{1}',N'{2}',N'{3}',N'{4}',N'{5}','{6}')", strMaKH, khachHang.TenKhachHang, khachHang.CMND, khachHang.SoDT, khachHang.DiaChi, khachHang.GhiChu, 1);
            SqlCommand    cmd     = new SqlCommand(query, conn);

            cmd.ExecuteNonQuery();
            ThaoTacDuLieu.DongKetNoi(conn);
            return(strMaKH);
        }
Beispiel #10
0
        public string TaoPhieuXuat(clsPhieuXuat_DTO phieuXuat)
        {
            int           iResult        = 0;
            SqlConnection conn           = ThaoTacDuLieu.TaoVaMoKetNoi();
            string        strMaPhieu     = "PX" + (ThaoTacDuLieu.DemSoDongCuaBang("PhieuXuat") + 1); // Tạo mã mới
            string        sqlInsertPhieu = string.Format("insert into PhieuXuat values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',1)", strMaPhieu, phieuXuat.MaKhachHang, phieuXuat.TongTien, phieuXuat.ChietKhau, phieuXuat.Thue, phieuXuat.NgayLap, phieuXuat.MaNVLap, phieuXuat.GhiChu, phieuXuat.Loai);
            SqlCommand    cmd            = new SqlCommand(sqlInsertPhieu, conn);

            iResult = cmd.ExecuteNonQuery();
            ThaoTacDuLieu.DongKetNoi(conn);
            return(strMaPhieu);
        }
Beispiel #11
0
        public bool ThemSoLuongSP(string strMaSP, int SL)
        {
            string queryUpdateSP = string.Format("update SanPham set SoLuong={1} where MaSanPham='{0}'", strMaSP, SL);

            if (ThaoTacDuLieu.ThucThi(queryUpdateSP))
            {
                int SoDong = 0;
                for (int i = 0; i < SL; i++)
                {
                    string SoSR = TienIch.GenerateSerial(12);
                    SoDong = ThaoTacDuLieu.DemSoDongCuaBang("Serial");
                    string MaSR = "SER" + (SoDong + 1);
                    ThaoTacDuLieu.ThucThi(string.Format("insert into Serial values('{0}','{1}',NULL,'{2}',NULL,{3})", MaSR, SoSR, strMaSP, 1));
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }