示例#1
0
        public ActionResult Extend(int?Id)
        {
            Session["file"] = null;
            var LabourContract = LabourContractRepository.GetvwLabourContractById(Id.Value);

            if (LabourContract != null && LabourContract.IsDeleted != true)
            {
                var model = new LabourContractViewModel();
                AutoMapper.Mapper.Map(LabourContract, model);
                model.EffectiveDate = DateTime.Now;
                model.SignedDay     = DateTime.Now;

                //lấy thông tin nhân viên lúc ký hợp đồng lưu lại.
                var staff = staffRepository.GetvwStaffsById(model.StaffId.Value);
                //model.DepartmentStaffId = staff.BranchDepartmentId;
                //model.PositionStaff = staff.Position;
                //model.StaffBranchName = staff.BranchName;
                //model.StaffDepartmentName = staff.Staff_DepartmentId;
                model.Name = "Hợp đồng gia hạn";
                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
示例#2
0
        public ViewResult Create()
        {
            var model = new LabourContractViewModel();

            model.EffectiveDate = DateTime.Now;
            model.SignedDay     = DateTime.Now;
            // xóa file đính kèm trong session để bắt đầu thêm mới
            Session["file"] = null;
            return(View(model));
        }
示例#3
0
        string bill(LabourContractViewModel model)
        {
            //lấy thông tin
            var company = Erp.BackOffice.Helpers.Common.GetSetting("companyName");
            //var BranchName = Erp.BackOffice.Helpers.Common.CurrentUser.BranchName;
            var staff         = staffRepository.GetvwStaffsById(model.StaffId.Value);
            var ApprovedStaff = staffRepository.GetvwStaffsById(model.ApprovedUserId.Value);
            var q             = LabourContractTypeRepository.GetLabourContractTypeById(model.Type.Value);
            //var branch = branchRepository.GetvwBranchById(ApprovedStaff.Sale_BranchId.Value);
            var address  = Erp.BackOffice.Helpers.Common.GetSetting("addresscompany");
            var phone    = Erp.BackOffice.Helpers.Common.GetSetting("phonecompany");
            var fax      = Erp.BackOffice.Helpers.Common.GetSetting("faxcompany");
            var bankcode = Erp.BackOffice.Helpers.Common.GetSetting("bankcode");
            var bankname = Erp.BackOffice.Helpers.Common.GetSetting("bankname");

            if (Convert.ToInt32(model.Type) > 0)
            {
                model.ExpiryDate = model.EffectiveDate.Value.AddMonths(Convert.ToInt32(q.QuantityMonth));
            }
            //lấy template phiếu xuất.
            var template = templatePrintRepository.GetAllTemplatePrint().Where(x => x.Code.Contains("LabourContract")).OrderByDescending(x => x.CreatedDate).FirstOrDefault();

            //truyền dữ liệu vào template.
            model.Content = template.Content;
            model.Content = model.Content.Replace("{Name}", model.Name);
            model.Content = model.Content.Replace("{SignedDay.Date}", model.SignedDay.Value.Day.ToString());
            model.Content = model.Content.Replace("{SignedDay.Month}", model.SignedDay.Value.Month.ToString());
            model.Content = model.Content.Replace("{SignedDay.Year}", model.SignedDay.Value.Year.ToString());
            model.Content = model.Content.Replace("{ApprovedUserName}", ApprovedStaff.Name);
            model.Content = model.Content.Replace("{ApprovedUserPositionName}", ApprovedStaff.PositionName);
            model.Content = model.Content.Replace("{ApprovedBranchName}", company);
            model.Content = model.Content.Replace("{ApprovedPhoneBranch}", phone);
            model.Content = model.Content.Replace("{ApprovedBranchAddress}", address);
            model.Content = model.Content.Replace("{StaffName}", staff.Name);
            model.Content = model.Content.Replace("{StaffBirthday}", staff.Birthday.Value.ToString("dd/MM/yyyy"));
            model.Content = model.Content.Replace("{Job}", model.Job);
            model.Content = model.Content.Replace("{StaffAddress}", staff.Address);
            model.Content = model.Content.Replace("{StaffWard}", staff.WardName);
            model.Content = model.Content.Replace("{StaffDistrict}", staff.DistrictName);
            model.Content = model.Content.Replace("{StaffProvince}", staff.ProvinceName);
            model.Content = model.Content.Replace("{StaffIdCardNumber}", staff.IdCardNumber);
            model.Content = model.Content.Replace("{StaffIdCardDate}", staff.IdCardDate.Value.ToString("dd/MM/yyyy"));
            model.Content = model.Content.Replace("{StaffCardIssuedName}", staff.CardIssuedName);
            model.Content = model.Content.Replace("{ContractTypeName}", model.Name);
            model.Content = model.Content.Replace("{EffectiveDate}", model.EffectiveDate.Value.ToString("dd/MM/yyyy"));
            model.Content = model.Content.Replace("{ExpiryDate}", model.ExpiryDate.Value.ToString("dd/MM/yyyy "));
            model.Content = model.Content.Replace("{FormWork}", model.FormWork);
            model.Content = model.Content.Replace("{WageAgreement}", Helpers.Common.PhanCachHangNgan(model.WageAgreement));
            model.Content = model.Content.Replace("{StaffPositionName}", staff.PositionName);

            model.Content = model.Content.Replace("{System.CompanyName}", company);
            model.Content = model.Content.Replace("{System.AddressCompany}", address);
            return(model.Content);
        }
示例#4
0
        public ActionResult Create(LabourContractViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user           = userRepository.GetUserById(WebSecurity.CurrentUserId);
                var LabourContract = new LabourContract();
                AutoMapper.Mapper.Map(model, LabourContract);
                LabourContract.IsDeleted      = false;
                LabourContract.CreatedUserId  = WebSecurity.CurrentUserId;
                LabourContract.ModifiedUserId = WebSecurity.CurrentUserId;
                LabourContract.AssignedUserId = WebSecurity.CurrentUserId;
                LabourContract.CreatedDate    = DateTime.Now;
                LabourContract.ModifiedDate   = DateTime.Now;
                LabourContract.Status         = "Còn hiệu lực";

                var q = LabourContractTypeRepository.GetLabourContractTypeById(model.Type.Value);
                if (Convert.ToInt32(model.Type) > 0)
                {
                    LabourContract.ExpiryDate = model.EffectiveDate.Value.AddMonths(Convert.ToInt32(q.QuantityMonth));
                }
                //lấy thông tin nhân viên lúc ký hợp đồng lưu lại.
                var staff = staffRepository.GetvwStaffsById(model.StaffId.Value);
                //LabourContract.DepartmentStaffId = staff.BranchDepartmentId;
                LabourContract.PositionStaff = staff.PositionId.Value.ToString();
                //lấy thông tin người đại diện công ty ký.
                var approved = staffRepository.GetvwStaffsById(model.ApprovedUserId.Value);
                //LabourContract.DepartmentApprovedId = approved.BranchDepartmentId;
                //LabourContract.PositionApproved = approved.Position;
                LabourContractRepository.InsertLabourContract(LabourContract);
                //tạo mã hợp đồng lao động
                var prefix = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_LabourContract");
                LabourContract.Code = Erp.BackOffice.Helpers.Common.GetCode(prefix, LabourContract.Id);
                LabourContractRepository.UpdateLabourContract(LabourContract);
                //lưu các trường thuộc tính động.
                //tạo hoặc cập nhật đặc tính động cho sản phẩm nếu có danh sách đặc tính động truyền vào và đặc tính đó phải có giá trị
                Sale.Controllers.ObjectAttributeController.CreateOrUpdateForObject(LabourContract.Id, model.AttributeValueList);
                //lưu file
                DocumentFieldController.SaveUpload(LabourContract.Code, "", LabourContract.Id, "LabourContract");
                //tạo quá trình lương cho nhân viên
                Staff.Controllers.ProcessPayController.CreateProcessPay(model.StaffId, model.WageAgreement, model.EffectiveDate);
                //cập nhật ngày vào làm, ngày nghỉ vào thông tin nhân viên
                Staff.Controllers.StaffsController.UpdateStaff(model.StaffId, model.EffectiveDate, LabourContract.ExpiryDate);
                //
                var labourcontract = LabourContractRepository.GetvwLabourContractById(LabourContract.Id);
                CreateLabourContract(labourcontract);
                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess + " " + LabourContract.Code;

                return(RedirectToAction("Index"));
            }
            TempData[Globals.FailedMessageKey] = App_GlobalResources.Error.InsertUnsucess;
            return(View(model));
        }
示例#5
0
        public ContentResult Contract(string Name, int?staffId, int?Type, int?ApprovedUserId, string FormWork, int WageAgreement)
        {
            var model = new LabourContractViewModel();

            model.Name           = Name;
            model.StaffId        = staffId;
            model.EffectiveDate  = DateTime.Now;
            model.SignedDay      = DateTime.Now;
            model.Type           = Type;
            model.ApprovedUserId = ApprovedUserId;
            model.FormWork       = FormWork;
            model.WageAgreement  = WageAgreement;
            model.Content        = bill(model);
            return(Content(model.Content));
        }
示例#6
0
        public ActionResult Print(int?Id)
        {
            var LabourContract = LabourContractRepository.GetvwLabourContractById(Id.Value);

            if (LabourContract != null && LabourContract.IsDeleted != true)
            {
                var model  = new LabourContractViewModel();
                var branch = branchRepository.GetvwBranchById(LabourContract.ApprovedBranchId.Value);
                AutoMapper.Mapper.Map(LabourContract, model);
                ViewBag.BranchAddress = branch.Address;
                ViewBag.BranchPhone   = branch.Phone;
                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
示例#7
0
        public ActionResult Edit(int?Id)
        {
            var LabourContract = LabourContractRepository.GetLabourContractById(Id.Value);

            if (LabourContract != null && LabourContract.IsDeleted != true)
            {
                var model = new LabourContractViewModel();
                AutoMapper.Mapper.Map(LabourContract, model);
                //if (model.CreatedUserId != Erp.BackOffice.Helpers.Common.CurrentUser.Id && Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId != 1)
                //{
                //    TempData["FailedMessage"] = "NotOwner";
                //    return RedirectToAction("Index");
                //}

                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
示例#8
0
        public ActionResult Edit(LabourContractViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var LabourContract = LabourContractRepository.GetLabourContractById(model.Id);
                    if (LabourContract.WageAgreement != model.WageAgreement)
                    {
                        //tạo quá trình lương cho nhân viên
                        Staff.Controllers.ProcessPayController.CreateProcessPay(model.StaffId, model.WageAgreement, model.EffectiveDate);
                    }
                    var q = LabourContractTypeRepository.GetLabourContractTypeById(model.Type.Value);
                    //kiem tra loai hop dong, neu khac loại hd vô thời hạn thì tính ngày nghỉ làm của nhân viên.
                    if (q.QuantityMonth > 0)
                    {
                        model.ExpiryDate = model.EffectiveDate.Value.AddMonths(Convert.ToInt32(q.QuantityMonth));
                    }
                    if (LabourContract.EffectiveDate != model.EffectiveDate)
                    {
                        //cập nhật ngày vào làm, ngày nghỉ vào thông tin nhân viên
                        Staff.Controllers.StaffsController.UpdateStaff(model.StaffId, model.EffectiveDate, model.ExpiryDate);
                    }
                    AutoMapper.Mapper.Map(model, LabourContract);
                    LabourContract.ModifiedUserId = WebSecurity.CurrentUserId;
                    LabourContract.ModifiedDate   = DateTime.Now;
                    if (LabourContract.ExpiryDate != null)
                    {
                        //  DateTime bb = item..AddHours(ShiftsOfItem2.EndTime.Value.Hour).AddMinutes(ShiftsOfItem2.EndTime.Value.Minute).AddSeconds(ShiftsOfItem2.EndTime.Value.Second);
                        TimeSpan b = LabourContract.ExpiryDate.Value.Subtract(DateTime.Now);
                        var      w = b.TotalDays;
                        if (Convert.ToInt32(w) <= 0)
                        {
                            LabourContract.Status = "Hết hạn";
                        }
                        else
                        if (Convert.ToInt32(w) < q.Notice && w > 0)
                        {
                            LabourContract.Status = "Sắp hết";
                        }
                        else
                        {
                            LabourContract.Status = "Còn hiệu lực";
                        }
                    }
                    LabourContractRepository.UpdateLabourContract(LabourContract);
                    //tạo hoặc cập nhật đặc tính động cho sản phẩm nếu có danh sách đặc tính động truyền vào và đặc tính đó phải có giá trị
                    Sale.Controllers.ObjectAttributeController.CreateOrUpdateForObject(LabourContract.Id, model.AttributeValueList);

                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess + " " + LabourContract.Code;
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Index"));
            }

            TempData[Globals.FailedMessageKey] = App_GlobalResources.Error.UpdateUnsuccess + " " + model.Code;
            return(RedirectToAction("Index"));

            //if (Request.UrlReferrer != null)
            //    return Redirect(Request.UrlReferrer.AbsoluteUri);
            //return RedirectToAction("Index");
        }