예제 #1
0
        /// <summary>
        /// Process submit action
        /// 1. Get data from layout
        /// 2. Validate -> show error message?
        /// 3. Update Password -> show success / error message?
        /// </summary>
        protected void OnOK()
        {
            // 1. Get data from layout
            // 2. Validate -> show error message?
            // 3. Update Password -> show success or error message?
            var model = GetDataFromLayout();

            if (Validate(model))
            {
                bool isSuccess = UpdateNewPassword(model);
                if (isSuccess)
                {
                    NotificationStatusHelper.SetInformationStatus(Page.Form,
                                                                  WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleSuccess),
                                                                  WebPageResourceHelper.GetResourceString(
                                                                      StringConstant.ResourcesKeyResetPasswordMessageSuccess));
                    //var message = WebPageResourceHelper.GetResourceString(StringConstant.ResourcesKeyResetPasswordMessageSuccess);
                    //Response.Write($"<script>alert('{message}');</script>");
                    //this.ShowMessageSuccess(MessageSuccessResetPasswordSuccess);
                }
                else
                {
                    NotificationStatusHelper.SetErrorStatus(Page.Form,
                                                            WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError),
                                                            WebPageResourceHelper.GetResourceString(
                                                                StringConstant.ResourcesKeyResetPasswordMessageUnsuccess));
                    // ShowMessageError(MessageErrorResetPasswordUnsuccess);
                }
            }
            else
            {
                // Validate fail!
            }
        }
예제 #2
0
        /// <summary>
        /// Process submit action
        /// 1. Get data from layout
        /// 2. Validate -> show error message?
        /// 3. Check Login
        /// </summary>
        protected void OnVerify()
        {
            // 1. Get data from layout
            // 2. Validate -> show error message?
            // 3. Check Login -> Redirect to Overview Page or show error message?
            var model = GetDataFromLayout();

            if (!Page.IsValid)
            {
                return;
            }
            bool isSuccess = CheckLogin(model);

            if (isSuccess)
            {
                // Store session IsManager
                bool isManager = !UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts);
                HttpContext.Current.Session[StringConstant.IsAdmin] = isManager;

                // Redirect to Overview Page
                Response.Redirect(StringConstant.PageOverviewURL);
            }
            else
            {
                NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcesKeyLoginMessageFail));
            }
        }
예제 #3
0
        /// <summary>
        /// ShowExpiredMessage
        /// </summary>
        /// <param name="expiredDate"></param>
        private void ShowExpiredMessage(DateTime expiredDate)
        {
            var requestExpiredMsgFormat = WebPageResourceHelper.GetResourceString("RequestExpiredMsgFormat");

            requestExpiredMsgFormat = HttpUtility.UrlDecode(requestExpiredMsgFormat);
            var expiredDateString = expiredDate.ToString(StringConstant.DateFormatddMMyyyy2);
            var message           = string.Format(requestExpiredMsgFormat, expiredDateString);

            this.ShowClientMessage(message);
        }
예제 #4
0
 /// <summary>
 /// Event delegate call On OK
 /// </summary>
 /// <param name="sender">A object sender</param>
 /// <param name="e">A System.EventArgs store data</param>
 protected void Button_OK_Click(object sender, EventArgs e)
 {
     try
     {
         OnOK();
     }
     catch (Exception ex)
     {
         // Write log to SharePoint
         ULSLogging.LogError(ex);
         NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralMessageError));
     }
 }
        private string GetRequestStatusMessage(OverTimeManagement currentItem)
        {
            string msgResult = "";

            string currentStatus = currentItem.ApprovalStatus.ToLower();

            if (currentStatus == "true")
            {
                msgResult = WebPageResourceHelper.GetResourceString("RequestStatusApproved");
            }
            else if (currentStatus == "false")
            {
                msgResult = WebPageResourceHelper.GetResourceString("RequestStatusRejected");
            }

            return(msgResult);
        }
