protected void btnSearch_Click(object sender, EventArgs e) { string headID = (string)Session["loginID"]; string deptID = deptStaffDAO.findStaffByID(headID).deptID; List <RequisitionByStaffCart> list = new List <RequisitionByStaffCart>(); string ReqStaffName = ddlStaff.Text; string from = txtFrom.Text; string to = txtTo.Text; if ((from == "" || to == "") && ReqStaffName == "---Select Name---") { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Please input condition!');</script>"); } if (ReqStaffName == "---Select Name---" && (from != "" && to != "")) { DateTime dateFrom = Convert.ToDateTime(from); DateTime dateTo = Convert.ToDateTime(to); list = reqDAO.findRequisitionByDate(dateFrom, dateTo, deptID); } if ((from == "" || to == "") && ReqStaffName != "---Select Name---") { string ReqStaffID = deptStaffDAO.findStaffByName(ReqStaffName).staffID; list = reqDAO.findRequisitionByStaffID(ReqStaffID); } if (from != "" && to != "" && ReqStaffName != "---Select Name---") { DateTime dateFrom = Convert.ToDateTime(from); DateTime dateTo = Convert.ToDateTime(to); string ReqStaffID = deptStaffDAO.findStaffByName(ReqStaffName).staffID; list = reqDAO.findRequisitionByDateAndStaffID(dateFrom, dateTo, ReqStaffID); } for (int i = list.Count - 1; i >= 0; i--) { RequisitionByStaffCart reqByStaffCart = new RequisitionByStaffCart(); reqByStaffCart = list[i]; string reqStatus = reqByStaffCart.Status; if (reqStatus == "pending") { list.RemoveAt(i); } } GridView_ReqHistory.DataSource = list; GridView_ReqHistory.DataBind(); }
protected void BindGrid() { string headID = (string)Session["loginID"]; string deptID = deptStaffDAO.findStaffByID(headID).deptID; List <RequisitionByStaffCart> list = new List <RequisitionByStaffCart>(); list = reqDAO.findRequisitionByDeptID(deptID); for (int i = list.Count - 1; i >= 0; i--) { RequisitionByStaffCart reqByStaffCart = new RequisitionByStaffCart(); reqByStaffCart = list[i]; string reqStatus = reqByStaffCart.Status; if (reqStatus == "pending") { list.RemoveAt(i); } } GridView_ReqHistory.DataSource = list; GridView_ReqHistory.DataBind(); }