public static ReturnObject SubmitLeave_OD(string current) { od_apply PageObject = new od_apply(); ReturnObject return_object = new ReturnObject(); DBConnection db_connection = new DBConnection(); string query = string.Empty; string Employee_id = string.Empty; string FromDate = string.Empty; string ToDate = string.Empty; string Reason = string.Empty; string OD_Type = string.Empty; int count = 0; int ODsubmitflag = 0; try { JObject json_data = JObject.Parse(current); Employee_id = json_data["employee_id"].ToString(); FromDate = json_data["from_date"].ToString(); ToDate = json_data["to_date"].ToString(); Reason = json_data["reason"].ToString(); OD_Type = json_data["od_types"].ToString(); count = PageObject.CheckForLeave_OD(Employee_id, FromDate, ToDate); if (count > 0) { return_object.status = "error"; return_object.return_data = "Leave already has been submitted for the selected dates."; return(return_object); } count = PageObject.CheckForLossonpay_OD(Employee_id, FromDate, ToDate); if (count > 0) { return_object.status = "error"; return_object.return_data = "Leave already has been submitted for the selected dates.Please check in LWP Details page."; return(return_object); } count = PageObject.CheckForOD_OD(Employee_id, FromDate, ToDate); if (count > 0) { return_object.status = "error"; return_object.return_data = "OD has already been submitted for the selected dates."; return(return_object); } ODsubmitflag = PageObject.InsertData_OD(Employee_id, FromDate, ToDate, Reason, OD_Type); if (ODsubmitflag > 0) { //PageObject.SendMail(Employee_id, FromDate, ToDate, Reason); return_object.status = "success"; return_object.return_data = OD_Type + " Leave submitted successfully."; } } catch (Exception ex) { Logger.LogException(ex, page, "SUBMIT_OD_LEAVE"); return_object.status = "error"; return_object.return_data = "An error occurred while Submitting OD Leave Application. Please try again. If the error persists, please contact Support."; } finally { PageObject.Dispose(); } return(return_object); }
public static ReturnObject ValidateEmployeeId(string employee_id) { od_apply page_object = new od_apply(); ReturnObject return_object = new ReturnObject(); DBConnection db_connection = new DBConnection(); DataTable Branchlisttable = new DataTable(); DataTable innermanagertable = new DataTable(); DataTable CoManagerID_data = new DataTable(); string BranchList = string.Empty, ismanager = string.Empty, ishr = string.Empty, query = string.Empty, deligationmanager = string.Empty, CoManagerID = string.Empty, InnerManagers = string.Empty; int IsDelegationMngr = 0; try { if (employee_id == "") { return_object.status = "error"; return_object.return_data = "Please enter Employee ID"; return(return_object); } IsDelegationMngr = db_connection.ExecuteQuery_WithReturnValueInteger("Select COUNT(DelidationManagerID) from TbAsignDelegation Where DelidationManagerID='" + HttpContext.Current.Session["employee_id"].ToString() + "' And DeliationStatus=1 and Convert(date,Getdate())>=Convert(date,Fromdate) And Convert(date,Getdate())<=Convert(date,Todate)"); if (IsDelegationMngr > 0) { query = "Select ManagerId from TbAsignDelegation Where DelidationManagerID='" + HttpContext.Current.Session["employee_id"].ToString() + "' And DeliationStatus=1 and Convert(date,Getdate())>=Convert(date,Fromdate) And Convert(date,Getdate())<=Convert(date,Todate)"; CoManagerID_data = db_connection.ReturnDataTable(query); if (CoManagerID_data.Rows.Count > 0) { foreach (DataRow dr in CoManagerID_data.Rows) { CoManagerID += "'" + dr["ManagerId"] + "',"; } CoManagerID = CoManagerID.TrimEnd(','); } } if (string.IsNullOrEmpty(CoManagerID)) { CoManagerID = "'Empty'"; } query = "Select BranchCode From TbManagerHrBranchMapping Where ManagerID='" + HttpContext.Current.Session["employee_id"].ToString() + "'"; Branchlisttable = db_connection.ReturnDataTable(query); if (Branchlisttable.Rows.Count > 0) { foreach (DataRow dr in Branchlisttable.Rows) { BranchList += "'" + dr["BranchCode"] + "',"; } } BranchList = BranchList.TrimEnd(','); if (string.IsNullOrEmpty(BranchList)) { BranchList = "'Empty'"; } if (!string.IsNullOrEmpty(employee_id) && employee_id != "admin") { if (!db_connection.RecordExist("select count(*) from employeeMaster where emp_Code='" + employee_id + "' and emp_status=1")) { return_object.status = "error"; return_object.return_data = "Employee doesn't Exist."; return(return_object); } if (employee_id.Trim() != HttpContext.Current.Session["employee_id"].ToString()) { if (Convert.ToInt32(HttpContext.Current.Session["access_level"].ToString()) == 0) { if (!db_connection.RecordExist("select count(*) from employeeMaster where emp_Code='" + employee_id.Trim() + "' and emp_status=1 ")) { return_object.status = "error"; return_object.return_data = "Entered Employee id does not belongs to this manager."; return(return_object); } } else { return_object.status = "error"; return_object.return_data = "You don't have permission to apply leave for this employee."; return(return_object); } } } return_object.status = "success"; } catch (Exception ex) { Logger.LogException(ex, page, "VALIDATE_EMPLOYEE_ID"); return_object.status = "error"; return_object.return_data = "An error occurred while loading EmployeeId. Please try again. If the error persists, please contact Support."; } return(return_object); }