public ActionResult RoleEdit(string EntryKey, string Func) { AppraisalApproverModel appraisalApproverModel = new AppraisalApproverModel(); if (String.IsNullOrEmpty(EntryKey) || String.IsNullOrEmpty(Func)) { TempData["ErrorMessage"] = "Error : Please access the page properly."; } else { if (Func.Equals("Edit")) { appraisalApproverModel = LINQCalls.getRoleSetupEntry(EntryKey); } else { string retVal = new AppDatabase().deleteRoleSetup(EntryKey, "AppraisalDbConnectionString"); if (!String.IsNullOrEmpty(retVal) && !retVal.Split('|')[0].Equals("0")) { TempData["ErrorMessage"] = "Error : " + retVal.Split('|')[1]; } else { return(RedirectToAction("ViewHRUsers")); } } } TempData["appraisalApproverModel"] = appraisalApproverModel; return(RedirectToAction("HRRoleSetup")); }
public ActionResult SetupAppraisalApprovers(AppraisalApproverModel appraisalApproverModel) { appraisalApproverModel.EntryKey = getEntryKey(appraisalApproverModel); /*bool duplicateEntry = LINQCalls.checkDupApproverSetup( appraisalApproverModel.EntryKey.ToUpper() ); * if (!duplicateEntry) { * TempData["ErrorMessage"] = "Error : The staff : "+ appraisalApproverModel.StaffName +" has an existing setup with the same identity"; * }*/ HRProfile hrprofile = LINQCalls.hrprofile(appraisalApproverModel.HRStaffName, 1); if (hrprofile == null) { TempData["ErrorMessage"] = "Error : You staff profile is not properly setup"; } //Setup the branch int inputMode = 0; string retVal = new AppDatabase().insertApproverSetup(appraisalApproverModel, hrprofile, inputMode, "AppraisalDbConnectionString"); if (!String.IsNullOrEmpty(retVal) && !retVal.Split('|')[0].Equals("0")) { TempData["ErrorMessage"] = "Error :" + retVal.Split('|')[1]; } else { appraisalApproverModel = null; } TempData["appraisalApproverModel"] = appraisalApproverModel; return(RedirectToAction("SetupAppraisalApprovers")); }
internal string insertApproverSetup(AppraisalApproverModel appr, HRProfile hrprofile, int inputMode, string ConnString) { string retVal = ""; string connString = getConnectionString(ConnString); SqlConnection conn = new SqlConnection(connString); SqlCommand cmnd = new SqlCommand(); cmnd.Connection = conn; cmnd.CommandType = CommandType.StoredProcedure; cmnd.CommandText = "zsp_insert_approver_setup"; cmnd.Parameters.Add("@entrykey", SqlDbType.VarChar).Value = appr.EntryKey; cmnd.Parameters.Add("@unitcode", SqlDbType.VarChar).Value = appr.UnitCode; cmnd.Parameters.Add("@unitname", SqlDbType.VarChar).Value = appr.UnitTitle; cmnd.Parameters.Add("@deptcode", SqlDbType.VarChar).Value = appr.DeptCode; cmnd.Parameters.Add("@deptname", SqlDbType.VarChar).Value = appr.DeptTitle; cmnd.Parameters.Add("@roleid", SqlDbType.VarChar).Value = appr.RoleID; cmnd.Parameters.Add("@role", SqlDbType.VarChar).Value = appr.RoleTitle; cmnd.Parameters.Add("@approverid", SqlDbType.VarChar).Value = appr.StaffNumber; cmnd.Parameters.Add("@approvername", SqlDbType.VarChar).Value = appr.StaffName; cmnd.Parameters.Add("@createdbyid", SqlDbType.VarChar).Value = hrprofile.employee_number; cmnd.Parameters.Add("@edittedbyid", SqlDbType.VarChar).Value = hrprofile.name; cmnd.Parameters.Add("@comments", SqlDbType.VarChar).Value = ""; cmnd.Parameters.Add("@rErrorCode", SqlDbType.Int, 2).Direction = ParameterDirection.Output; cmnd.Parameters.Add("@rErrorMsg", SqlDbType.VarChar, 255).Direction = ParameterDirection.Output; SqlDataReader dr; try { // Open the data connection cmnd.Connection = conn; conn.Open(); dr = cmnd.ExecuteReader(); int retCode = int.Parse(cmnd.Parameters["@rErrorCode"].Value.ToString()); if (retCode != 0) { retVal = retCode + "|" + cmnd.Parameters["@rErrorMsg"].Value.ToString(); } } catch (SqlException ex) { if (ex.Number != 0) { retVal = ex.Number + "|" + ex.Message; logWriter.WriteErrorLog(string.Format("insertApproverSetup : Exception!!! / {0}", retVal)); } } return(retVal); }
public ActionResult AppraisalApproverBulkSetupForm(int?ActionState) { SuperApproverBulkSetupModel superApproverBulkSetupModel; if (ActionState != null && ActionState == 0) { AppraisalApproverModel aam = new AppraisalApproverModel(); AppraisalApproverBulkModel aabm = new AppraisalApproverBulkModel(); List <ApproverExcelModel> sem = new List <ApproverExcelModel>(); superApproverBulkSetupModel = new SuperApproverBulkSetupModel(); superApproverBulkSetupModel.AppraisalApproverBulkModel = aabm; superApproverBulkSetupModel.ApproverExcelModel = sem; superApproverBulkSetupModel.AppraisalApproverModel = aam; return(View(superApproverBulkSetupModel)); } if (TempData["superApproverBulkSetupModel"] != null) { superApproverBulkSetupModel = TempData["superApproverBulkSetupModel"] as SuperApproverBulkSetupModel; } else { if (ViewBag.HasGrid != null) { superApproverBulkSetupModel = TempData["superApproverBulkSetupModel"] as SuperApproverBulkSetupModel; } else { AppraisalApproverBulkModel appraisalApproverBulkModel = new AppraisalApproverBulkModel(); List <ApproverExcelModel> approverExcelModel = new List <ApproverExcelModel>(); superApproverBulkSetupModel = new SuperApproverBulkSetupModel(); superApproverBulkSetupModel.AppraisalApproverBulkModel = appraisalApproverBulkModel; superApproverBulkSetupModel.ApproverExcelModel = approverExcelModel; } } String ErrorMessage = TempData["ErrorMessage"] as String; if (ErrorMessage != null) { ViewBag.ErrorMessage = ErrorMessage; } //superApproverBulkSetupModel.AppraisalApproverModel = aam; return(View(superApproverBulkSetupModel)); }
public ActionResult SetupAppraisalApprovers() { AppraisalApproverModel appraisalApproverModel = new AppraisalApproverModel(); string deptcode = BRACODE; string origdeptcode = ""; ViewBag.hasdata = "false"; if (TempData["appraisalApproverModel"] as AppraisalApproverModel != null) { appraisalApproverModel = TempData["appraisalApproverModel"] as AppraisalApproverModel; deptcode = String.IsNullOrEmpty(appraisalApproverModel.DeptCode) ? deptcode : appraisalApproverModel.DeptCode; origdeptcode = appraisalApproverModel.DeptCode; int j; if (!Int32.TryParse(deptcode, out j)) { deptcode = HOBCODE; } else { deptcode = (deptcode.Equals(ABJCODE)) ? ABJCODE : BRACODE; } ViewBag.hasdata = "true"; } //appraisalApproverModel.DeptName = SelectListItemHelper.GetDepts(); //appraisalApproverModel.UnitName = SelectListItemHelper.GetUnits( deptcode ); /*int k; * if ( Int32.TryParse(deptcode, out k) ){ * deptcode = ( deptcode.Equals(ABJCODE) ) ? ABJCODE : BRACODE; * }else { * deptcode = HOBCODE; * }*/ origdeptcode = String.IsNullOrEmpty(origdeptcode)?deptcode:origdeptcode; appraisalApproverModel.Role = SelectListItemHelper.GetRoles(deptcode); if (!String.IsNullOrEmpty(TempData["ErrorMessage"] as string)) { ViewBag.ErrorMessage = TempData["ErrorMessage"] as string; } return(View(appraisalApproverModel)); }
public ActionResult HRRoleSetup(AppraisalApproverModel appraisalApproverModel) { appraisalApproverModel.EntryKey = (String.IsNullOrEmpty(appraisalApproverModel.EntryKey)) ? getHREntryKey(appraisalApproverModel) : appraisalApproverModel.EntryKey; HRProfile hrprofile = LINQCalls.hrprofile(appraisalApproverModel.HRStaffName, 1); if (hrprofile == null) { TempData["ErrorMessage"] = "Error : You staff profile is not properly setup"; } //Get the staff's username from the staff number //AD ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(appraisalApproverModel.StaffNumber); string _username = activeDirectoryQuery.GetUserName(); if (_username == null) { ViewBag.ErrorMessage = "The user's profile is not properly setup on the system. Please contact InfoTech."; return(View()); } appraisalApproverModel.UserName = _username; //Setup the staff string retVal = new AppDatabase().insertRoleSetup(appraisalApproverModel, hrprofile, "AppraisalDbConnectionString"); if (!String.IsNullOrEmpty(retVal) && !retVal.Split('|')[0].Equals("0")) { TempData["ErrorMessage"] = "Error :" + retVal.Split('|')[1]; } else { appraisalApproverModel = null; } TempData["appraisalApproverModel"] = appraisalApproverModel; return(RedirectToAction("HRRoleSetup")); }
public ActionResult HRRoleSetup() { AppraisalApproverModel appraisalApproverModel = new AppraisalApproverModel(); ViewBag.hasdata = "false"; if (TempData["appraisalApproverModel"] as AppraisalApproverModel != null) { appraisalApproverModel = TempData["appraisalApproverModel"] as AppraisalApproverModel; ViewBag.hasdata = "true"; } appraisalApproverModel.Role = SelectListItemHelper.GetHRRoles(); appraisalApproverModel.StatusName = SelectListItemHelper.GetHRStatus(); if (!String.IsNullOrEmpty(TempData["ErrorMessage"] as string)) { ViewBag.ErrorMessage = TempData["ErrorMessage"] as string; } return(View(appraisalApproverModel)); }
private string getHREntryKey(AppraisalApproverModel ap) { return(ap.StaffNumber + "_" + ap.RoleID); }
private string getEntryKey(AppraisalApproverModel ap) { return(ap.StaffNumber + "_" + ap.RoleID + "_" + ap.UnitCode + "_" + ap.DeptCode + "_" + ap.GroupCode + "_" + ap.SuperGroupCode); }