예제 #6
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender">A objects sender </param>
        /// <param name="e">A System.EventArgs that contains the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Check postback
                if (!Page.IsPostBack)
                {
                    FirstLoad();
                }
            }
            catch (Exception ex)
            {
                // Write log to SharePoint
                ULSLogging.LogError(ex);

                NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralMessageError));
            }
        }
예제 #7
0
        /// <summary>
        /// Process submit action
        /// 1. Get data from layout
        /// 2. Validate -> show error message?
        /// 3. Update Password -> show success / error message?
        /// </summary>
        protected void OnOK()
        {
            // 1. Get data from layout
            // 2. Validate -> show error message?
            // 3. Update Password -> show success / error message?
            var model = GetDataFromLayout();

            if (!Page.IsValid)
            {
                return;
            }
            bool currentPasswordValid = ValidateCurrentPassword(model);

            if (!currentPasswordValid)
            {
                NotificationStatusHelper.SetErrorStatus(Page.Form,
                                                        WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError),
                                                        WebPageResourceHelper.GetResourceString(
                                                            StringConstant.ResourcesKeyChangePasswordCurrentPasswordIsInValid));
            }
            else
            {
                bool isSuccess = UpdateNewPassword(model);
                if (!isSuccess)
                {
                    NotificationStatusHelper.SetErrorStatus(Page.Form,
                                                            WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleSuccess),
                                                            WebPageResourceHelper.GetResourceString(
                                                                StringConstant.ResourcesKeyChangePasswordMessageUnsuccess));
                }
                else
                {
                    NotificationStatusHelper.SetInformationStatus(Page.Form,
                                                                  WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleSuccess),
                                                                  WebPageResourceHelper.GetResourceString(
                                                                      StringConstant.ResourcesKeyChangePasswordMessageSuccess));

                    //Log out
                    //Response.Redirect(StringConstant.PageLogoutURL);
                    SPUtility.Redirect(StringConstant.PageLogoutURL, SPRedirectFlags.DoNotEndResponse | SPRedirectFlags.Trusted, HttpContext.Current);
                }
            }
        }
예제 #8
0
        /// <summary>
        /// Process submit action
        /// 1. Get data from layout
        /// 2. Validate -> show error message?
        /// 3. Check Login
        /// </summary>
        protected void OnVerify()
        {
            // 1. Get data from layout
            // 2. Validate -> show error message?
            // 3. Check Login -> Redirect to Overview Page or show error message?
            var model = GetDataFromLayout();

            if (!Page.IsValid)
            {
                return;
            }
            bool isSuccess = CheckLogin(model);

            if (isSuccess)
            {
                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;
                }

                // Store session IsManager
                //bool isManager = !UserPermission.IsCurrentUserInGroup(StringConstant.CommonAccounts);
                bool isManager = !isCurrentUserInCommonGroup;
                HttpContext.Current.Session[StringConstant.IsAdmin] = isManager;

                // Redirect to Overview Page
                //Response.Redirect(StringConstant.PageOverviewURL);
                SPUtility.Redirect(StringConstant.PageOverviewURL, SPRedirectFlags.DoNotEndResponse | SPRedirectFlags.Trusted, HttpContext.Current);
            }
            else
            {
                NotificationStatusHelper.SetErrorStatus(Page.Form, WebPageResourceHelper.GetResourceString(StringConstant.ResourcekeyGeneralTitleError), WebPageResourceHelper.GetResourceString(StringConstant.ResourcesKeyLoginMessageFail));
            }
        }
