public static bool Update(BEL_LoaiNhanVien LoaiNhanVien) { try { GetConnection(); string Query = string.Format("update LOAINHANVIEN set TenLoai = N'{0}' where MaLoai = '{1}'", LoaiNhanVien.Ten, LoaiNhanVien.Ma); SqlCommand Command = new SqlCommand(Query, Connection); int Result = Command.ExecuteNonQuery(); return(Result == 1); } catch (Exception Err) { throw; } finally { Connection.Close(); } }
public static bool Add(BEL_LoaiNhanVien LoaiNhanVien) { try { GetConnection(); string Query = string.Format("insert into LOAINHANVIEN(MaLoai, TenLoai, TrangThai) values('{0}', N'{1}', N'{2}')", LoaiNhanVien.Ma, LoaiNhanVien.Ten, LoaiNhanVien.TrangThai); SqlCommand Command = new SqlCommand(Query, Connection); int Result = Command.ExecuteNonQuery(); return(Result == 1); } catch (Exception Err) { throw; } finally { Connection.Close(); } }
public static bool Update(BEL_LoaiNhanVien LoaiNhanVien) { if (LoaiNhanVien.Ma == "") { throw new Exception("Mã loại không được rỗng!"); } if (LoaiNhanVien.Ten == "") { throw new Exception("Tên loại không được rỗng!"); } if (LoaiNhanVien.TrangThai == "") { throw new Exception("Trạng thái không được rỗng!"); } try { return(DAL_LoaiNhanVien.Update(LoaiNhanVien)); } catch (Exception Err) { throw; } }
public static BEL_LoaiNhanVien GetObjectById(string Id) { try { GetConnection(); string Query = string.Format("select* from LOAINHANVIEN where MaLoai = '{0}'", Id); SqlCommand Command = new SqlCommand(Query, Connection); SqlDataReader DataReader = Command.ExecuteReader(); DataReader.Read(); string MaLoai = (string)DataReader["MaLoai"]; string TenLoai = (string)DataReader["TenLoai"]; string TrangThai = (string)DataReader["TrangThai"]; BEL_LoaiNhanVien LoaiNhanVien = new BEL_LoaiNhanVien(MaLoai, TenLoai, TrangThai); return(LoaiNhanVien); } catch (Exception Err) { throw; } finally { Connection.Close(); } }
public BEL_LoaiNhanVien(BEL_LoaiNhanVien LoaiNhanVien) { _Ma = LoaiNhanVien._Ma; _Ten = LoaiNhanVien._Ten; _TrangThai = LoaiNhanVien._TrangThai; }