예제 #1
0
        public bool updateKhachhang(BKIT.Entities.Khachhang objKhachhang)
        {
            Database db         = DatabaseFactory.CreateDatabase();
            string   sqlCommand = "UPDATE Khachhang SET Tongdiem = @tongdiem, NgayBD = @ngaybd, IDLoaiKH = @idloaikh, Ngaysinh = @ngaysinh, SoDT = @sodt, Diachi = @diachi, Chucvu = @chucvu, Gioitinh = @gioitinh, Ten = @ten " +
                                  "WHERE IDKhachhang = @idkhachhang";
            DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

            try
            {
                db.AddInParameter(dbCommand, "tongdiem", DbType.Int32, objKhachhang.Tongdiem);
                db.AddInParameter(dbCommand, "ngaybd", DbType.DateTime, objKhachhang.NgayBD);
                db.AddInParameter(dbCommand, "idloaikh", DbType.Int32, objKhachhang.IDLoaiKH);
                db.AddInParameter(dbCommand, "ngaysinh", DbType.DateTime, objKhachhang.Ngaysinh);
                db.AddInParameter(dbCommand, "sodt", DbType.String, objKhachhang.SoDT);
                db.AddInParameter(dbCommand, "diachi", DbType.String, objKhachhang.Diachi);
                db.AddInParameter(dbCommand, "chucvu", DbType.String, objKhachhang.Chucvu);
                db.AddInParameter(dbCommand, "gioitinh", DbType.String, objKhachhang.Gioitinh);
                db.AddInParameter(dbCommand, "ten", DbType.String, objKhachhang.Ten);
                db.AddInParameter(dbCommand, "idkhachhang", DbType.Int32, objKhachhang.IDKhachhang);
                db.ExecuteNonQuery(dbCommand);
                dbCommand.Connection.Close();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
        public int insertKhachhang(BKIT.Entities.Khachhang objKhachhang)
        {
            Database db         = DatabaseFactory.CreateDatabase();
            string   sqlCommand = "INSERT INTO Khachhang(IDKhachhang,Tongdiem,NgayBD,IDLoaiKH,Ngaysinh,SoDT,Diachi,Chucvu,Gioitinh,Ten) " +
                                  "VALUES (@idkhachhang,@tongdiem,@ngaybd,@idloaikh,@ngaysinh,@sodt,@diachi,@chucvu,@gioitinh,@ten)";
            DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

            try
            {
                int ID = GetNextAVailableID();
                objKhachhang.IDKhachhang = ID;
                db.AddInParameter(dbCommand, "idkhachhang", DbType.Int32, objKhachhang.IDKhachhang);
                db.AddInParameter(dbCommand, "tongdiem", DbType.Int32, objKhachhang.Tongdiem);
                db.AddInParameter(dbCommand, "ngaybd", DbType.DateTime, objKhachhang.NgayBD);
                db.AddInParameter(dbCommand, "idloaikh", DbType.Int32, objKhachhang.IDLoaiKH);
                db.AddInParameter(dbCommand, "ngaysinh", DbType.DateTime, objKhachhang.Ngaysinh);
                db.AddInParameter(dbCommand, "sodt", DbType.String, objKhachhang.SoDT);
                db.AddInParameter(dbCommand, "diachi", DbType.String, objKhachhang.Diachi);
                db.AddInParameter(dbCommand, "chucvu", DbType.String, objKhachhang.Chucvu);
                db.AddInParameter(dbCommand, "gioitinh", DbType.String, objKhachhang.Gioitinh);
                db.AddInParameter(dbCommand, "ten", DbType.String, objKhachhang.Ten);
                db.ExecuteNonQuery(dbCommand);
                dbCommand.Connection.Close();
                return(ID);
            }
            catch
            {
                dbCommand.Connection.Close();
                return(-1);
            }
        }
예제 #3
0
        public bool deleteKhachhang(BKIT.Entities.Khachhang objKhachhang)
        {
            Database  db         = DatabaseFactory.CreateDatabase();
            string    sqlCommand = "DELETE FROM Khachhang WHERE IDKhachhang = @idkhachhang";
            DbCommand dbCommand  = db.GetSqlStringCommand(sqlCommand);

            try
            {
                db.AddInParameter(dbCommand, "idkhachhang", DbType.Int32, objKhachhang.IDKhachhang);
                db.ExecuteNonQuery(dbCommand);
                dbCommand.Connection.Close();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #4
0
 public bool updateKhachhang(Khachhang objKhachhang)
 {
     return new KhachhangService().updateKhachhang(objKhachhang);
 }
예제 #5
0
 public int insertKhachhang(Khachhang objKhachhang)
 {
     return new KhachhangService().insertKhachhang(objKhachhang);
 }
예제 #6
0
 public bool deleteKhachhang(Khachhang objKhachhang)
 {
     return new KhachhangService().deleteKhachhang(objKhachhang);
 }