Exemplo n.º 1
0
        static Common()
        {
            server0   = "LAPTOP-U7HEJ86K";
            database0 = "QLVT";
            userid0   = "QLVT_HTKN";
            password0 = "123";

            LoaiHangDataTable    = new QLVTDataSet.LoaiHangDataTable();
            NhanVienDataTable    = new QLVTDataSet.NhanVienDataTable();
            NhaCungCapDataTable  = new QLVTDataSet.NhaCungCapDataTable();
            MatHangDataTable     = new QLVTDataSet.MatHangDataTable();
            CTDatHangDataTable   = new QLVTDataSet.CTDatHangDataTable();
            KhoDataTable         = new QLVTDataSet.KhoDataTable();
            KhachHangDataTable   = new QLVTDataSet.KhachHangDataTable();
            CTHoaDonDataTable    = new QLVTDataSet.CTHoaDonDataTable();
            PhieuNhapDataTable   = new QLVTDataSet.PhieuNhapDataTable();
            CTPhieuNhapDataTable = new QLVTDataSet.CTPhieuNhapDataTable();

            NhanVienTableAdapter = new QLVTDataSetTableAdapters.NhanVienTableAdapter();
            NhanVienTableAdapter.Adapter.InsertCommand.CommandText = "INSERT INTO NhanVien (Ten,Ho,Phai,DiaChi,SoDienThoai,TrangThai,NgaySinh,ChiNhanhId)"
                                                                     + "VALUES(@Ten,@Ho,@Phai,@DiaChi,@SoDienThoai,@TrangThai,@NgaySinh,@ChiNhanhId)";

            KhoTableAdapter = new QLVTDataSetTableAdapters.KhoTableAdapter();
            KhoTableAdapter.Adapter.InsertCommand.CommandText =
                "IF(@KhoId < 0) INSERT INTO Kho (Ten,ViTri,ChiNhanhId) VALUES(@Ten,@ViTri,@ChiNhanhId) "
                + "ELSE INSERT INTO Kho (KhoId,Ten,ViTri,ChiNhanhId) VALUES(@KhoId,@Ten,@ViTri,@ChiNhanhId)";

            KhachHangTableAdapter = new QLVTDataSetTableAdapters.KhachHangTableAdapter();
            KhachHangTableAdapter.Adapter.InsertCommand.CommandText =
                "IF(@KhachHangId < 0) INSERT INTO KhachHang (Ten,SoDienThoai,DiaChi,ChiNhanhId) VALUES(@Ten,@SoDienThoai,@DiaChi,@ChiNhanhId)"
                + "ELSE INSERT INTO KhachHang (KhachHangId,Ten,SoDienThoai,DiaChi,ChiNhanhId) VALUES(@KhachHangId,@Ten,@SoDienThoai,@DiaChi,@ChiNhanhId)";

            NhaCungCapTableAdapter = new QLVTDataSetTableAdapters.NhaCungCapTableAdapter();
            NhaCungCapTableAdapter.Adapter.InsertCommand.CommandText =
                "IF(@NhaCungCapId < 0) INSERT INTO NhaCungCap (Ten,SoDienThoai,DiaChi) VALUES(@Ten,@SoDienThoai,@DiaChi)"
                + "ELSE INSERT INTO NhaCungCap (NhaCungCapId,Ten,SoDienThoai,DiaChi) VALUES(@NhaCungCapId,@Ten,@SoDienThoai,@DiaChi)";

            LoaiHangTableAdapter = new QLVTDataSetTableAdapters.LoaiHangTableAdapter();
            LoaiHangTableAdapter.Adapter.InsertCommand.CommandText =
                "IF(@LoaiHangId < 0) INSERT INTO LoaiHang (Ten) VALUES(@Ten)"
                + "ELSE INSERT INTO LoaiHang (LoaiHangId,Ten) VALUES(@LoaiHangId,@Ten)";

            MatHangTableAdapter = new QLVTDataSetTableAdapters.MatHangTableAdapter();
            MatHangTableAdapter.Adapter.InsertCommand.CommandText =
                "IF(@MatHangId < 0) INSERT INTO MatHang (Ten,DonViTinh,LoaiHangId) VALUES(@Ten,@DonViTinh,@LoaiHangId)"
                + "ELSE INSERT INTO MatHang (MatHangId,Ten,DonViTinh,LoaiHangId) VALUES(@MatHangId,@Ten,@DonViTinh,@LoaiHangId)";

            DatHangTableAdapter = new QLVTDataSetTableAdapters.DatHangTableAdapter();
            //DatHangTableAdapter.Adapter.InsertCommand.CommandText =
            //   "IF(@DatHangId < 0) INSERT INTO DatHang (NhanVienId,NhaCungCapId,ThoiGian) VALUES(@NhanVienId,@NhaCungCapId)"
            //   + "ELSE INSERT INTO DatHang (DatHangId,Ten,DonViTinh,LoaiHangId) VALUES(@DatHangId,@NhanVienId,@NhaCungCapId)";

            CTDatHangTableAdapter = new QLVTDataSetTableAdapters.CTDatHangTableAdapter();
            PhieuNhapTableAdapter = new QLVTDataSetTableAdapters.PhieuNhapTableAdapter();
            PhieuNhapTableAdapter.Adapter.InsertCommand.CommandText = "INSERT INTO PhieuNhap (NhanVienId,KhoId,DatHangId) VALUES(@NhanVienId,@KhoId,@DatHangId)";
            HoaDonTableAdapter = new QLVTDataSetTableAdapters.HoaDonTableAdapter();
            //HoaDonTableAdapter.Adapter.InsertCommand.CommandText= "INSERT INTO HoaDon (NhanVienId,KhoId,DatHangId) VALUES(@NhanVienId,@KhoId,@DatHangId)";
            CTHoaDonTableAdapter    = new QLVTDataSetTableAdapters.CTHoaDonTableAdapter();
            CTPhieuNhapTableAdapter = new QLVTDataSetTableAdapters.CTPhieuNhapTableAdapter();
        }
Exemplo n.º 2
0
        public int update()
        {
            QLVTDataSetTableAdapters.NhaCungCapTableAdapter nhaCungCapTableAdapter = Common.NhaCungCapTableAdapter;
            nhaCungCapTableAdapter.Connection = Common.connection;
            int rs = 0;

            try
            {
                rs = nhaCungCapTableAdapter.Update((QLVTDataSet.NhaCungCapDataTable)dgContent.ItemsSource);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(rs);
        }