protected void btnProcess_Click(object sender, EventArgs e) { try { if (ddlRegion1.SelectedItem.ToString() == "--Select--") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Region')", true); return; } else if (ddlOffice1.SelectedItem.ToString() == "--Select--") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Office!')", true); return; } else if (ddlDept1.SelectedItem.ToString() == "--Select--") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Department!')", true); return; } else if (txtDate.Text == "") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Working Date')", true); return; } else if (ddlworkingType.SelectedItem.ToString() == "Select Day Type") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Day Type')", true); return; } else if (ddlworkingType.SelectedItem.Text == "------ Select One ------") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Working Day!')", true); return; } else { try { Attendance_BLL _attendancebll = new Attendance_BLL(); //sub-section wise process if (ddlRegion1.SelectedItem.Text != "--Select--" && ddlOffice1.SelectedItem.Text != "--Select--" && ddlDept1.SelectedItem.Text != "--Select--" && ddlSection.SelectedItem.Text != "--Select--" && ddlSubSections.SelectedItem.Text != "--Select--") { int ResionId = Convert.ToInt32(ddlRegion1.SelectedValue); int OfficeId = Convert.ToInt32(ddlOffice1.SelectedValue); int DeptId = Convert.ToInt32(ddlDept1.SelectedValue); int sction = Convert.ToInt32(ddlSection.SelectedValue); int subsction = Convert.ToInt32(ddlSubSections.SelectedValue); List <HRM_EMPLOYEES_VIEWER> employess = _attendancebll.GetEmployeeByRODSSUID(ResionId, OfficeId, DeptId, sction, subsction, Convert.ToDateTime(txtDate.Text)); List <HRM_EMPLOYEES_VIEWER> newemployess = new List <HRM_EMPLOYEES_VIEWER>(); foreach (HRM_EMPLOYEES_VIEWER aitem in employess) { HRM_EMPLOYEES_VIEWER aemployee = new HRM_EMPLOYEES_VIEWER(); aemployee.EID = aitem.EID; // aemployee.EMP_ID = Convert.ToInt32(aitem.EID); aemployee.EmployeeFullName = aitem.FirstName + " " + aitem.LastName; aemployee.DEG_NAME = aitem.DEG_NAME; aemployee.DATE_JOINED = Convert.ToDateTime(txtDate.Text); aemployee.Is_Holiday = aitem.Is_Holiday; aemployee.Working_Day = ddlworkingType.SelectedValue; newemployess.Add(aemployee); } List <HRM_EMPLOYEES_VIEWER> assendingnewemployess = newemployess.OrderBy(x => x.EID).ToList(); if (assendingnewemployess.Count > 0) { grdview.DataSource = assendingnewemployess; grdview.DataBind(); } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Data Found!')", true); grdview.DataSource = null; grdview.DataBind(); } } //section wise process else if (ddlRegion1.SelectedItem.Text != "--Select--" && ddlOffice1.SelectedItem.Text != "--Select--" && ddlDept1.SelectedItem.Text != "--Select--" && ddlSection.SelectedItem.Text != "--Select--" && ddlSubSections.SelectedItem.Text == "--Select--") { int regionId = Convert.ToInt32(ddlRegion1.SelectedValue); int officeId = Convert.ToInt32(ddlOffice1.SelectedValue); int deptId = Convert.ToInt32(ddlDept1.SelectedValue); int sectionId = Convert.ToInt32(ddlSection.SelectedValue); List <HRM_EMPLOYEES_VIEWER> employess = _attendancebll.GetEmployeeBySectionId(regionId, officeId, deptId, sectionId, Convert.ToDateTime(txtDate.Text)); if (employess.Count > 0) { List <HRM_EMPLOYEES_VIEWER> newemployess = new List <HRM_EMPLOYEES_VIEWER>(); foreach (HRM_EMPLOYEES_VIEWER aitem in employess) { HRM_EMPLOYEES_VIEWER aemployee = new HRM_EMPLOYEES_VIEWER(); aemployee.EID = aitem.EID; // aemployee.EMP_ID = Convert.ToInt32(aitem.EID); aemployee.EmployeeFullName = aitem.FirstName + " " + aitem.LastName; aemployee.DEG_NAME = aitem.DEG_NAME; aemployee.DATE_JOINED = Convert.ToDateTime(txtDate.Text); aemployee.Is_Holiday = aitem.Is_Holiday; aemployee.Working_Day = ddlworkingType.SelectedValue; newemployess.Add(aemployee); } List <HRM_EMPLOYEES_VIEWER> assendingnewemployess = newemployess.OrderBy(x => x.EID).ToList(); if (assendingnewemployess.Count > 0) { grdview.DataSource = assendingnewemployess; grdview.DataBind(); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Data Found!')", true); grdview.DataSource = null; grdview.DataBind(); } } //department wise process else if (ddlRegion1.SelectedItem.Text != "--Select--" && ddlOffice1.SelectedItem.Text != "--Select--" && ddlDept1.SelectedItem.Text != "--Select--" && ddlSection.SelectedItem.Text == "--Select--" && (ddlSubSections.SelectedValue.ToString() == "" || ddlSubSections.SelectedValue.ToString() == "0" || ddlSection.SelectedValue.ToString() == "" || ddlSection.SelectedValue.ToString() == "0")) { int RegionId = Convert.ToInt32(ddlRegion1.SelectedValue); int OfficeId = Convert.ToInt32(ddlOffice1.SelectedValue); int DeptId = Convert.ToInt32(ddlDept1.SelectedValue); List <HRM_EMPLOYEES_VIEWER> employess = _attendancebll.GetEmployeeByDepartmentID(RegionId, OfficeId, DeptId, Convert.ToDateTime(txtDate.Text)); List <HRM_EMPLOYEES_VIEWER> newemployess = new List <HRM_EMPLOYEES_VIEWER>(); foreach (HRM_EMPLOYEES_VIEWER aitem in employess) { HRM_EMPLOYEES_VIEWER aemployee = new HRM_EMPLOYEES_VIEWER(); aemployee.EID = aitem.EID; aemployee.EmployeeFullName = aitem.FirstName + " " + aitem.LastName; aemployee.DEG_NAME = aitem.DEG_NAME; //aemployee.EMP_ID = Convert.ToInt32(aitem.EID); aemployee.Is_Holiday = aitem.Is_Holiday; aemployee.DATE_JOINED = Convert.ToDateTime(txtDate.Text); aemployee.Working_Day = ddlworkingType.SelectedValue; newemployess.Add(aemployee); } List <HRM_EMPLOYEES_VIEWER> ascendingnewemployees = newemployess.OrderBy(x => x.EID).ToList(); if (ascendingnewemployees.Count > 0) { grdview.DataSource = ascendingnewemployees; grdview.DataBind(); } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Data Found!')", true); grdview.DataSource = null; grdview.DataBind(); } } //office wise process else if (ddlRegion1.SelectedItem.Text != "--Select--" && ddlOffice1.SelectedItem.Text != "--Select--" && ddlDept1.SelectedItem.Text == "--Select--") { List <HRM_EMPLOYEES_VIEWER> employess = _attendancebll.GetEmployeeByOffice(Convert.ToInt32(ddlOffice1.SelectedValue), Convert.ToDateTime(txtDate.Text)); List <HRM_EMPLOYEES_VIEWER> newemployess = new List <HRM_EMPLOYEES_VIEWER>(); foreach (HRM_EMPLOYEES_VIEWER aitem in employess) { HRM_EMPLOYEES_VIEWER aemployee = new HRM_EMPLOYEES_VIEWER(); aemployee.EID = aitem.EID; aemployee.EmployeeFullName = aitem.FirstName + " " + aitem.LastName; aemployee.DEG_NAME = aitem.DEG_NAME; //aemployee.EMP_ID = Convert.ToInt32(aitem.EID); aemployee.Is_Holiday = aitem.Is_Holiday; aemployee.DATE_JOINED = Convert.ToDateTime(txtDate.Text); aemployee.Working_Day = ddlworkingType.SelectedValue; newemployess.Add(aemployee); } List <HRM_EMPLOYEES_VIEWER> ascendingnewemployees = newemployess.OrderBy(x => x.EID).ToList(); if (ascendingnewemployees.Count > 0) { grdview.DataSource = ascendingnewemployees; grdview.DataBind(); } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Data Found!')", true); grdview.DataSource = null; grdview.DataBind(); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select information for process!')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }