Exemple #1
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            PersonnelFile.Id = _pinhuaContext.CreatePersonnelFileId("PF", 4);

            var rcId    = _pinhuaContext.GetNewRcId();
            var rtId    = _pinhuaContext.GetRtId("人员档案");
            var repCase = new EsRepCase
            {
                RcId          = rcId,
                RtId          = rtId,
                LstFiller     = 2,
                LstFillerName = User.Identity.Name,
                LstFillDate   = DateTime.Now,
                FillDate      = DateTime.Now,
            };

            PersonnelFile.ExcelServerRcid = rcId;
            PersonnelFile.ExcelServerRtid = rtId;
            PersonnelFile.SignedDate      = DateTime.Now;

            _pinhuaContext.EsRepCase.Add(repCase);
            _pinhuaContext.人员档案.Add(_mapper.Map <PersonnelFilesDTO, 人员档案>(PersonnelFile));
            _pinhuaContext.SaveChanges();

            return(RedirectToPage("Index"));
        }
Exemple #2
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                var Rcid    = _pinhuaContext.GetNewRcId();
                var rtId    = _pinhuaContext.GetRtId("入库简易版");
                var repCase = new EsRepCase
                {
                    RcId          = Rcid,
                    RtId          = rtId,
                    LstFiller     = 2,
                    LstFillerName = User.Identity.Name,
                    LstFillDate   = DateTime.Now,
                    //fillDate = DateTime.Now,
                    //wiId = "",
                    //state = 1,
                };
                var main = _mapper.Map <Gr2MainDto, Gr2Main>(Purchasing.Main);
                main.ExcelServerRcid = Rcid;
                main.ExcelServerRtid = rtId;
                main.SupplierName    = _pinhuaContext.往来单位.AsNoTracking().FirstOrDefault(p => p.单位编号 == main.Supplier).单位名称;

                var details = _mapper.Map <List <Gr2DetailsDto>, List <Gr2Details> >(Purchasing.Details);
                details.ForEach(i =>
                {
                    i.ExcelServerRcid = Rcid;
                    i.ExcelServerRtid = rtId;
                    i.PurchasingId    = main.PurchasingId;
                });

                if (Purchasing.Details.Count == 0)
                {
                    ModelState.AddModelError("", "采购清单不可为空");
                    PurchasingTypes = buildPurchasingTypes();
                    SupplierList    = _pinhuaContext.GetCustomerSelectList();
                    return(Page());
                }
                _pinhuaContext.EsRepCase.Add(repCase);
                _pinhuaContext.Gr2Main.Add(main);
                _pinhuaContext.Gr2Details.AddRange(details);
                _pinhuaContext.SaveChanges();

                return(RedirectToPage("Index"));
            }
            else
            {
                PurchasingTypes = buildPurchasingTypes();
                SupplierList    = _pinhuaContext.GetCustomerSelectList();
                return(Page());
            }
        }
Exemple #3
0
        public IActionResult OnPost()
        {
            var year = DateTime.Now.ToString("yy");

            var exsistedIds = (from p in _pinhuaContext.收款单
                               where p.收款单号.Substring(0, 4) == "SK" + year
                               orderby p.收款单号 descending
                               select p.收款单号)
                              .ToList();
            var orderIndex = int.Parse(exsistedIds.Count() == 0 ? "0" : exsistedIds.First().Substring(4, 6)) + 1;

            var name = _pinhuaContext.往来单位.FirstOrDefault(x => x.单位编号 == Collection.单位编号)?.单位名称;

            Collection.收款单号 = "SK" + year + orderIndex.ToString("D6");
            Collection.收款单位 = name;

            var rcId    = _pinhuaContext.GetNewRcId();
            var rtId    = _pinhuaContext.GetRtId("收款单");
            var repCase = new EsRepCase
            {
                RcId          = rcId,
                RtId          = rtId,
                LstFiller     = 2,
                LstFillerName = User.Identity.Name,
                LstFillDate   = DateTime.Now,
                FillDate      = DateTime.Now,
            };

            Collection.ExcelServerRcid = rcId;
            Collection.ExcelServerRtid = rtId;

            _pinhuaContext.EsRepCase.Add(repCase);
            _pinhuaContext.收款单.Add(Collection);
            _pinhuaContext.SaveChanges();

            return(RedirectToPage("Index"));
        }
        public IActionResult OnPost(int yyyy, int mm, string jsonStr)
        {
            if (string.IsNullOrEmpty(jsonStr))
            {
                return(Page());
            }
            var Payrolls = Newtonsoft.Json.JsonConvert.DeserializeObject <IList <PayrollDetailsDTO> >(jsonStr);

            if (Payrolls == null)
            {
                return(Page());
            }

            var Rcid    = _pinhuaContext.GetNewRcId();
            var rtId    = _pinhuaContext.GetRtId("工资单");
            var repCase = new EsRepCase
            {
                RcId          = Rcid,
                RtId          = rtId,
                LstFiller     = 2,
                LstFillerName = User.Identity.Name,
                LstFillDate   = DateTime.Now,
            };

            var payrollMain = new PayrollMain
            {
                ExcelServerRcid = Rcid,
                ExcelServerRtid = rtId,
                Y = yyyy,
                M = mm
            };

            var payrollDetails = new List <PayrollDetails>();

            foreach (var payroll in Payrolls)
            {
                var pd = new PayrollDetails
                {
                    ExcelServerRcid = Rcid,
                    ExcelServerRtid = rtId,
                    Y = yyyy,
                    M = mm,
                };
                _mapper.Map <PayrollDetailsDTO, PayrollDetails>(payroll, pd);
                payrollDetails.Add(pd);
            }

            _pinhuaContext.EsRepCase.Add(repCase);
            _pinhuaContext.PayrollMain.Add(payrollMain);
            _pinhuaContext.PayrollDetails.AddRange(payrollDetails);
            try
            {
                _pinhuaContext.SaveChanges();
            }
            catch (DbUpdateException e)
            {
                ModelState.AddModelError("", e.InnerException.Message);
                return(Page());
            }

            return(RedirectToPage("Index"));
        }
        public IActionResult OnPost(string jsonStr)
        {
            if (string.IsNullOrEmpty(jsonStr))
            {
                return(Page());
            }
            var data = Newtonsoft.Json.JsonConvert.DeserializeObject <AttendanceServiceDTO>(jsonStr);

            if (data == null)
            {
                return(Page());
            }


            var Rcid    = _pinhuaContext.GetNewRcId();
            var rtId    = _pinhuaContext.GetRtId("AttendanceReport");
            var repCase = new EsRepCase
            {
                RcId          = Rcid,
                RtId          = rtId,
                LstFiller     = 2,
                LstFillerName = User.Identity.Name,
                LstFillDate   = DateTime.Now,
            };

            var reportMain = new AttendanceReport
            {
                ExcelServerRcid = Rcid,
                ExcelServerRtid = rtId,
                Y = data.Y.Value,
                M = data.M.Value
            };

            var reportDetails = new List <AttendanceReportResults>();

            foreach (var person in data.PersonList)
            {
                var detail = new AttendanceReportResults
                {
                    ExcelServerRcid = Rcid,
                    ExcelServerRtid = rtId,
                    Y    = data.Y.Value,
                    M    = data.M.Value,
                    编号   = person.Id,
                    姓名   = person.Name,
                    是否全勤 = person.IsFullAttendance ? "是" : "否",
                    正班   = person.DaytimeHours,
                    加班   = person.OvertimeHours,
                    总工时  = person.TotalHours,
                    缺勤   = person.TimesOfAbsent,
                    迟到   = person.TimesOfLate,
                    早退   = person.TimesOfLeaveEarly,
                    请假   = person.TimesOfAskForLeave,
                    用餐   = person.TimesOfDinner,
                };
                reportDetails.Add(detail);
            }
            // 保存明细
            var abc = new List <AttendanceReportDetails>();

            foreach (var person in data.PersonList)
            {
                foreach (var detail in person.Results)
                {
                    foreach (var range in detail.Details)
                    {
                        var o = new AttendanceReportDetails
                        {
                            编号              = person.Id,
                            姓名              = person.Name,
                            日期              = detail.Date,
                            班段              = range.RangeId,
                            班段描述            = range.Range,
                            班               = range.Time1Fix,
                            班               = range.Time2Fix,
                            工时              = range.Hours,
                            考勤结果            = range.State,
                            ExcelServerRcid = Rcid,
                            ExcelServerRtid = rtId,
                        };
                        abc.Add(o);
                    }
                }
            }

            _pinhuaContext.EsRepCase.Add(repCase);
            _pinhuaContext.AttendanceReport.Add(reportMain);
            _pinhuaContext.AttendanceReportResults.AddRange(reportDetails);
            _pinhuaContext.AttendanceReportDetails.AddRange(abc);
            _pinhuaContext.SaveChanges();

            return(RedirectToPage("Index"));
        }