public bool TRaGVU(TAIKHOAN tk) { gvu = GiaoVuBUS.Instance.GetByID(tk.maTaiKhoan); if (gvu != null) { return(true); } return(false); }
//Update public bool Update(DataGridView data) { DataGridViewRow row = data.SelectedCells[0].OwningRow; string MaGVu = row.Cells["maGVu"].Value.ToString(); string TenGVu = row.Cells["tenGVu"].Value.ToString(); bool? Phai = (bool?)row.Cells["phai"].Value; DateTime? NgaySinh = (DateTime?)row.Cells["ngaySinh"].Value; string DiaChi = row.Cells["diaChi"].Value.ToString(); GIAOVU gvu = new GIAOVU(MaGVu, TenGVu, Phai, NgaySinh, DiaChi); return(GiaoVuDAO.Instance.Update(MaGVu, gvu)); }
//update public bool Update(string id, GIAOVU gvu) { string query = "Update GIAOVU SET TenGiaoVu = @ten , Phai = @phai , NgaySinh = @NS , DiaChi = @diaChi WHERE MaGiaoVu = @maOLD "; object[] para = new object[] { gvu.tenGVu, gvu.phai, gvu.ngaySinh, gvu.diaChi, id }; if (DataProvider.Instance.ExecuteNonQuery(query, para) > 0) { return(true); } return(false); }
public List <GIAOVU> GetAll() { List <GIAOVU> giaovus = new List <GIAOVU>(); string query = "SELECT * FROM GIAOVU"; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { string maGVu = item["MaGiaoVu"].ToString(); string tenGVu = item["TenGiaoVu"].ToString(); bool phai = (bool)item["Phai"]; DateTime ngaySinh = (DateTime)item["NgaySinh"]; string diaChi = item["DiaChi"].ToString(); GIAOVU gv = new GIAOVU(maGVu, tenGVu, phai, ngaySinh, diaChi); giaovus.Add(gv); } return(giaovus); }
//get by id public GIAOVU GetByID(string id) { string query = "select * from GIAOVU where MaGiaoVu = @Id "; object[] para = new object[] { id }; DataTable data = DataProvider.Instance.ExecuteQuery(query, para); DataRow item = data.Rows[0]; string maGVU = item["MaGiaoVu"].ToString(); string tenGVU = item["TenGiaoVu"].ToString(); bool? phai = item["Phai"].ToString() == string.Empty ? null : (bool?)item["phai"]; DateTime?ngaySinh = item["NgaySinh"].ToString() == string.Empty ? null : (DateTime?)item["ngaySinh"]; string diaChi = item["DiaChi"].ToString(); GIAOVU GVU = new GIAOVU(maGVU, tenGVU, phai, ngaySinh, diaChi); return(GVU); }
//get by id public GIAOVU GetByID(string id) { GIAOVU gvu = GiaoVuDAO.Instance.GetByID(id); return(gvu); }