public ChucVuCollection TimDSChucVu(string tencv) { ChucVuCollection cvColl = new ChucVuCollection(); SqlConnection cnn = new SqlConnection(cnnstr); string query = "select * from ChucVu where tencv <> '' "; query += "order by tencv"; SqlCommand cmd = new SqlCommand(query, cnn); if (tencv != "") { query = "select * from ChucVu where tencv like @tencv and tencv <>''"; query += "order by tencv"; cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@tencv", "%" + tencv + "%"); } cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ChucVuBO cvBO = new ChucVuBO(); cvBO.MaCV = dr["macv"].ToString(); cvBO.TenCV = dr["tencv"].ToString(); cvColl.Add(cvBO); } cnn.Close(); return cvColl; }
public void SuaChucVu(ChucVuBO ChucVuBO) { SqlConnection cnn = new SqlConnection(cnnstr); string query = "update ChucVu set tencv=@tencv where macv=@macv "; SqlCommand cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@tencv", ChucVuBO.TenCV); cmd.Parameters.AddWithValue("@macv", ChucVuBO.MaCV); cnn.Open(); cmd.ExecuteNonQuery(); cnn.Close(); }
public bool SuaChucVu(string macv, string tencv) { try { ChucVuBO chucvuBO = new ChucVuBO(); chucvuBO.MaCV = macv; chucvuBO.TenCV = tencv; chucvuDAO.SuaChucVu(chucvuBO); return true; } catch { return false; } }
public ChucVuBO Tim1ChucVu(string macv) { ChucVuBO chucvuBO = new ChucVuBO(); SqlConnection cnn = new SqlConnection(cnnstr); string query = "select * from ChucVu where tencv <> '' and MaCV=@macv "; SqlCommand cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@macv", macv); cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { chucvuBO.MaCV = dr["macv"].ToString(); chucvuBO.TenCV = dr["tencv"].ToString(); break; } return chucvuBO; }
public void Add(ChucVuBO chucvuBO) { List.Add(chucvuBO); }