コード例 #1
0
        public async Task <ActionResult> Edit(EM_Company_Limit model)
        {
            var entity = companyLimitRepo.GetById(model.Id);

            Log(entity);
            if (model == null)
            {
                return(Json(new { code = 0, message = "额度不存在!" }, JsonRequestBehavior.AllowGet));
            }

            entity            = Mapper.Map <EM_Company_Limit, EM_Company_Limit>(model, entity);
            entity.ModifyDate = DateTime.Now;
            entity.Modifier   = ViewHelp.GetUserName();
            var result = companyLimitRepo.SaveChanges();

            if (result > 0)
            {
                Log(model);
                return(Json(new { code = 1, model = model }));
            }
            else
            {
                return(Json(new { code = 0, message = "保存失败,请重试" }));
            }
        }
コード例 #2
0
        public async Task <ActionResult> CancelExpenseAccount(int Id)
        {
            if (!expenseAccountRepo.IsCreater(Id.ToString(), ViewHelp.GetUserName()))
            {
                return(Json(new { code = 0, message = "选中的项目中包含不是本人新增的报销单,请重新选择" }, JsonRequestBehavior.AllowGet));
            }
            var result = expenseAccountRepo.UpdataApproveStatus(Id, (int)ExpenseAccountApproveStatus.Created, "", ViewHelp.GetUserName());

            return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public async Task <ActionResult> Add()
        {
            var model = new EM_ExpenseAccount();

            InitBodys();
            model.OccurDate = DateTime.Now;
            model.ApplyDate = DateTime.Now;
            model.Name      = ViewHelp.GetUserName();
            return(View("AddOrEdit", model));
        }
コード例 #4
0
        public async Task <ActionResult> BrowseFile(int Id)
        {
            var Dto = await expenseAccountFileRepo.GetDtos(Id);

            if (Dto.UpLoader != ViewHelp.GetUserName() && !ViewHelp.IsAdmin())
            {
                return(RedirectToAction("noright", "error"));
            }
            var Vm = Mapper.Map <ExpenseAccountFileVM>(Dto);

            return(View(Vm));
        }
コード例 #5
0
ファイル: CompanyController.cs プロジェクト: YongLWei03/EM-2
        public async Task <ActionResult> Edit(EM_Company model)
        {
            var entity = companyRepo.GetById(model.Id);

            Log(entity);
            entity            = Mapper.Map <EM_Company, EM_Company>(model, entity);
            entity.KPIValue   = entity.KPIValue.Value * 10000;
            entity.ModifyDate = DateTime.Now;
            entity.Modifier   = ViewHelp.GetUserName();
            var result = companyRepo.SaveChanges();

            return(Json(new { code = 1 }));
        }
コード例 #6
0
        public async Task <ActionResult> CancelExpenseAccounts(string Ids)
        {
            if (!expenseAccountRepo.IsCreater(Ids, ViewHelp.GetUserName()))
            {
                return(Json(new { code = 0, message = "选中的项目中包含不是本人新增的报销单,请重新选择" }, JsonRequestBehavior.AllowGet));
            }
            var IdsInt = Ids.ToInts();

            foreach (var Id in IdsInt)
            {
                var result = expenseAccountRepo.UpdataApproveStatus(Id, (int)ExpenseAccountApproveStatus.Created, "", ViewHelp.GetUserName());
            }
            return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public ActionResult PostExpenseAccountFile(int id, string remark = "")
        {
            var message = "";

            if (string.IsNullOrEmpty(remark))
            {
                return(Json(new { code = 0, message = "必须填写附件说明" }, "text/html;charset=utf-8"));
            }
            var FilePathId = id == 0 ? "temp" : id.ToString();

            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files[0];
                var FileType            = file.FileName.Split('.').Last().ToLower();
                message = CheckFileType(FileType);
                if (string.IsNullOrEmpty(message))
                {
                    var BasePath = Server.MapPath("~");
                    var FileName = DateTime.Now.ToBinary().ToString();
                    var FilePath = "Upload\\ExpenseAccountFile\\" + FilePathId + "\\";
                    if (!Directory.Exists(BasePath + FilePath))
                    {
                        Directory.CreateDirectory(BasePath + FilePath);
                    }
                    var FullFilePath = BasePath + FilePath + FileName + "." + FileType;
                    file.SaveAs(FullFilePath);
                    var model = new EM_ExpenseAccount_File()
                    {
                        ExpenseAccountId = id,
                        FileName         = file.FileName,
                        FileId           = FileName,
                        FilePath         = FilePath + FileName + "." + FileType,
                        CreateDate       = DateTime.Now,
                        UpLoader         = ViewHelp.GetUserName(),
                        Status           = (int)ExpenseAccountFileStatus.NoRelated,
                        Remark           = remark
                    };
                    expenseAccountFileRepo.Add(model);
                    expenseAccountFileRepo.SaveChanges();

                    return(Json(new { code = 1, model = new { Id = model.Id, FileName = model.FileName, CreateDate = model.CreateDate.ToString("yyyy-MM-dd HH:mm:ss") } }, "text/html;charset=utf-8"));
                }
            }
            return(Json(new { code = 0, message = message }, "text/html;charset=utf-8"));
        }
コード例 #8
0
        public async Task <ActionResult> Add(EM_Company_Performance model)
        {
            model.CreateDate = DateTime.Now;
            model.Creater    = ViewHelp.GetUserName();
            model.ModifyDate = DateTime.Now;
            model.Modifier   = ViewHelp.GetUserName();
            companyPerformanceRepo.Add(model);
            var result = companyPerformanceRepo.SaveChanges();

            if (result > 0)
            {
                return(Json(new { code = 1, model = model }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { code = 0, message = "保存失败,请重试" }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #9
0
ファイル: CompanyController.cs プロジェクト: YongLWei03/EM-2
        public async Task <ActionResult> Add(EM_Company model)
        {
            model.KPIValue   = model.KPIValue.Value * 10000;
            model.ModifyDate = DateTime.Now;
            model.CreateDate = DateTime.Now;
            model.Modifier   = ViewHelp.GetUserName();
            model.Creater    = ViewHelp.GetUserName();
            companyRepo.Add(model);
            var result = companyRepo.SaveChanges();

            if (result > 0)
            {
                return(Json(new { code = 1 }));
            }
            else
            {
                return(Json(new { code = 0, message = "保存失败,请重试" }));
            }
        }
コード例 #10
0
        public async Task <ActionResult> Edit(EM_ExpenseAccount model, string FileIds, string DetailIds)
        {
            var entity = expenseAccountRepo.GetById(model.Id);

            if (model == null)
            {
                return(Json(new { code = 0, message = "报销单不存在!" }, JsonRequestBehavior.AllowGet));
            }
            var IsRepeat = expenseAccountRepo.GetMany(o => o.EANumber == model.EANumber && o.Id != model.Id).Any();

            if (IsRepeat)
            {
                return(Json(new { code = 0, message = "报销单号已存在,请修改报销单号" }, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(DetailIds))
            {
                return(Json(new { code = 0, message = "报销单明细上传失败,请重试" }, JsonRequestBehavior.AllowGet));
            }

            entity = Mapper.Map <EM_ExpenseAccount, EM_ExpenseAccount>(model, entity);
            entity.ApproveStatus = entity.ApproveStatus == 0 ? (int)ExpenseAccountApproveStatus.Created : entity.ApproveStatus;
            entity.ModifyDate    = DateTime.Now;
            entity.Modifier      = ViewHelp.GetUserName();
            var result = expenseAccountRepo.SaveChanges();

            //添加状态变更记录
            expenseAccountRepo.AddApproveHistory(model.Id, model.ApproveStatus, "", ViewHelp.GetUserName(), "");
            if (result > 0)
            {
                //更新单身
                await expenseAccountDetailRepo.UpdateDetailExpenseAccountId(model.Id, DetailIds);

                await expenseAccountFileRepo.UpdateFileExpenseAccountId(model.Id, FileIds);

                Log(model);
                return(Json(new { code = 1, model = model }));
            }
            else
            {
                return(Json(new { code = 0, message = "保存失败,请重试" }));
            }
        }
コード例 #11
0
        public async Task <ActionResult> Delete(int Id)
        {
            if (!expenseAccountRepo.IsCreater(Id.ToString(), ViewHelp.GetUserName()))
            {
                return(Json(new { code = 0, message = "选中的项目中包含不是本人新增的报销单,请重新选择" }, JsonRequestBehavior.AllowGet));
            }
            var model = expenseAccountRepo.GetById(Id);

            if (model == null)
            {
                return(Json(new { code = 0, message = "报销单不存在!" }, JsonRequestBehavior.AllowGet));
            }
            expenseAccountRepo.Delete(model);
            if (expenseAccountRepo.SaveChanges() > 0)
            {
                Log(model);
                return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { code = 0, message = "删除失败,请重试" }, JsonRequestBehavior.AllowGet));
        }
コード例 #12
0
        public ActionResult SaveDetail(EM_ExpenseAccount_Detail model)
        {
            model.Modifier   = ViewHelp.GetUserName();
            model.ModifyTime = DateTime.Now;
            if (model.Id == 0)
            {
                model.Creater    = ViewHelp.GetUserName();
                model.CreateTime = DateTime.Now;
                expenseAccountDetailRepo.Add(model);
            }
            else
            {
                var entity = expenseAccountDetailRepo.GetById(model.Id);
                Log(entity);
                entity = Mapper.Map <EM_ExpenseAccount_Detail, EM_ExpenseAccount_Detail>(model, entity);
            }
            var result = expenseAccountDetailRepo.SaveChanges();
            var dto    = Mapper.Map <EM_ExpenseAccount_Detail, ExpenseAccountDetailListDTO>(model);

            return(Json(new { code = result, message = "保存失败,请重试", model = dto }));
        }
コード例 #13
0
        public async Task <ActionResult> Deletes(string Ids)
        {
            if (!expenseAccountRepo.IsCreater(Ids, ViewHelp.GetUserName()))
            {
                return(Json(new { code = 0, message = "选中的项目中包含不是本人新增的报销单,请重新选择" }, JsonRequestBehavior.AllowGet));
            }
            var IdsInt = Ids.ToInts();

            foreach (var Id in IdsInt)
            {
                var model = expenseAccountRepo.GetById(Id);
                if (model == null)
                {
                    return(Json(new { code = 0, message = "报销单不存在!,单据号" + model.EANumber }, JsonRequestBehavior.AllowGet));
                }
                expenseAccountRepo.Delete(model);
                if (expenseAccountRepo.SaveChanges() > 0)
                {
                    Log(model);
                }
            }
            return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
        }
コード例 #14
0
        public async Task <ActionResult> UpdataApproveStatuss(string Ids, int ApproveStatus, string Message)
        {
            var IdsInt = Ids.ToInts();

            foreach (var Id in IdsInt)
            {
                var result = expenseAccountRepo.UpdataApproveStatus(Id, ApproveStatus, Message, ViewHelp.GetUserName());
            }
            //发送
            return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
        }
コード例 #15
0
        public async Task <ActionResult> UpdataApproveStatus(UpdataApproveStatusVM model)
        {
            var result = expenseAccountRepo.UpdataApproveStatus(model.Id, model.ApproveStatus, model.Message, ViewHelp.GetUserName(), model.Note);

            //发送
            return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet));
        }
コード例 #16
0
        public async Task <ActionResult> ToExcel(ExpenseAccountSM Sm)
        {
            var Dtos     = expenseAccountRepo.GetExcelListByDto(Sm, ViewHelp.UserInfo());
            var Vms      = Mapper.Map <List <ExpenseAccountExcelVM> >(Dtos);
            var FilePath = ExpenseAccountManager.Instance.ToExcel(Vms);

            Log(Vms, "路径:" + FilePath);
            return(File(new FileStream(FilePath, FileMode.Open), "application/octet-stream", "报销清单_" + ViewHelp.GetUserName() + "_" + DateTime.Now.ToString("yyyyMMddss") + ".xls"));
        }