Exemplo n.º 1
0
        public JsonResult EmployeeTransfer(EmployeeTransferInfo objEmployeeTransferInfo)
        {
            objLoginHelper = (LoginHelper)Session["LogInInformation"];
            byte transferSequenceNumber = 0;

            try
            {
                if (objEmployeeTransferInfo.TransferSeqNo == null)
                {
                    transferSequenceNumber = hrmsData.ReadTransferSequenceNumber(objEmployeeTransferInfo.EmployeeID);
                }
                else
                {
                    transferSequenceNumber = Convert.ToByte(objEmployeeTransferInfo.TransferSeqNo);
                }

                Hrm_EmployeeTransfer objEmployeeTransfer = new Hrm_EmployeeTransfer();
                objEmployeeTransfer.EmployeeID    = objEmployeeTransferInfo.EmployeeID;
                objEmployeeTransfer.TransferSeqNo = transferSequenceNumber;
                //start for if its region loger
                if (objLoginHelper.Location == "Region" || objLoginHelper.Location == "Unit")
                {
                    objEmployeeTransfer.TransferDate = Convert.ToDateTime(objEmployeeTransferInfo.TransferReleaseDate);
                }
                else //for ho and zone
                {
                    objEmployeeTransfer.TransferDate = Convert.ToDateTime(Helper.DateFormatMMDDYYYY(objLoginHelper.MonthOpenForHRMS));
                }
                //end for if its region loger

                //objEmployeeTransfer.TransferDate = Convert.ToDateTime(Helper.DateFormatMMDDYYYY(objLoginHelper.TransactionOpenDate));

                objEmployeeTransfer.TransferFromLocation = objEmployeeTransferInfo.TransferFromLocation;
                objEmployeeTransfer.TransferToLocation   = objEmployeeTransferInfo.TransferToLocation;
                objEmployeeTransfer.IsItLastTransfer     = false;
                objEmployeeTransfer.NoteForTransfer      = objEmployeeTransferInfo.NoteForTransfer;
                objEmployeeTransfer.IsTransferAccepted   = false;
                objEmployeeTransfer.CreatedBy            = objLoginHelper.LogInID;
                objEmployeeTransfer.CreatedOn            = objLoginHelper.MonthOpenForHRMS;
                objEmployeeTransfer.Status = Helper.Active;

                Hrm_EmployeeTransferAdditionalInfo objEmployeeTransferAdditionalInfo = new Hrm_EmployeeTransferAdditionalInfo();
                objEmployeeTransferAdditionalInfo.EmployeeID                   = objEmployeeTransferInfo.EmployeeID;
                objEmployeeTransferAdditionalInfo.TransferSeqNo                = transferSequenceNumber;
                objEmployeeTransferAdditionalInfo.RequisitionReceivedOn        = objEmployeeTransferInfo.RequisitionReceivedOn;
                objEmployeeTransferAdditionalInfo.OfficeOrderDate              = objEmployeeTransferInfo.OfficeOrderDate;
                objEmployeeTransferAdditionalInfo.OfficeOrderNo                = objEmployeeTransferInfo.OfficeOrderNo + objEmployeeTransferInfo.OfficeOrderNoSequence;
                objEmployeeTransferAdditionalInfo.TransferReleaseDate          = objEmployeeTransferInfo.TransferReleaseDate;
                objEmployeeTransferAdditionalInfo.ResponsibilityHandoverTo     = objEmployeeTransferInfo.ResponsibilityHandoverTo;
                objEmployeeTransferAdditionalInfo.ResponsibilityTakenoverFrom  = objEmployeeTransferInfo.ResponsibilityTakenoverFrom;
                objEmployeeTransferAdditionalInfo.ReasonForLateTransferJoining = objEmployeeTransferInfo.ReasonForLateTransferJoining;
                objEmployeeTransferAdditionalInfo.ReasonForLateTransferRelease = objEmployeeTransferInfo.ReasonForLateTransferRelease;
                objEmployeeTransferAdditionalInfo.ActualTransferJoiningDate    = objEmployeeTransferInfo.ActualTransferJoiningDate;
                objEmployeeTransferAdditionalInfo.ActualTransferReleaseDate    = objEmployeeTransferInfo.ActualTransferReleaseDate;
                objEmployeeTransferAdditionalInfo.NewOperationalRole           = objEmployeeTransferInfo.NewOperationalRole;

                if (objEmployeeTransferInfo.TransferSeqNo == null)
                {
                    hrmsData.CreateEmployeeTransfer(objEmployeeTransfer, objEmployeeTransferAdditionalInfo);
                }
                else
                {
                    objEmployeeTransfer.ModifiedBy = objLoginHelper.LogInID;
                    objEmployeeTransfer.ModifiedOn = DateTime.Now;

                    hrmsData.UpdateEmployeeTransfer(objEmployeeTransfer, objEmployeeTransferAdditionalInfo);
                }

                return(new JsonResult {
                    Data = ExceptionHelper.ExceptionMessage("Transfer Is Succeed")
                });
            }
            catch (Exception ex)
            {
                return(new JsonResult {
                    Data = ExceptionHelper.ExceptionMessage(ex)
                });
            }
        }