예제 #9
0
        public static string GetRequestStatusMessage(string currentStatus)
        {
            string msgResult = "";

            currentStatus = currentStatus.ToLower();
            if (currentStatus == ApprovalStatus.Approved.ToLower())
            {
                msgResult = WebPageResourceHelper.GetResourceString("RequestStatusApproved");
            }
            else if (currentStatus == ApprovalStatus.Rejected.ToLower())
            {
                msgResult = WebPageResourceHelper.GetResourceString("RequestStatusRejected");
            }
            else if (currentStatus == ApprovalStatus.Cancelled.ToLower())
            {
                msgResult = WebPageResourceHelper.GetResourceString("RequestStatusCancelled");
            }
            else if (!string.IsNullOrEmpty(currentStatus))
            {
                msgResult = WebPageResourceHelper.GetResourceString("RequestStatusInProgress");
            }

            return(msgResult);
        }
        public MessageResult InsertOvertime(SPWeb spWeb, OverTimeModel overTimeModel, bool autoovertime = false)
        {
            var  overtimeManagementId = 0;
            bool createNew            = overTimeModel.ID == 0;
            bool breakFunc            = false;
            var  overtimeEntity       = overTimeModel.ToEntity();

            try
            {
                if (createNew == false)
                {
                    var currentItem = _overTimeManagementDAL.GetByID(spWeb, overtimeEntity.ID);

                    string actionType = overTimeModel.ApprovalStatus.ToLower();
                    if (actionType == "true" || actionType == "false" || overTimeModel.RequiredBODApprove == true) // action = approve or reject
                    {
                        string retMsg = GetRequestStatusMessage(currentItem);
                        if (!string.IsNullOrEmpty(retMsg))
                        {
                            breakFunc = true;
                            int errorCode = actionType == "false" ? (int)OverTimeErrorCode.CannotReject : (int)OverTimeErrorCode.CannotApprove;
                            return(new MessageResult {
                                Code = errorCode, Message = retMsg, ObjectId = 0
                            });
                        }
                    }
                    else // action = edit
                    {
                        if (currentItem.ApprovalStatus.ToLower().Equals("false") || currentItem.ApprovalStatus.ToLower().Equals("true"))
                        {
                            breakFunc = true;
                            string retMsg = GetRequestStatusMessage(currentItem);
                            return(new MessageResult {
                                Code = (int)OverTimeErrorCode.CannotSubmit, Message = retMsg, ObjectId = 0
                            });
                        }
                        else if (currentItem.FirstApprovedDate != null && currentItem.FirstApprovedDate != DateTime.MinValue && currentItem.ApprovalStatus == "")
                        {
                            breakFunc = true;
                            string retMsg = WebPageResourceHelper.GetResourceString("RequestStatusInProgress");
                            return(new MessageResult {
                                Code = (int)OverTimeErrorCode.CannotSubmit, Message = retMsg, ObjectId = 0
                            });
                        }
                    }

                    string requestExpiredMsg = MessageResultHelper.GetRequestExpiredMessage(currentItem.RequestDueDate);
                    if (!string.IsNullOrEmpty(requestExpiredMsg))
                    {
                        breakFunc = true;
                        return(new MessageResult {
                            Code = (int)OverTimeErrorCode.CannotApprove, Message = requestExpiredMsg, ObjectId = 0
                        });
                    }

                    overtimeEntity.FirstApprovedDate = currentItem.FirstApprovedDate;
                    if (!string.IsNullOrEmpty(currentItem.ApprovalStatus.Trim()))
                    {
                        breakFunc = true;
                        return(new MessageResult
                        {
                            Code = 0,
                            Message = "Success",
                            ObjectId = overtimeManagementId
                        });
                    }

                    // Update Approver
                    if (!string.IsNullOrEmpty(overTimeModel.ApprovalStatus))
                    {
                        if (!overTimeModel.RequiredBODApprove) // 1 STEP
                        {
                            overtimeEntity.FirstApprovedDate = DateTime.Now;
                        }
                        else // 2 STEPs
                        {
                            if (overTimeModel.ApprovalStatus == "true") // BOD Approve
                            {
                                overtimeEntity.DHComments = currentItem.DHComments;
                            }
                            else if (overTimeModel.ApprovalStatus == "false")                                  // DH/BOD Reject
                            {
                                if (currentItem.FirstApprovedBy != null && currentItem.FirstApprovedBy.ID > 0) // BOD Reject
                                {
                                    overtimeEntity.DHComments = currentItem.DHComments;
                                }
                                else // DH Reject
                                {
                                    overtimeEntity.FirstApprovedDate = DateTime.Now;
                                }
                            }
                        }
                    }
                    else // DH Approve, Waiting BOD
                    {
                        overtimeEntity.FirstApprovedDate = DateTime.Now;
                    }
                }
                else
                {
                    overtimeEntity = _overTimeManagementDAL.SetDueDate(overtimeEntity);
                }

                overtimeManagementId = _overTimeManagementDAL.SaveOrUpdate(spWeb, overtimeEntity);
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Overtime Service - InsertOvertime fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                if (overtimeManagementId > 0 && breakFunc == false)
                {
                    var overtimeManagementDetailAddNewList = new List <OverTimeManagementDetail>();
                    foreach (var detail in overTimeModel.OvertimeDetailModelList)
                    {
                        var overTimeManagementDetail = new OverTimeManagementDetail();
                        overTimeManagementDetail.Employee.LookupId             = detail.Employee.LookupId;
                        overTimeManagementDetail.OvertimeFrom                  = Convert.ToDateTime(detail.OvertimeFrom);
                        overTimeManagementDetail.OvertimeManagementID.LookupId = overtimeManagementId;
                        overTimeManagementDetail.ApprovalStatus.LookupId       = detail.OvertimeMgmtApprovalStatus.LookupId;
                        overTimeManagementDetail.Task             = detail.Task;
                        overTimeManagementDetail.OvertimeTo       = Convert.ToDateTime(detail.OvertimeTo);
                        overTimeManagementDetail.CompanyTransport = detail.CompanyTransport;
                        overTimeManagementDetail.WorkingHours     = string.IsNullOrEmpty(detail.WorkingHours) ? 0.0 : double.Parse(detail.WorkingHours);
                        overTimeManagementDetail.ID           = detail.ID;
                        overTimeManagementDetail.BatchCommand = EntityBase.BatchCmd.Save;

                        overtimeManagementDetailAddNewList.Add(overTimeManagementDetail);
                    }

                    if (overtimeManagementDetailAddNewList.Count > 0)
                    {
                        if (autoovertime == false)
                        {
                            SPQuery spQuery = new SPQuery()
                            {
                                Query = $"<Where><Eq><FieldRef Name='OvertimeManagementID'/><Value Type='Lookup' LookupId='TRUE'>{overtimeManagementId}</Value></Eq></Where>"
                            };
                            List <OverTimeManagementDetail> details = _overTimeManagementDetailDAL.GetByQuery(spQuery, new string[] { "ID" });
                            _overTimeManagementDetailDAL.DeleteBatch(details);
                        }

                        _overTimeManagementDetailDAL.BulkInsert(overtimeManagementDetailAddNewList);
                    }

                    // Create New -> SendEmailToDepartmentHead
                    overtimeEntity = _overTimeManagementDAL.GetByID(spWeb, overtimeManagementId);
                    if (createNew)
                    {
                        _overTimeManagementDAL.SendEmailToApprover(SPContext.Current.Web, overtimeEntity, (int)StringConstant.EmployeePosition.DepartmentHead);
                        _overTimeManagementDAL.SendEmailToDelegatedApprover(SPContext.Current.Web, overtimeEntity);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(overTimeModel.ApprovalStatus) && overTimeModel.ApprovalStatus.Equals("true")) // Approve
                        {
                            _overTimeManagementDAL.Approve(overtimeManagementId, overTimeModel.ApproverFullName);
                        }
                        else if (!string.IsNullOrEmpty(overTimeModel.ApprovalStatus) && overTimeModel.ApprovalStatus.Equals("false")) // Reject
                        {
                            _overTimeManagementDAL.Reject(overtimeManagementId, overTimeModel.ApproverFullName);
                        }
                        else if (string.IsNullOrEmpty(overTimeModel.ApprovalStatus) && overTimeModel.RequiredBODApprove)
                        {
                            _overTimeManagementDAL.SendEmailToApprover(SPContext.Current.Web, overtimeEntity, (int)StringConstant.EmployeePosition.BOD);
                            _overTimeManagementDAL.SendEmailToDelegatedApprover(SPContext.Current.Web, overtimeEntity);
                        }
                    }
                }
            }

            return(new MessageResult
            {
                Code = 0,
                Message = "Success",
                ObjectId = overtimeManagementId
            });
        }