Beispiel #1
0
        public MessageResult CashierUpdateBusinessTrip(BusinessTripManagementModel businessTripManagementModel)
        {
            MessageResult msgResult = new MessageResult();

            try
            {
                SPWeb spWeb = SPContext.Current.Web;

                if (businessTripManagementModel.Id > 0)
                {
                    Biz.Models.BusinessTripManagement businessTripManagement = _businessTripManagementDAL.GetByID(businessTripManagementModel.Id);
                    if (!string.IsNullOrEmpty(businessTripManagementModel.Comment) && businessTripManagementModel.Cashier != null)
                    {
                        EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Site.Url);
                        EmployeeInfo    currentUserInfo  = _employeeInfoDAL.GetByID(businessTripManagementModel.Cashier.LookupId);

                        if (currentUserInfo != null)
                        {
                            businessTripManagement.Comment = businessTripManagement.Comment.BuildComment(string.Format("{0}: {1}", currentUserInfo.FullName, businessTripManagementModel.Comment));
                            _businessTripManagementDAL.SaveOrUpdate(spWeb, businessTripManagement);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                msgResult.Code    = (int)BusinessTripErrorCode.Unexpected;
                msgResult.Message = ex.Message;
            }

            return(msgResult);
        }
 public bool IsMemberOfDepartmentByCode(string employeeId, string departmentCode)
 {
     try
     {
         var departmentDal = new DepartmentDAL(SPContext.Current.Web.Url);
         var employeeDal   = new EmployeeInfoDAL(SPContext.Current.Web.Url);
         var department    = departmentDal.GetByCode(departmentCode);
         if (department != null)
         {
             var employee = employeeDal.GetByDepartment(Convert.ToInt32(employeeId), Convert.ToInt32(department.ID), true); //get user active
             if (employee != null)
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         SPDiagnosticsService.Local.WriteTrace(0,
                                               new SPDiagnosticsCategory("STADA - Employee Service - IsMemberOfDepartmentByCode fn",
                                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
         return(false);
     }
 }
Beispiel #3
0
        public Delegation GetDelegatedTaskInfo(string Id)
        {
            Delegation delegation = new Delegation(null);

            int listItemId = 0;

            if (int.TryParse(Id, out listItemId))
            {
                string[] viewFields = new string[] { StringConstant.ChangeShiftList.DHField, StringConstant.CommonSPListField.ApprovalStatusField,
                                                     StringConstant.CommonSPListField.CommonDepartmentField };
                string queryStr = $@"<Where>
                                      <Eq>
                                         <FieldRef Name='ID' />
                                         <Value Type='Counter'>{listItemId}</Value>
                                      </Eq>
                                   </Where>";
                List <Biz.Models.ChangeShiftManagement> changeShiftManagementCollection = this.GetByQuery(queryStr, viewFields);
                if (changeShiftManagementCollection != null && changeShiftManagementCollection.Count > 0)
                {
                    Biz.Models.ChangeShiftManagement changeShiftManagement = changeShiftManagementCollection[0];

                    EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(this.SiteUrl);
                    EmployeeInfo    currentApprover  = _employeeInfoDAL.GetByADAccount(changeShiftManagement.DepartmentHead.ID);
                    if (currentApprover != null)
                    {
                        delegation = DelegationPermissionManager.IsDelegation(currentApprover.ID, StringConstant.ChangeShiftList.ListUrl, changeShiftManagement.ID);
                    }
                }
            }

            return(delegation);
        }
        /// <summary>
        /// GetCurrentEmployeeInfo
        /// </summary>
        /// <param name="siteUrl"></param>
        /// <returns></returns>
        private static EmployeeInfo GetCurrentEmployeeInfo(string siteUrl)
        {
            EmployeeInfo currentEmployeeInfo = null;

            if (HttpContext.Current != null)
            {
                currentEmployeeInfo = HttpContext.Current.Session[StringConstant.EmployeeLogedin] as EmployeeInfo;
            }

            //User is not common account, we should get from employee list
            if (currentEmployeeInfo == null)
            {
                SPUser spUser = null;
                if (SPContext.Current != null)
                {
                    spUser = SPContext.Current.Web.CurrentUser;
                }
                if (spUser != null)
                {
                    if (employeeInfoDAL == null)
                    {
                        employeeInfoDAL = new EmployeeInfoDAL(siteUrl);
                    }
                    currentEmployeeInfo = employeeInfoDAL.GetByADAccount(spUser.ID);
                    //if (HttpContext.Current != null)
                    //{
                    //    HttpContext.Current.Session[StringConstant.EmployeeLogedin] = currentEmployeeInfo;
                    //}
                }
            }

            return(currentEmployeeInfo);
        }
Beispiel #5
0
 private void InitEmployeeDAL(SPWeb currentWeb)
 {
     if (_employeeInfoDAL == null)
     {
         _employeeInfoDAL = new EmployeeInfoDAL(currentWeb.Url);
     }
 }
Beispiel #6
0
        /// <summary>
        /// Update new password to Employee Info
        /// </summary>
        /// <param name="model">Reset password model </param>
        /// <returns>Result: true if update successfully</returns>
        protected bool UpdateNewPassword(ResetPasswordModel model)
        {
            EmployeeInfoDAL employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Web.Url);
            var             result          = employeeInfoDAL.UpdatePassword(model.EmployeeID, model.NewPassword);

            return(result);
        }
 public EmployeeModel GetEmployeeInfoByADAccount(string adAccountId)
 {
     try
     {
         var user            = new EmployeeModel();
         var employeeDal     = new EmployeeInfoDAL(SPContext.Current.Web.Url);
         var currentEmployee = employeeDal.GetByADAccount(Convert.ToInt32(adAccountId));
         if (currentEmployee != null)
         {
             user = new EmployeeModel()
             {
                 ID         = currentEmployee.ID,
                 EmployeeID = currentEmployee.EmployeeID,
                 //Department = currentEmployee.Department,
                 //Location = currentEmployee.FactoryLocation,
                 FullName = currentEmployee.FullName
             };
         }
         return(user);
     }
     catch (Exception ex)
     {
         SPDiagnosticsService.Local.WriteTrace(0,
                                               new SPDiagnosticsCategory("STADA - Employee Service - GetCurrentUser fn",
                                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
         return(null);
     }
 }
Beispiel #8
0
        public DelegationModel(Delegation delegation) : this()
        {
            if (delegation != null)
            {
                ModuleName           = delegation.ModuleName;
                VietnameseModuleName = delegation.VietnameseModuleName;
                FromDate             = delegation.FromDate.ToString(StringConstant.DateFormatddMMyyyyHHmm);
                ToDate = delegation.ToDate.ToString(StringConstant.DateFormatddMMyyyyHHmm);
                if (delegation.ToEmployee != null)
                {
                    ToEmployee.AddRange(delegation.ToEmployee.Select(item => new LookupItemModel {
                        LookupId = item.LookupId, LookupValue = item.LookupValue
                    }));
                }

                Requester = new LookupItemModel {
                    LookupId = (delegation.Requester != null ? delegation.Requester.LookupId : 0), LookupValue = (delegation.Requester != null ? delegation.Requester.LookupValue : string.Empty)
                };
                Department = new LookupItemModel {
                    LookupId = (delegation.Department != null ? delegation.Department.LookupId : 0), LookupValue = (delegation.Department != null ? delegation.Department.LookupValue : string.Empty)
                };

                EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Site.Url);
                FromEmployee = _employeeInfoDAL.GetByID(delegation.FromEmployee.LookupId).ADAccount;
            }
        }
        /// <summary>
        /// An item is being added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);
            try
            {
                SPListItem curItem = properties.ListItem;

                var departmentRepo = new DepartmentDAL(properties.Site.Url);
                departmentRepo.CreateDepartmentSite(properties.SiteId, properties.Web.ID, curItem);

                // Add bod approver to BOD group
                var userBodString = Convert.ToString(properties.ListItem[StringConstant.DepartmentList.BODField]);
                if (!string.IsNullOrEmpty(userBodString))
                {
                    var employeeInfoRepo = new EmployeeInfoDAL(properties.Site.Url);
                    employeeInfoRepo.AddUserToGroup(properties.Site.ID, properties.Web.ID, curItem, StringConstant.Group.BODGroupName, userBodString);
                }
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Event Receiver - ItemAdded fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
            }
        }
        /// <summary>
        ///     Load data
        /// </summary>
        /// <returns>model in form</returns>
        protected void LoadData()
        {
            var isCurrentUserInCommonGroup = false;

            if (Page.Session[SessionKey.IsCurrentUserInCommonGroup] != null)
            {
                bool.TryParse(Page.Session[SessionKey.IsCurrentUserInCommonGroup].ToString(), out isCurrentUserInCommonGroup);
            }
            else
            {
                isCurrentUserInCommonGroup = UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts);
                Page.Session[SessionKey.IsCurrentUserInCommonGroup] = isCurrentUserInCommonGroup;
            }

            // if (!SPContext.Current.Web.CurrentUser.IsSiteAdmin && UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts))
            if (!SPContext.Current.Web.CurrentUser.IsSiteAdmin && isCurrentUserInCommonGroup)
            {
                var employeeInfo = UserPermission.GetEmployeeInfo();

                // Common user alreay logged in
                if (employeeInfo != null)
                {
                    EmployeeNameLiteral.Text = employeeInfo.FullName;
                    ScriptManager.RegisterStartupScript(this, GetType(), "ShowWelcomeCommon", "showWelcomeCommon();", true);
                    employeeInfo.Image = string.Empty;
                    this._employeeInfo = employeeInfo;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "hideWelcomeCommon", "hideWelcomeCommon();", true);
                }
            }
            else
            {
                try
                {
                    var employee = Page.Session[WelcomeCommonUser_EmployeeInfo_Session_Key] as EmployeeInfo;

                    if (employee == null)
                    {
                        EmployeeInfoDAL employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Site.Url);
                        //DepartmentDAL departmentDAL = new DepartmentDAL(SPContext.Current.Site.Url);
                        employee = employeeInfoDAL.GetByADAccount(SPContext.Current.Web.CurrentUser.ID);
                        if (employee != null)
                        {
                            employee.Image     = string.Empty;
                            this._employeeInfo = employee;
                            Page.Session[WelcomeCommonUser_EmployeeInfo_Session_Key] = employee;
                        }
                    }
                    else
                    {
                        this._employeeInfo = employee;
                    }
                }
                catch { }

                ScriptManager.RegisterStartupScript(this, GetType(), "showWelcome", "showWelcome();", true);
            }
        }
        /// <summary>
        /// Get list of delegated employees from employee.
        /// </summary>
        /// <param name="siteUrl">The current site url.</param>
        /// <param name="fromEmployeeId">The employ id who is processing for this task.</param>
        /// <param name="listUrl">The url of list object. For example: /Lists/Requests, /Lists/Recruitments</param>
        /// <param name="itemId">The id of SPListItem (task).</param>
        /// <returns>If return value is not null, that meaning this from employee id has delegation, return delegated employee (To Employee). Otherwise null value.</returns>
        public static List <EmployeeInfo> GetListOfDelegatedEmployees(string siteUrl, int fromEmployeeId, string listUrl, int itemId)
        {
            List <EmployeeInfo> toEmployees = null;

            var delegationOfNewTasks = HasDelegationOfNewTasks(fromEmployeeId, listUrl, siteUrl);

            if (delegationOfNewTasks != null)
            {
                List <int> employeeIds = new List <int>();
                foreach (var delegationOfNewTask in delegationOfNewTasks)
                {
                    if (delegationOfNewTask.ToEmployee != null && delegationOfNewTask.ToEmployee.Count > 0)
                    {
                        employeeIds.AddRange(delegationOfNewTask.ToEmployee.Select(e => e.LookupId).ToList());
                    }
                }

                if (employeeIds.Count > 0)
                {
                    employeeIds = employeeIds.Distinct().ToList();
                    var employeeInfoDAL = new EmployeeInfoDAL(siteUrl);
                    toEmployees = employeeInfoDAL.GetByIDs(employeeIds);
                }
            }

            return(toEmployees);
        }
        /// <summary>
        /// An item was Updated.
        /// </summary>
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);

            SPListItem curItem          = properties.ListItem;
            var        employeeInfoRepo = new EmployeeInfoDAL(properties.Site.Url);

            employeeInfoRepo.UpdateUserGroupPermission(properties.Site.ID, properties.Web.ID, curItem);
        }
        /// <summary>
        /// Validate current password and Username is existed in Employee info list
        /// </summary>
        /// <param name="model">A ChangePasswordModel store data</param>
        /// <returns>A string as message error</returns>
        protected bool ValidateCurrentPassword(ChangePasswordModel model)
        {
            // Check Current Password
            EmployeeInfoDAL employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Web.Url);
            EmployeeInfo    employeeInfo    = employeeInfoDAL.GetByEmployeeID(model.EmployeeID);
            var             isValid         = employeeInfo != null && StringCipher.VerifyMd5Hash(model.CurrentPassword, employeeInfo.Password);

            return(isValid);
        }
        public OvertimeService()
        {
            var webUrl = SPContext.Current.Web.Url;

            _overTimeManagementDAL       = new OverTimeManagementDAL(webUrl);
            _overTimeManagementDetailDAL = new OverTimeManagementDetailDAL(webUrl);
            _notOvertimeManagementDal    = new NotOvertimeManagementDAL(webUrl);
            _employeeInfoDAL             = new EmployeeInfoDAL(webUrl);
        }
        /// <summary>
        /// Get current logined user
        /// </summary>
        /// <returns></returns>
        /// CALL URL: _vti_bin/Services/Employee/EmployeeService.svc/GetCurrentUser
        public CurrentUserModel GetCurrentUser()
        {
            try
            {
                CurrentUserModel user = new CurrentUserModel();
                //Get Current Login User
                SPUser spUser = SPContext.Current.Web.CurrentUser;
                if (spUser.IsSiteAdmin)
                {
                    user.IsSystemAdmin = true;
                    //return user;
                }

                var          employeeDal     = new EmployeeInfoDAL(SPContext.Current.Web.Url);
                EmployeeInfo currentEmployee = HttpContext.Current.Session[StringConstant.SessionString.EmployeeLogedin] as EmployeeInfo;

                if (currentEmployee == null)
                {
                    if (spUser != null)
                    {
                        int currentLoginName = spUser.ID;
                        currentEmployee = employeeDal.GetByADAccount(currentLoginName);
                    }
                }

                if (currentEmployee != null)
                {
                    user = new CurrentUserModel()
                    {
                        ID               = currentEmployee.ID,
                        EmployeeID       = currentEmployee.EmployeeID,
                        Department       = LookupItemModel.ConvertFromEntity(currentEmployee.Department),
                        Location         = LookupItemModel.ConvertFromEntity(currentEmployee.FactoryLocation),
                        FullName         = currentEmployee.FullName,
                        EmployeePosition = (currentEmployee.EmployeePosition != null && currentEmployee.EmployeePosition.LookupId > 0) ? currentEmployee.EmployeePosition.LookupId : 0
                    };
                    if (user.Department != null && user.Department.LookupId > 0)
                    {
                        var departmentDetail = _departmentDAL.GetByID(user.Department.LookupId);
                        if (departmentDetail != null)
                        {
                            user.IsBODApprovalRequired = departmentDetail.IsBODApprovalRequired;
                        }
                    }
                }
                return(user);
            }
            catch (Exception ex)
            {
                SPDiagnosticsService.Local.WriteTrace(0,
                                                      new SPDiagnosticsCategory("STADA - Employee Service - GetCurrentUser fn",
                                                                                TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                                                      string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
                return(null);
            }
        }
Beispiel #16
0
        public Delegation GetDelegationListItem(SPListItem listItem, SPWeb currentWeb)
        {
            ChangeShiftManagement changeShiftManagement = this.ParseToEntity(listItem);

            EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(this.SiteUrl);
            EmployeeInfo    fromEmployee     = _employeeInfoDAL.GetByADAccount(changeShiftManagement.DepartmentHead.ID);
            Delegation      delegation       = new Delegation(changeShiftManagement, fromEmployee, currentWeb);

            return(delegation);
        }
        /// <summary>
        /// An item is Deleting.
        /// </summary>
        public override void ItemDeleting(SPItemEventProperties properties)
        {
            base.ItemDeleting(properties);

            SPListItem curItem = properties.ListItem;

            var employeeInfoRepo = new EmployeeInfoDAL(properties.Site.Url);

            employeeInfoRepo.RemoveUserFromGroupPermission(properties.Site.ID, properties.Web.ID, curItem);
        }
        public EmployeeService()
        {
            var url = SPContext.Current.Web.Url;

            _employeeInfoDAL             = new EmployeeInfoDAL(url);
            _departmentDAL               = new DepartmentDAL(url);
            _overtimeManagementDAL       = new OverTimeManagementDAL(url);
            _overtimeManagementDetailDAL = new OverTimeManagementDetailDAL(url);
            _employeePositionDAL         = new EmployeePositionDAL(url);
        }
Beispiel #19
0
        public Delegation GetDelegationListItem(SPListItem listItem, SPWeb currentWeb)
        {
            NotOvertimeManagement notOvertimeManagement = this.ParseToEntity(listItem);

            EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(this.SiteUrl);
            var             fromEmployee     = _employeeInfoDAL.GetByADAccount(notOvertimeManagement.DH.ID);
            Delegation      delegation       = new Delegation(notOvertimeManagement, fromEmployee, currentWeb);

            return(delegation);
        }
 public EmailService()
 {
     WebUrl                    = SPContext.Current.Web.Url;
     _emailTemplateDAL         = new EmailTemplateDAL(WebUrl);
     _employeeDAL              = new EmployeeInfoDAL(WebUrl);
     _changeShiftManagementDAL = new ChangeShiftManagementDAL(WebUrl);
     _notOvertimeMangementDAL  = new NotOvertimeManagementDAL(WebUrl);
     _shiftTimeDAL             = new ShiftTimeDAL(WebUrl);
     _sendMailActivity         = new SendEmailActivity();
 }
 private void InitObjects()
 {
     this.employeeInfoDAL = new EmployeeInfoDAL(this.SiteUrl);
     this.InitCurrentEmployeeInfoObject();
     this.employeePositionDAL            = new EmployeePositionDAL(this.SiteUrl);
     this.delegationModulesDAL           = new DelegationModulesDAL(this.SiteUrl);
     this.delegationEmployeePositionsDAL = new DelegationEmployeePositionsDAL(this.SiteUrl);
     this.delegationsOfNewTaskDAL        = new DelegationsOfNewTaskDAL(this.SiteUrl);
     this.delegationsDAL = new DelegationsDAL(this.SiteUrl);
     this.departmentDAL  = new DepartmentDAL(this.SiteUrl);
 }
Beispiel #22
0
 private void InitEmployeeDAL(SPWeb currentWeb)
 {
     if (currentWeb == null)
     {
         currentWeb = SPContext.Current.Web;
     }
     if (_employeeInfoDAL == null)
     {
         _employeeInfoDAL = new EmployeeInfoDAL(currentWeb.Url);
     }
 }
        //public override void ItemUpdated(SPItemEventProperties properties)
        //{
        //    base.ItemUpdated(properties);
        //    try
        //    {
        //        //_employeeInfoDAL = new EmployeeInfoDAL(properties.WebUrl);
        //        //var itemId = properties.ListItem.ID;
        //        //string modifiedByName = string.Empty;
        //        //var modifiedByString = Convert.ToString(properties.ListItem["Modified By"]);
        //        //SPFieldUser spUserField = (SPFieldUser)properties.ListItem.Fields.GetField("Modified By");
        //        //if (spUserField != null)
        //        //{
        //        //    SPFieldUserValue spNewUserFieldValue = (SPFieldUserValue)spUserField.GetFieldValue(modifiedByString);
        //        //    SPUser spModifiedByUser = properties.Web.EnsureUser(spNewUserFieldValue.LookupValue);
        //        //    var modifiedBy = _employeeInfoDAL.GetByADAccount(spModifiedByUser.ID);
        //        //    modifiedByName = modifiedBy != null ? modifiedBy.FullName : string.Empty;
        //        //}

        //        //SendEmailToApprover(properties.Web, itemId, modifiedByName);
        //    }
        //    catch (Exception ex)
        //    {
        //        ULSLogging.Log(new SPDiagnosticsCategory("STADA -  Shift Management Event Receiver - ItemUpdated fn",
        //            TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
        //        string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
        //    }
        //}

        private void SendEmailToApprover(SPWeb web, int itemId, string modifiedBy = "")
        {
            EmployeeInfoDAL    employeeInfoDAL    = new EmployeeInfoDAL(web.Url);
            EmailTemplateDAL   emailTemplateDAL   = new EmailTemplateDAL(web.Url);
            ShiftManagementDAL shiftManagementDAL = new ShiftManagementDAL(web.Url);

            var shiftManagementItem = shiftManagementDAL.GetByID(itemId);

            if (shiftManagementItem != null)
            {
                SPUser departmentHeadSPUser = web.EnsureUser(shiftManagementItem.ApprovedBy.UserName);

                var departmentHead = employeeInfoDAL.GetByADAccount(departmentHeadSPUser.ID);
                if (departmentHead != null)
                {
                    var requestEmailItem = emailTemplateDAL.GetByKey("ShiftManagement_Request");
                    if (requestEmailItem != null)
                    {
                        string emailBody = HTTPUtility.HtmlDecode(requestEmailItem.MailBody);
                        if (!string.IsNullOrEmpty(departmentHead.Email) && !string.IsNullOrEmpty(emailBody))
                        {
                            string link       = string.Format("{0}/SitePages/ShiftApproval.aspx?itemId={1}&Source={0}/_layouts/15/RBVH.Stada.Intranet.WebPages/ShiftManagement/ShiftManagementManager.aspx", web.Url, shiftManagementItem.ID);
                            var    department = DepartmentListSingleton.GetDepartmentByID(shiftManagementItem.Department.LookupId, web.Url);
                            emailBody = string.Format(emailBody, departmentHead.FullName, string.IsNullOrEmpty(modifiedBy) ? shiftManagementItem.Requester.LookupValue : modifiedBy, shiftManagementItem.Month,
                                                      shiftManagementItem.Year, shiftManagementItem.Department.LookupValue, department.VietnameseName);

                            emailBody = emailBody.Replace("#link", link);
                            _sendMailActivity.SendMail(web.Url, requestEmailItem.MailSubject, departmentHead.Email, true, false, emailBody);

                            List <EmployeeInfo> toUsers = DelegationPermissionManager.GetListOfDelegatedEmployees(web.Url, departmentHead.ID, StringConstant.ShiftManagementList.ListUrl, shiftManagementItem.ID);
                            link = string.Format("{0}/SitePages/ShiftApproval.aspx?subSection=ShiftManagement&itemId={1}&Source=/_layouts/15/RBVH.Stada.Intranet.WebPages/DelegationManagement/DelegationList.aspx&Source=Tab=DelegationsApprovalTab", web.Url, shiftManagementItem.ID);
                            if (toUsers != null)
                            {
                                foreach (var toUser in toUsers)
                                {
                                    try
                                    {
                                        if (!string.IsNullOrEmpty(toUser.Email))
                                        {
                                            emailBody = HTTPUtility.HtmlDecode(requestEmailItem.MailBody);
                                            emailBody = string.Format(emailBody, toUser.FullName, string.IsNullOrEmpty(modifiedBy) ? shiftManagementItem.Requester.LookupValue : modifiedBy, shiftManagementItem.Month,
                                                                      shiftManagementItem.Year, shiftManagementItem.Department.LookupValue, department.VietnameseName);
                                            emailBody = emailBody.Replace("#link", link);
                                            _sendMailActivity.SendMail(web.Url, requestEmailItem.MailSubject, toUser.Email, true, false, emailBody);
                                        }
                                    }
                                    catch { }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #24
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public DataTable GetEmployeeInfoAll()
 {
     try
     {
         EmployeeInfoDAL objEmployeeInfoDAL = new EmployeeInfoDAL();
         return(objEmployeeInfoDAL.GetEmployeeInfoAll());
     }
     catch (Exception exp)
     {
         throw (exp);
     }
 }
Beispiel #25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="objEmployeeInfo"></param>
 /// <returns></returns>
 public string SaveEmployeeInfo(EmployeeInfo objEmployeeInfo)
 {
     try
     {
         EmployeeInfoDAL objEmployeeInfoDAL = new EmployeeInfoDAL();
         return(objEmployeeInfoDAL.InsertEmployeeInfo(objEmployeeInfo));
     }
     catch (Exception exp)
     {
         throw (exp);
     }
 }
Beispiel #26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="objEmployeeInfo"></param>
 /// <returns></returns>
 public string EditEmployeeInfo(EmployeeInfo objEmployeeInfo)
 {
     try
     {
         EmployeeInfoDAL objEmployeeInfoDAL = new EmployeeInfoDAL();
         return(objEmployeeInfoDAL.UpdateEmployeeInfo(objEmployeeInfo));
     }
     catch (Exception exp)
     {
         throw (exp);
     }
 }
Beispiel #27
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="objEmployeeInfo"></param>
 /// <returns></returns>
 public string RemoveEmployeeInfo(int empGid)
 {
     try
     {
         EmployeeInfoDAL objEmployeeInfoDAL = new EmployeeInfoDAL();
         return(objEmployeeInfoDAL.DeleteEmployeeInfo(empGid));
     }
     catch (Exception exp)
     {
         throw (exp);
     }
 }
Beispiel #28
0
 public static string[] GetFacilityNames(string prefixText, int count)
 {
     EmployeeInfoDAL emp_Info = new EmployeeInfoDAL();
     List<string> emp_List = new List<string>();
     emp_Info = new EmployeeInfoDAL();
     emp_List.Clear();
     DataTable _Names = emp_Info.get_LocationNames(prefixText);
     foreach (DataRow dr in _Names.Rows)
     {
         emp_List.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dr[0].ToString(), dr[2].ToString()));
     }
     return emp_List.ToArray();
 }
        /// <summary>
        /// To check current employee who has delegation permission.
        /// </summary>
        /// <returns>If return true, current employee has delegation permission. Otherwise return false.</returns>
        public static bool DoesCurrentEmployeeHasDelegationPermission()
        {
            var res = false;

            // Administrator
            if (SPContext.Current.Web.CurrentUser.IsSiteAdmin)
            {
                res = true;
            }
            else    // User
            {
                #region User

                if (delegationEmployeePositionsDAL == null)
                {
                    delegationEmployeePositionsDAL = new DelegationEmployeePositionsDAL(SPContext.Current.Web.Url);
                }

                EmployeeInfo currentEmployeeInfo = HttpContext.Current.Session[StringConstant.EmployeeLogedin] as EmployeeInfo;

                //User is not common account, we should get from employee list
                if (currentEmployeeInfo == null)
                {
                    SPUser spUser = SPContext.Current.Web.CurrentUser;
                    if (spUser != null)
                    {
                        EmployeeInfoDAL employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Web.Url);
                        currentEmployeeInfo = employeeInfoDAL.GetByADAccount(spUser.ID);
                        //HttpContext.Current.Session[StringConstant.EmployeeLogedin] = currentEmployeeInfo;
                    }
                }

                if (currentEmployeeInfo != null)
                {
                    if (currentEmployeeInfo.EmployeePosition != null)
                    {
                        var employeePositionId          = currentEmployeeInfo.EmployeePosition.LookupId;
                        var delegationEmployeePositions = delegationEmployeePositionsDAL.GetByEmployeePosition(employeePositionId);
                        if (delegationEmployeePositions != null && delegationEmployeePositions.Count > 0)
                        {
                            res = true;
                        }
                    }
                }

                #endregion
            }

            return(res);
        }
Beispiel #30
0
        public BusinessTripManagementApprover CreateApprovalList(int departmentId, int locationId)
        {
            BusinessTripManagementApprover businessTripManagementApprover = new BusinessTripManagementApprover();

            EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(this.SiteUrl);
            // Department Head
            var departmentHead = _employeeInfoDAL.GetByPositionDepartment(Constants.StringConstant.EmployeePosition.DepartmentHead, departmentId, locationId);

            if (departmentHead.Count > 0)
            {
                businessTripManagementApprover.Approver1 = departmentHead[0];
            }

            // Direct BOD
            if (businessTripManagementApprover.Approver1 != null && businessTripManagementApprover.Approver1.Manager != null && businessTripManagementApprover.Approver1.Manager.LookupId > 0)
            {
                var directBODInfo = _employeeInfoDAL.GetByID(businessTripManagementApprover.Approver1.Manager.LookupId);
                if (directBODInfo != null)
                {
                    businessTripManagementApprover.Approver2 = directBODInfo;
                }
            }

            // BOD
            var bodImployeeInfo = _employeeInfoDAL.GetByEmployeeID("11009"); // Ms. Su

            if (bodImployeeInfo != null)
            {
                businessTripManagementApprover.Approver3 = bodImployeeInfo;
            }

            // Department Head of HC
            int departmentIdHC = DepartmentListSingleton.GetDepartmentByCode("HR", SiteUrl).ID;

            if (departmentIdHC != departmentId)
            {
                var departmentHeadOfHC = _employeeInfoDAL.GetByPositionDepartment(Constants.StringConstant.EmployeePosition.DepartmentHead, departmentIdHC, locationId);
                if (departmentHeadOfHC.Count > 0)
                {
                    businessTripManagementApprover.Approver4 = departmentHeadOfHC[0];
                }
            }

            if (businessTripManagementApprover.Approver2 == null)
            {
                businessTripManagementApprover.Approver2 = businessTripManagementApprover.Approver3;
            }

            return(businessTripManagementApprover);
        }
Beispiel #31
0
        public DelegationModel(Delegation delegation) : this()
        {
            if (delegation != null)
            {
                ModuleName           = delegation.ModuleName;
                VietnameseModuleName = delegation.VietnameseModuleName;
                FromDate             = delegation.FromDate.ToString(StringConstant.DateFormatddMMyyyyHHmm);
                ToDate     = delegation.ToDate.ToString(StringConstant.DateFormatddMMyyyyHHmm);
                ToEmployee = delegation.ToEmployee;
                Requester  = delegation.Requester;
                Department = delegation.Department;

                EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(SPContext.Current.Site.Url);
                FromEmployee = _employeeInfoDAL.GetByID(delegation.FromEmployee.LookupId).ADAccount;
            }
        }
Beispiel #32
0
 public void provRoles()
 {
     try
     {
         EmployeeInfoDAL emp_Info = new EmployeeInfoDAL();
         ddlempRole.DataTextField = "Role";
         ddlempRole.DataValueField = "Role_Code";
         ddlempRole.DataSource = (DataTable)emp_Info.getUserRole();
         ddlempRole.DataBind();
     }
     catch (Exception ex)
     {
         objNLog.Error("Error : " + ex.Message);
     }
 }
Beispiel #33
0
    public void publishEMPData(int empID)
    {
        try
        {
            EmployeeInfoDAL EMP_data = new EmployeeInfoDAL();
            EmployeeInfo EMP_Info = new EmployeeInfo();
            DataTable dtEmpData = new DataTable();

            dtEmpData = EMP_data.get_EMPDataByID(empID);

            if (dtEmpData.Rows.Count > 0)
            {
                hdnEmpID.Value = dtEmpData.Rows[0]["Emp_ID"].ToString();
                txtAddress1.Text = dtEmpData.Rows[0]["Emp_Address"].ToString();
                txtAddress2.Text = dtEmpData.Rows[0]["Emp_Address2"].ToString();
                txtCity.Text = dtEmpData.Rows[0]["Emp_City"].ToString();
                txtComments.Text = dtEmpData.Rows[0]["Emp_Comments"].ToString();
                txtemail.Text = dtEmpData.Rows[0]["Emp_Email"].ToString();
                txtempFName.Text = dtEmpData.Rows[0]["Emp_FName"].ToString();
                txtempLName.Text = dtEmpData.Rows[0]["Emp_LName"].ToString();
                txtempMName.Text = dtEmpData.Rows[0]["Emp_MName"].ToString();
                DateTime dt = DateTime.Parse(dtEmpData.Rows[0]["Emp_HireDate"].ToString());
                txtHireDate.Text = dt.Date.ToShortDateString();
                txtHomePhone.Text = dtEmpData.Rows[0]["Emp_HomePhone"].ToString();
                string str = dtEmpData.Rows[0]["Emp_LocID"].ToString();
                if (str != "")
                {
                    int LocID = (int)dtEmpData.Rows[0]["Emp_LocID"];//location
                    txtLoc.Text = EMP_data.get_LocationByID(LocID).Rows[0]["Facility_Name"].ToString();
                }

                string sup1 = dtEmpData.Rows[0]["Emp_SupID1"].ToString();
                if (sup1 != "")
                {
                    int Emp_Sup = (int)dtEmpData.Rows[0]["Emp_SupID1"];
                    txtSup1.Text = EMP_data.get_EMPSupName(Emp_Sup).Rows[0]["Emp_SupName"].ToString();
                }

                string sup2 = dtEmpData.Rows[0]["Emp_SupID2"].ToString();
                if (sup2 != "")
                {
                    int Emp_Sup = (int)dtEmpData.Rows[0]["Emp_SupID2"];
                    txtSup2.Text = EMP_data.get_EMPSupName(Emp_Sup).Rows[0]["Emp_SupName"].ToString();
                }

                txtPhone.Text = dtEmpData.Rows[0]["Emp_Phone"].ToString();
                txtState.Text = dtEmpData.Rows[0]["Emp_State"].ToString();
                DateTime dt2 = DateTime.Parse(dtEmpData.Rows[0]["Emp_TermDate"].ToString());
                txtTDate.Text = dt2.ToShortDateString();
                txtTitle.Text = dtEmpData.Rows[0]["Emp_Email"].ToString();//Title
                txtZip.Text = dtEmpData.Rows[0]["Emp_Zip"].ToString();
                ddlApprov.SelectedValue = dtEmpData.Rows[0]["Emp_IS_Approver_Y_N"].ToString();
                ddlempRole.SelectedValue = dtEmpData.Rows[0]["Emp_Role"].ToString();
                ddlStatus.SelectedValue = dtEmpData.Rows[0]["Emp_Status"].ToString();

                if (dtEmpData.Rows[0]["Emp_TitleID"].ToString() != "")
                {
                    int TitleID = int.Parse(dtEmpData.Rows[0]["Emp_TitleID"].ToString());
                    txtTitle.Text = EMP_data.get_TitleByID(TitleID).Rows[0]["Title_Name"].ToString();
                }
                txtemail.Text = dtEmpData.Rows[0]["Emp_Email"].ToString();

            }
            else
            {
                string script = @"alert('No records found');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "jsCall", script, true);
            }
        }
        catch (Exception ex)
        {
            objNLog.Error("Error : " + ex.Message);
        }
    }
Beispiel #34
0
    protected void btnDelete_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            string userID = (string)Session["User"];
            EmployeeInfoDAL EMP_data = new EmployeeInfoDAL();
            EmployeeInfo EMP_Info = new EmployeeInfo();
            EMP_Info.EMPID = int.Parse(hdnEmpID.Value.ToString());

            int flag = EMP_data.DeleteEMPData(EMP_Info, userID);
            if (flag == 1)
            {
                string script = @"alert('Employee Info Deleted Successfully...');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "jsCall", script, true);
                Cleartxt();
            }
            else
            {
                string script = @"alert('Failed To Delete Employee Info...');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "jsCall", script, true);
            }
        }
        catch (Exception ex)
        {
            objNLog.Error("Error : " + ex.Message);
        }
    }
Beispiel #35
0
    protected void btnTitleSave_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            EmployeeInfoDAL EMP_data = new EmployeeInfoDAL();
            EmployeeInfo EMP_Info = new EmployeeInfo();
            EMP_Info.Title = txtNewTitle.Text;
            EMP_Info.TitleDesc = txtDesc.Text;
            if (ddlTimeEntry.SelectedItem.Text == "Yes")
                EMP_Info.TimeEntry = Convert.ToChar("Y");
            else
                EMP_Info.TimeEntry = Convert.ToChar("N");

            string str = EMP_data.set_Title(EMP_Info);
            string script = @"alert('" + str + "');";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "jsCall", script, true);
            txtNewTitle.Text = string.Empty;
            txtDesc.Text = string.Empty;
            PnlTitle.Visible = false;
            chkTitle.Checked = false;
        }
        catch (Exception ex)
        {
            objNLog.Error("Error : " + ex.Message);
        }
    }
Beispiel #36
0
    protected void btnUpdate_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            EmployeeInfoDAL EMP_data = new EmployeeInfoDAL();
            EmployeeInfo EMP_Info = new EmployeeInfo();
            DataTable dtEmpData = new DataTable();
            EMP_Info.Address1 = txtAddress1.Text;
            EMP_Info.Address2 = txtAddress2.Text;
            EMP_Info.City = txtCity.Text;
            EMP_Info.Comments = txtComments.Text;
            EMP_Info.EMail = txtemail.Text;

            EMP_Info.EMPHireDate = DateTime.Parse(txtHireDate.Text);
            EMP_Info.EMPID = int.Parse(hdnEmpID.Value.ToString());

            if (txtTDate.Text != "")
                EMP_Info.EMPTermDate = DateTime.Parse(txtTDate.Text);
            EMP_Info.IsApprove = ddlApprov.SelectedValue.ToString();

            if (txtSup1.Text != "")
            {
                string[] arInfo1 = new string[2];
                char[] splitter1 = { ',' };
                arInfo1 = txtSup1.Text.Split(splitter1);
                EMP_Info.EMPLName = arInfo1[0].ToString();
                EMP_Info.EMPFName = arInfo1[1].ToString();
                dtEmpData = EMP_data.get_EMPDataByNames(EMP_Info);

                if (dtEmpData.Rows.Count > 0)
                {
                    EMP_Info.EMPSup1 = int.Parse(dtEmpData.Rows[0]["Emp_ID"].ToString());
                }
                else
                {
                    string script = @"alert(Supervisor1 donot exist);";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "jsCall", script, true);

                }
            }
            if (txtSup2.Text != "")
            {
                string[] arInfo2 = new string[2];
                char[] splitter2 = { ',' };
                arInfo2 = txtSup2.Text.Split(splitter2);
                EMP_Info.EMPLName = arInfo2[0].ToString();
                EMP_Info.EMPFName = arInfo2[1].ToString();
                dtEmpData = EMP_data.get_EMPDataByNames(EMP_Info);

                if (dtEmpData.Rows.Count > 0)
                {
                    EMP_Info.EMPSup2 = int.Parse(dtEmpData.Rows[0]["Emp_ID"].ToString());
                }
                else
                {
                    string script = @"alert(Supervisor2 donot exist);";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "jsCall", script, true);

                }

            }

            EMP_Info.EMPFName = txtempFName.Text;
            EMP_Info.EMPLName = txtempLName.Text;
            EMP_Info.EMPMName = txtempMName.Text;

            if (txtLoc.Text != "")
            {
                EMP_Info.LocationID = int.Parse(EMP_data.get_LocationNamesByName(txtLoc.Text).Rows[0]["Facility_ID"].ToString());
            }
            EMP_Info.Pat_CellPhone = txtHomePhone.Text;
            EMP_Info.Phone = txtPhone.Text;
            EMP_Info.Role = ddlempRole.SelectedValue.ToString();
            EMP_Info.State = txtState.Text;
            EMP_Info.Status = ddlStatus.SelectedValue.ToString();
            if (txtTitle.Text != "")
            {
                EMP_Info.TitleID = int.Parse(EMP_data.get_TitleNamesByNames(txtTitle.Text).Rows[0]["Title_ID"].ToString());
            }
            EMP_Info.ZIP = txtZip.Text;
            string userID = (string)Session["User"];
            int flag = EMP_data.update_EmpInfo(EMP_Info,userID);
            if (flag == 1)
            {
                string script2 = @"alert('Employee Info Updated Successfully...');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "jsCall", script2, true);
                Cleartxt();
            }
            else
            {
                string script2 = @"alert('Failed To Update Employee Info...');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "jsCall", script2, true);
            }
        }
        catch (Exception ex)
        {
            objNLog.Error("Error : " + ex.Message);
        }
    }