Ejemplo n.º 1
0
        public Boolean SuaPB(PhongBan pb)
        {
            SqlConnection conn = getConnection();

            conn.Open();
            try
            {
                string sqlSua = "DECLARE @dem int select @dem = COUNT(MaPB) FROM PhongBan WHERE MaPB = @MaPB " +
                                "IF @dem != 0 UPDATE PhongBan SET TenPB = @TenPB , NgayThanhLap = @NgayThanhLap WHERE MaPB = @MaPB else raiserror('',16,1)";
                SqlCommand cmd = new SqlCommand(sqlSua, conn);
                cmd.Parameters.AddWithValue("MaPB", pb.MaPB);
                cmd.Parameters.AddWithValue("TenPB", pb.TenPB);
                cmd.Parameters.AddWithValue("NgayThanhLap", pb.NgayThanhLap);
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
            return(true);
        }
        public bool AddPhongBan(PhongBan phongBan)
        {
            DynamicParameters parameters = new DynamicParameters();

            parameters.Add("@TenPhongBan", phongBan.TenPhongBan);
            parameters.Add("@IsDelete", phongBan.IsDeleted);
            SqlMapper.Execute(con, "AddPhongBan", param: parameters, commandType: CommandType.StoredProcedure);
            return(true);
        }
Ejemplo n.º 3
0
 public int Insert(PhongBan obj)
 {
     MySqlParameter[] para =
     {
         new MySqlParameter("idPB",  obj.IDPhongBan),
         new MySqlParameter("tenPB", obj.namePhongBan)
     };
     return(db.ExecuteSQL("phongban_Insert", para));
 }
Ejemplo n.º 4
0
 public bool CreatePhongBan(PhongBan phongBan)
 {
     try
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@MaPB", phongBan.MaPB);
         parameters.Add("@TenPB", phongBan.TenPB);
         SqlMapper.Execute(con, "CreatePhongBan", param: parameters, commandType: CommandType.StoredProcedure);
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 5
0
 public bool Sua(PhongBan pb)
 {
     try
     {
         string query = @" UPDATE dbo.PhongBan set tenphongban = N'" + pb.Ten + "',manql = '" + pb.MaQL + "', diadiem = N'" + pb.DiaDiem + "' where maphong ='" + pb.Ma + "'";
         OpenConection();
         ExecuteQueries(query);
         CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         SetEx(ex);
         return(false);
     }
 }
        public bool UpdatePhongBan(PhongBan phongBan)
        {
            try
            {
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@IDPhongBan", phongBan.IDPhongBan);
                parameters.Add("@TenPhongBan", phongBan.TenPhongBan);
                //parameters.Add("@UserEmail", phongBan.IsDeleted);

                SqlMapper.Execute(con, "AddPhongBan", param: parameters, commandType: CommandType.StoredProcedure);
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
 public bool Them(PhongBan pb)
 {
     try
     {
         string query = @"INSERT INTO dbo.PhongBan( MaPhong ,TenPhongBan , MaNQL ,DiaDiem)
                         VALUES  ( '" + pb.Ma + "',N'" + pb.Ten + "', '" + pb.MaQL + "',N'" + pb.DiaDiem + "')";
         OpenConection();
         ExecuteQueries(query);
         CloseConnection();
         return(true);
     }
     catch (Exception ex)
     {
         SetEx(ex);
         return(false);
     }
 }
Ejemplo n.º 8
0
        public Boolean ThemPB(PhongBan pb)
        {
            SqlConnection conn = getConnection();

            conn.Open();
            try
            {
                string     sqlThem = "INSERT INTO PhongBan VALUES(@MaPB , @TenPB , @NgayThanhLap)";
                SqlCommand cmd     = new SqlCommand(sqlThem, conn);
                cmd.Parameters.AddWithValue("MaPB", pb.MaPB);
                cmd.Parameters.AddWithValue("TenPB", pb.TenPB);
                cmd.Parameters.AddWithValue("NgayThanhLap", pb.NgayThanhLap);
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
            return(true);
        }
Ejemplo n.º 9
0
 partial void DeletePhongBan(PhongBan instance);
Ejemplo n.º 10
0
 partial void UpdatePhongBan(PhongBan instance);
Ejemplo n.º 11
0
 partial void InsertPhongBan(PhongBan instance);
Ejemplo n.º 12
0
 public void Update(PhongBan obj)
 {
     db.Update("update phongban set TenPB = '" + obj.namePhongBan + "' Where MaPB = '" + obj.IDPhongBan + "'");
 }