//Hien thi danh sach de nghi trong tinh trang dang cho "Tinhtrangdn =0" public List <DeNghi> getDN(int TinhTrang) { string sql = "Select * from DeNghi where TinhTrangDN= " + TinhTrang; List <DeNghi> dnList = new List <DeNghi>(); dt = new DataTable(); ketnoi(sql); DeNghi denghi; for (int i = 0; i < dt.Rows.Count; i++) { denghi = new DeNghi(); denghi.MaDN = int.Parse(dt.Rows[i]["MaDN"].ToString()); denghi.NgayDN = DateTime.Parse(dt.Rows[i]["NgayDN"].ToString()); denghi.TenNguoiDN = dt.Rows[i]["TenNguoiDN"].ToString(); denghi.CMND = int.Parse(dt.Rows[i]["CMND"].ToString()); denghi.TruongBP = dt.Rows[i]["TruongBP"].ToString(); denghi.MoTa = dt.Rows[i]["MoTa"].ToString(); denghi.LyDo = dt.Rows[i]["LyDo"].ToString(); denghi.GhiChu = dt.Rows[i]["GhiChu"].ToString(); denghi.SoLuong = int.Parse(dt.Rows[i]["SoLuong"].ToString()); denghi.NgayDuyetDN = DateTime.Parse(dt.Rows[i]["NgayDuyetDN"].ToString()); denghi.TinhTrangDN = bool.Parse(dt.Rows[i]["TinhTrangDN"].ToString()); dnList.Add(denghi); } return(dnList); }
//Them de nghi public void AddDeNghi(DeNghi adddeNghi) { string sql = "Insert into DeNghi(NgayDN,TenNguoiDN,CMND,TruongBP,MoTa,LyDo,GhiChu,SoLuong,NgayDuyetDN,TinhTrangDN) values(N'" + adddeNghi.NgayDN + "',N'" + adddeNghi.TenNguoiDN + "',N'" + adddeNghi.CMND + "',N'" + adddeNghi.TruongBP + "',N'" + adddeNghi.MoTa + "',N'" + adddeNghi.LyDo + "',N'" + adddeNghi.GhiChu + "',N'" + adddeNghi.SoLuong + "',N'" + adddeNghi.NgayDuyetDN + "',N'" + 0 + "')"; RunSQL(sql); }
//sua de nghi public void EditDN(DeNghi editDN) { string sql = "Update DeNghi Set NgayDN= N'" + editDN.NgayDN + "',N'" + editDN.TenNguoiDN + "',N'" + editDN.CMND + "',N'" + editDN.TruongBP + "',N'" + editDN.MoTa + "',N'" + editDN.LyDo + "',N'" + editDN.LyDo + "',N'" + editDN.GhiChu + "',N'" + editDN.SoLuong + "',N'" + editDN.NgayDuyetDN + "',N'" + editDN.TinhTrangDN + "'WHERE MaDN=N'" + editDN.MaDN + "'"; RunSQL(sql); }
//xoa de nghi vs tinh trang chua duyet public void DeleteDN(DeNghi deleDN) { if (deleDN.TinhTrangDN is false) { string sql = "DELETE DeNghi WHERE MaDN=N'" + deleDN.MaDN + "'"; RunSQL(sql); } else { } }
public List <DeNghi> getDNMa(int MaDN) { string sql; if (MaDN == null) { sql = "Select * from DeNghi"; } else { sql = "Select * from DeNghi where MaDN= " + MaDN; } List <DeNghi> dnList = new List <DeNghi>(); DataTable dt = new DataTable(); SqlConnection con = db.getConnection(); SqlDataAdapter da = new SqlDataAdapter(sql, con); con.Open(); da.Fill(dt); da.Dispose(); con.Close(); DeNghi denghi; for (int i = 0; i < dt.Rows.Count; i++) { denghi = new DeNghi(); denghi.MaDN = int.Parse(dt.Rows[i]["MaDN"].ToString()); denghi.NgayDN = DateTime.Parse(dt.Rows[i]["NgayDN"].ToString()); denghi.TenNguoiDN = dt.Rows[i]["TenNguoiDN"].ToString(); denghi.CMND = int.Parse(dt.Rows[i]["CMND"].ToString()); denghi.TruongBP = dt.Rows[i]["TruongBP"].ToString(); denghi.MoTa = dt.Rows[i]["MoTa"].ToString(); denghi.LyDo = dt.Rows[i]["LyDo"].ToString(); denghi.GhiChu = dt.Rows[i]["GhiChu"].ToString(); denghi.SoLuong = int.Parse(dt.Rows[i]["SoLuong"].ToString()); denghi.NgayDuyetDN = DateTime.Parse(dt.Rows[i]["NgayDuyetDN"].ToString()); denghi.TinhTrangDN = bool.Parse(dt.Rows[i]["TinhTrang"].ToString()); dnList.Add(denghi); } return(dnList); }