public static DataTable MenuTable() { try { DataTable dt = null; if (HttpContext.Current.User.Identity.IsAuthenticated) { int id = Convert.ToInt32(HttpContext.Current.User.Identity.Name); cEmpLogin emp = cEmpLogin.Get_ID(id); int accessId = emp.objRoleAccess.iObjectID; string strCon = ConfigurationManager.ConnectionStrings["DevA4.DatabaseConnectionString"].ConnectionString; SqlConnection conn = new SqlConnection(strCon); SqlDataAdapter adpt = new SqlDataAdapter("uspMenu", conn); adpt.SelectCommand.CommandType = CommandType.StoredProcedure; adpt.SelectCommand.Parameters.AddWithValue("@id", accessId); conn.Open(); adpt.SelectCommand.ExecuteReader(); conn.Close(); dt = new DataTable(); adpt.Fill(dt); } return(dt); } catch (Exception ex) { throw ex; } }
/// <summary> /// Finds and return cEmpLogin objects matching the specified criteria /// </summary> /// <param name="i_oFilter">Filter criteria (WHERE clause)</param> /// <returns>cEmpLogin objects</returns> public static List <cEmpLogin> Find(cFilter i_oFilter) { DataTable dt = Find_DataTable(i_oFilter, null); List <cEmpLogin> l = new List <cEmpLogin>(); cEmpLogin oObj; for (int i = 0; i < dt.Rows.Count; i++) { oObj = new cEmpLogin(); oObj.m_iID = Convert.ToInt32(dt.Rows[i]["iID"]); oObj.m_sName = dt.Rows[i]["sName"].ToString(); oObj.m_dtCreatedOn = Convert.ToDateTime(dt.Rows[i]["dtCreatedOn"]); oObj.m_dtLastUpdatedOn = Convert.ToDateTime(dt.Rows[i]["dtLastUpdatedOn"]); oObj.m_sEmailID = Convert.ToString(dt.Rows[i]["sEmailID"]); oObj.m_sPassword = Convert.ToString(dt.Rows[i]["sPassword"]); oObj.m_objRoleAccess.iObjectID = Convert.ToInt32(dt.Rows[i]["objRoleAccess"].ToString()); oObj.m_sFirstTime = Convert.ToString(dt.Rows[i]["sFirstTime"]); oObj.m_objDesignation.iObjectID = Convert.ToInt32(dt.Rows[i]["objDesignation"].ToString()); oObj.m_objLocation.iObjectID = Convert.ToInt32(dt.Rows[i]["objLocation"].ToString()); oObj.m_objTitle.iObjectID = Convert.ToInt32(dt.Rows[i]["objTitle"].ToString()); oObj.m_objManageGroup.iObjectID = Convert.ToInt32(dt.Rows[i]["objManageGroup"].ToString()); oObj.m_bFirstTime = Convert.ToBoolean(dt.Rows[i]["bFirstTime"]); oObj.m_bIsActive = Convert.ToBoolean(dt.Rows[i]["bIsActive"]); oObj.m_bInvalid = false; l.Add(oObj); } return(l); }
private int Log(string methodName, RouteData routeData) { var controllerName = routeData.Values["controller"]; var actionName = routeData.Values["action"]; string str = controllerName + "/" + actionName; int id = Convert.ToInt32(HttpContext.Current.User.Identity.Name); cEmpLogin objlogon = cEmpLogin.Get_ID(id); int access = objlogon.objRoleAccess.iObjectID; if (access == 1 || access == 2) { return(1); } List <cPermission> objPermit = cPermission.Find(" sName = " + str); if (objPermit.Count > 0) { List <cPermissionRoleAccess> objPermission = cPermissionRoleAccess.Find(" objRoleAccess = " + objlogon.objRoleAccess.iObjectID + " and objPermission = " + objPermit[0].iID); if (objPermission.Count > 0) { return(1); } else { return(0); } } else { return(0); } }
public JsonResult ChangePassword(ChangePassword objChangePass) { if (objChangePass.hdnEmail != null) { string email = EncryptDecrypt.Decrypt(objChangePass.hdnEmail); List <cEmpLogin> aobjLoginEmp = cEmpLogin.Find(" sEmailID = " + email); if (aobjLoginEmp.Count > 0) { aobjLoginEmp[0].sPassword = objChangePass.NewPassword; aobjLoginEmp[0].Save(); return(Json("1")); } else { return(Json("3")); } } else { if (objChangePass.CurrentPassword != null && objChangePass.CurrentPassword != "") { int loginID = Convert.ToInt32(HttpContext.User.Identity.Name); cEmpLogin objLoginEmp = cEmpLogin.Get_ID(loginID); objLoginEmp.sPassword = objChangePass.NewPassword; objLoginEmp.Save(); return(Json("2")); } else { return(Json("3")); } } }
public ActionResult Add(string ID) { try { EmployeeViewModel objEmpViewMod = new EmployeeViewModel(); if (ID != null) { int val = Convert.ToInt32(ID); cEmpLogin objEmpLogin = cEmpLogin.Get_ID(val); List <cEmpPersonalDetails> aobPerso = cEmpPersonalDetails.Find(" objEmpLogin = "******" objEmpLogin = "******"dd/MM/yyyy"); ViewBag.TitleName = objEmpLogin.objTitle.iObjectID; ViewBag.iLocation = objEmpLogin.objLocation.iObjectID; cManageGroup objmanage = cManageGroup.Get_ID(objEmpLogin.objManageGroup.iObjectID); ViewBag.iReportingHead = objmanage.iReportingHead; ViewBag.DepID = cFunctionalGroup.Get_ID(objmanage.objFunctionalGroup.iObjectID).objFunctionalDepartment; ViewBag.RollAccessID = objEmpLogin.objRoleAccess.iObjectID; ViewBag.DepTypeID = objmanage.objFunctionalGroup.iObjectID; ViewBag.DesgID = objEmpLogin.objDesignation.iObjectID; objEmpViewMod.DesignationList = getDesignationList(); objEmpViewMod.ReportList = getReportHeadList(); objEmpViewMod.TitleList = getTitleList(); objEmpViewMod.LocationList = getLocation(); objEmpViewMod.DepartmentList = getDepartmentList(); objEmpViewMod.RollAccessList = getRollAccessList(); objEmpViewMod.DepartTypeList = getDepartmentType(); objEmpViewMod.EmpList = GetEmployeeList(); ViewBag.Update = objEmpViewMod; return(View(objEmpViewMod)); } else { objEmpViewMod.DesignationList = getDesignationList(); objEmpViewMod.ReportList = getReportHeadList(); objEmpViewMod.TitleList = getTitleList(); objEmpViewMod.LocationList = getLocation(); objEmpViewMod.DepartmentList = getDepartmentList(); objEmpViewMod.RollAccessList = getRollAccessList(); objEmpViewMod.DepartTypeList = getDepartmentType(); objEmpViewMod.EmpList = GetEmployeeList(); return(View(objEmpViewMod)); } } catch (Exception ex) { throw ex; } }
public JsonResult Index(Login objlogin) { if (!HttpContext.User.Identity.IsAuthenticated) { if (objlogin.ForgotEmailID != null) { string link = url + "/Login/ChangePassword?Email=" + EncryptDecrypt.Encrypt(objlogin.ForgotEmailID); string Links = "<b><a target='_blank' href=" + link + ">Click here to reset your password.</a></b>"; string strBody = ""; StreamReader sr = new StreamReader(HttpContext.Server.MapPath(HttpContext.Request.ApplicationPath + "/App_Data/ForgotPassword.html")); strBody = sr.ReadToEnd(); sr.Close(); strBody = strBody.Replace("#Link#", Links); strBody = strBody.Replace("#Employee#", objlogin.ForgotEmailID); //strBody = strBody.Replace("#password#", password); string str = Mail.SendEmail(objlogin.ForgotEmailID, "Reset Password", strBody, true); return(Json("4")); } else { List <cEmpLogin> objEmplog = cEmpLogin.Find(" sEmailID = " + objlogin.EmailID.Trim() + " and sPassword = "******""; List <cEmpPersonalDetails> aobEmp = cEmpPersonalDetails.Find(" objEmpLogin = "******" " + aobEmp[0].sLastName; } if (objEmplog[0].sFirstTime == "0") { return(Json("0"));//Redirect to Change Password: } FormsAuthentication.SetAuthCookie(objEmplog[0].iID.ToString(), objlogin.RememberMe); if (objEmplog[0].sFirstTime == "1") { return(Json("1")); //Redirect to My Profile: } return(Json("2")); //Redirect to DashBoard: } else { return(Json("3")); } } } else { cEmpLogin emp = cEmpLogin.Get_ID(Convert.ToInt32(HttpContext.User.Identity.Name)); return(Json("2")); } }
/// <summary> /// Creates a cEmpLogin object. It will be saved in permanent storage only /// on calling Save() /// </summary> /// <returns>cEmpLogin object</returns> public static cEmpLogin Create() { cEmpLogin oObj = new cEmpLogin(); SecurityCheck((int)enEmpLogin_Action.Create); // Create an object in memory, will be saved to storage on calling Save() oObj.m_bCreating = true; oObj.m_bInvalid = false; return(oObj); }
/// <summary> /// Ensures that an object with the specified name exists, while creating other properties are set to their default values /// </summary> /// <param name="i_sName">Name</param> /// <returns>cEmpLogin object</returns> public static cEmpLogin CreateIfRequiredAndGet(string i_sName) { cEmpLogin oObj = cEmpLogin.Get_Name(i_sName); if (oObj == null) { oObj = cEmpLogin.Create(); oObj.sName = i_sName; oObj.Save(); } return(oObj); }
public JsonResult CheckOldPassword(string CurrentPassword) { try { int loginID = Convert.ToInt32(HttpContext.User.Identity.Name); cEmpLogin objLoginEmp = cEmpLogin.Get_ID(loginID); if (objLoginEmp.sPassword == CurrentPassword.Trim()) { return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json("Incorrect old password", JsonRequestBehavior.AllowGet)); } } catch (Exception) { throw; } }
public ActionResult CreateRequest() { try { LeaveViewModel objLeaveViewModel = new LeaveViewModel(); int LoginID = Convert.ToInt32(HttpContext.User.Identity.Name); int manageID = cEmpLogin.Get_ID(LoginID).objManageGroup.iObjectID; cManageGroup objmanage = cManageGroup.Get_ID(manageID); int ReportHeadID = objmanage.iReportingHead; List <cEmpPersonalDetails> objPersona = cEmpPersonalDetails.Find(" objEmpLogin = "******"EmployeeCode"].ToString(); objLeaveViewModel.EmployeeDepartment = dt.Rows[0]["DepartmentType"].ToString(); objLeaveViewModel.EmployeeDesignation = dt.Rows[0]["Designation"].ToString(); objLeaveViewModel.EmployeeName = dt.Rows[0]["Firstname"].ToString(); if (objPersona.Count > 0) { objLeaveViewModel.EmployeeReportingHead = objPersona[0].sFirstName + " " + objPersona[0].sLastName; } else { objLeaveViewModel.EmployeeReportingHead = ""; } } cEmpLogin objEmpLogin = cEmpLogin.Get_ID(LoginID); objLeaveViewModel.LeaveTypeList = getLeaveTypeList(); return(View(objLeaveViewModel)); } catch (Exception ex) { throw ex; } }
public ActionResult Profile() { try { int LoginID = Convert.ToInt32(HttpContext.User.Identity.Name); string EmergancyContact = ""; string ContactNo = ""; string Relation = ""; ProfileViewModel objProfile = new ProfileViewModel(); cEmpLogin empLogin = cEmpLogin.Get_ID(LoginID); objProfile.objEmpPersonal = new EmployeePersonalDetails { WorkEmail = empLogin.sEmailID }; //------- Employee Personal Detail data check----// List <cEmpEmergencyContact> emerobj = cEmpEmergencyContact.Find(" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = " + empLogin.iID); if (objProfessional.Count > 0) { objProfile.objEmpProfessional = new EmpProfessionalDetails { CompanyName = objProfessional[0].sCompanyName, Designation = objProfessional[0].sDesignation, FromDate = objProfessional[0].dtFromDate, EndDate = objProfessional[0].dtEndDate, }; } else { objProfile.objEmpProfessional = new EmpProfessionalDetails(); } return(View(objProfile)); } catch (Exception ex) { throw ex; } //objPers.objEmpPersonal.FirstName=aobjEmployeePersonalDetails[0].sFirstName.ToString(); //objPers.objEmpPersonal.MiddleName = aobjEmployeePersonalDetails[0].sMiddleName.ToString(); ; //objPers.objEmpPersonal.LastName = aobjEmployeePersonalDetails[0].sLastName.ToString() ; //objPers.PersonalEmail = aobjEmployeePersonalDetails[0].sPersoanlEmailID.ToString(); //objPers.objEmpPersonal.Gender = aobjEmployeePersonalDetails[0].sGender.ToString(); //objPers.WorkEmail = objEmpLogin.sEmailID.ToString(); }
public JsonResult personaldeatil(EmployeePersonalDetails objEmpPersonal) { try { int LoginID = Convert.ToInt32(HttpContext.User.Identity.Name); cEmpLogin objEmpLogin = cEmpLogin.Get_ID(LoginID); List <cEmpPersonalDetails> aobjEmployeePersonalDetails = cEmpPersonalDetails.Find(" objEmpLogin = "******"2"; objEmpLogin.Save(); } List <cEmpEmergencyContact> aobjEmpEmergency = cEmpEmergencyContact.Find(" objEmpLogin = "******"2"; return(Json(aobjEmployeePersonalDetails[0])); } catch (Exception ex) { throw ex; } }
//public JsonResult Edit(string ID) //{ // try // { // JsonResult result = new JsonResult(); // result.Data = objEmpViewMod; // result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; // return result; // } // catch (Exception) // { // throw; // } //} public JsonResult Delete(string ID) { try { int loginID = Convert.ToInt32(HttpContext.User.Identity.Name); int id = Convert.ToInt32(ID); cEmpLogin objEmp = cEmpLogin.Get_ID(id); objEmp.bIsActive = false; objEmp.Save(); //List<cEmpPersonalDetails> objPersonal = cEmpPersonalDetails.Find(" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******"2"); //} ////Profile Detail Delete //List<cEmpPersonalDetails> objPersonal = cEmpPersonalDetails.Find(" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objEmpLogin = "******" objTimesheet = " + aobjTimeSheet[0].iID); // if (aobjTimeActivity.Count>0) // { // foreach (var itemAct in aobjTimeActivity) // { // List<cTimeSheetActivityDes> aobjTimeAcDes = cTimeSheetActivityDes.Find(" objTimeSheetActivity = " + itemAct.iID); // if (aobjTimeAcDes.Count > 0) // { // foreach (var itemDes in aobjTimeAcDes) // { // cTimeSheetActivityDes.Delete(itemDes.iID); // } // } // cTimeSheetActivity.Delete(itemAct.iID); // } // } // cTimesheet.Delete(aobjTimeSheet[0].iID); //} ////Update reporting Head:- //List<cEmpLogin> aobEmpLog = cEmpLogin.Find(" objEmpLogin = "******" iReportingHead = " + id); //if (aobEmpReport.Count > 0) //{ // foreach (var itemEmpRe in aobEmpReport) // { // itemEmpRe.iReportingHead = 1; // itemEmpRe.Save(); // } //} //cEmpLogin.Delete(id); return(Json("1")); } catch (Exception ex) { throw ex; } }
public JsonResult Add(EmployeeViewModel emp, string hdnEmployeeID) { try { EmployeeViewModel objEmpViewMod = new EmployeeViewModel(); if (emp.SelectedRollAccess[0] == "" || emp.SelectedReportHead[0] == "" || emp.SelectedLocation[0] == "" || emp.SelectedDepartmentType[0] == "" || emp.SelectedDesignation[0] == "" || emp.SelectedRollAccess[0] == "" || emp.SelectedReportHead[0] == "") { return(Json("1"));//Some Dropdown are not selected } else { //if (ModelState.IsValid) //{ if (hdnEmployeeID != null && hdnEmployeeID != "") { string strTitle = "0"; if (emp.SelectedTitle[0] == "") { strTitle = "0"; } else { strTitle = emp.SelectedTitle[0]; } int ID = Convert.ToInt32(hdnEmployeeID); cEmpLogin objEmpLogin = cEmpLogin.Get_ID(ID); objEmpLogin.sEmailID = emp.EmployeeEmailIdUpdate; List <cManageGroup> objManag = cManageGroup.Find(" objFunctionalGroup = " + emp.DepTypeID + " and iReportingHead = " + Convert.ToInt32(emp.SelectedReportHead[0])); if (objManag.Count > 0) { objEmpLogin.objManageGroup.iObjectID = objManag[0].iID; } else { cManageGroup aobjManag = cManageGroup.Create(); aobjManag.objFunctionalGroup.iObjectID = Convert.ToInt32(emp.SelectedDepartmentType[0]); aobjManag.iReportingHead = Convert.ToInt32(emp.SelectedReportHead[0]); aobjManag.Save(); objEmpLogin.objManageGroup.iObjectID = aobjManag.iID; } objEmpLogin.objRoleAccess.iObjectID = Convert.ToInt32(emp.SelectedRollAccess[0]); objEmpLogin.objTitle.iObjectID = Convert.ToInt32(emp.SelectedTitle[0]); objEmpLogin.objLocation.iObjectID = Convert.ToInt32(emp.SelectedLocation[0]); objEmpLogin.objDesignation.iObjectID = Convert.ToInt32(emp.SelectedDesignation[0]); objEmpLogin.sFirstTime = "1"; objEmpLogin.bIsActive = true; objEmpLogin.sPassword = emp.Password; objEmpLogin.Save(); List <cEmpPersonalDetails> aobjEmployeePersonalDetails = cEmpPersonalDetails.Find(" objEmpLogin = "******""; } else { aobjEmployeePersonalDetails[0].sMiddleName = aobjEmployeePersonalDetails[0].sMiddleName; } //aobjEmployeePersonalDetails[0].sMiddleName = emp.EmpPersonal.MiddleName; aobjEmployeePersonalDetails[0].sLastName = emp.EmpPersonal.LastName; aobjEmployeePersonalDetails[0].sPersoanlEmailID = emp.PersonalEmailUpdate; aobjEmployeePersonalDetails[0].objEmpLogin.iObjectID = objEmpLogin.iID; aobjEmployeePersonalDetails[0].Save(); List <cEmployee> aobjEmp = cEmployee.Find(" objEmpLogin = "******" iID = " + aobjEmp[0].objEmpDesigDepartmentType.iObjectID); //aobjDesigDepart[0].objDepartmentType.iObjectID = Convert.ToInt32(emp.SelectedDepartmentType[0]); //aobjDesigDepart[0].objDesignation.iObjectID = Convert.ToInt32(emp.SelectedDesignation[0]); //aobjDesigDepart[0].Save(); MailCreateEmployee(objEmpLogin.sEmailID, objEmpLogin.sPassword, "Update"); return(Json("2"));//Update } else { string strTitle = "0"; if (emp.SelectedTitle[0] == "") { strTitle = "0"; } else { strTitle = emp.SelectedTitle[0]; } cEmpLogin objEmpLogin = cEmpLogin.Create(); objEmpLogin.sEmailID = emp.EmployeeEmailId; objEmpLogin.objRoleAccess.iObjectID = Convert.ToInt32(emp.SelectedRollAccess[0]); objEmpLogin.sFirstTime = "1"; objEmpLogin.bIsActive = true; objEmpLogin.sPassword = emp.Password; objEmpLogin.objDesignation.iObjectID = Convert.ToInt32(emp.SelectedDesignation[0]); objEmpLogin.objLocation.iObjectID = Convert.ToInt32(emp.SelectedLocation[0]); objEmpLogin.objTitle.iObjectID = Convert.ToInt32(emp.SelectedTitle[0]); List <cManageGroup> objManag = cManageGroup.Find(" objFunctionalGroup = " + emp.DepTypeID + " and iReportingHead = " + Convert.ToInt32(emp.SelectedReportHead[0])); if (objManag.Count > 0) { objEmpLogin.objManageGroup.iObjectID = objManag[0].iID; } else { cManageGroup aobjManag = cManageGroup.Create(); aobjManag.objFunctionalGroup.iObjectID = Convert.ToInt32(emp.SelectedDepartmentType[0]); aobjManag.iReportingHead = Convert.ToInt32(emp.SelectedReportHead[0]); aobjManag.Save(); objEmpLogin.objManageGroup.iObjectID = aobjManag.iID; } objEmpLogin.Save(); cEmpPersonalDetails objEmployeePersonalDetails = cEmpPersonalDetails.Create(); objEmployeePersonalDetails.sFirstName = emp.EmpPersonal.FirstName; if (emp.EmpPersonal.MiddleName == null) { objEmployeePersonalDetails.sMiddleName = ""; } else { objEmployeePersonalDetails.sMiddleName = emp.EmpPersonal.MiddleName; } objEmployeePersonalDetails.sLastName = emp.EmpPersonal.LastName; objEmployeePersonalDetails.sPersoanlEmailID = emp.PersonalEmail; objEmployeePersonalDetails.objEmpLogin.iObjectID = objEmpLogin.iID; objEmployeePersonalDetails.bIsActive = true; objEmployeePersonalDetails.Save(); cEmployee objEmp = cEmployee.Create(); objEmp.objEmpLogin.iObjectID = objEmpLogin.iID; objEmp.dtDOJ = Convert.ToDateTime(emp.Employee.DOJ); objEmp.Save(); MailCreateEmployee(objEmpLogin.sEmailID, objEmpLogin.sPassword, "Create"); return(Json("3"));//Create } } } catch (Exception ex) { throw ex; } }
using System;