public ActionResult Print(string id)
        {
            ViewBag.ComName = siteConfig.webcompany;
            Spl_WarehouseWarrantOUTModel entity = m_BLL.GetById(id);

            return(View(entity));
        }
示例#2
0
        public virtual Spl_WarehouseWarrantOUTModel GetById(object id)
        {
            if (IsExists(id))
            {
                Spl_WarehouseWarrantOUT      entity = m_Rep.GetById(id);
                Spl_WarehouseWarrantOUTModel model  = new Spl_WarehouseWarrantOUTModel();
                model.Id              = entity.Id;
                model.OutTime         = entity.OutTime;
                model.Handler         = entity.Handler;
                model.Remark          = entity.Remark;
                model.PriceTotal      = entity.PriceTotal;
                model.State           = entity.State;
                model.Checker         = entity.Checker;
                model.CheckTime       = entity.CheckTime;
                model.CreateTime      = entity.CreateTime;
                model.CreatePerson    = entity.CreatePerson;
                model.ModifyTime      = entity.ModifyTime;
                model.ModifyPerson    = entity.ModifyPerson;
                model.Confirmation    = entity.Confirmation;
                model.InOutCategoryId = entity.InOutCategoryId;
                model.WarehouseId     = entity.WarehouseId;
                model.ContractNumber  = entity.ContractNumber;

                return(model);
            }
            else
            {
                return(null);
            }
        }
        public ActionResult Edit(string id)
        {
            Spl_WarehouseWarrantOUTModel entity = m_BLL.GetById(id);

            ViewBag.Warehouse     = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()), "Id", "Name", entity.WarehouseId);
            ViewBag.InOutCategory = new SelectList(InOutCategoryBLL.GetList(ref setNoPagerAscById, "出库"), "Id", "Name", entity.InOutCategoryId);
            return(View(entity));
        }
        public JsonResult Edit(Spl_WarehouseWarrantOUTModel model, string inserted)
        {
            var detailsList = JsonHandler.DeserializeJsonToList <Spl_WarehouseWarrantDetailsOUTModel>(inserted);

            if (detailsList != null && detailsList.Count != 0)
            {
                //计算总价
                model.PriceTotal = detailsList.Sum(a => a.Quantity * a.Price);
                model.ModifyTime = DateTime.Now;
                if (model != null && ModelState.IsValid)
                {
                    if (m_BLL.Edit(ref errors, model))
                    {
                        var detailsResultList = new List <Spl_WarehouseWarrantDetailsOUTModel>();
                        //新加

                        foreach (var r in detailsList)
                        {
                            //过滤无效数据
                            if (string.IsNullOrEmpty(r.WareDetailsId))
                            {
                                continue;
                            }
                            Spl_WarehouseWarrantDetailsOUTModel entity = new Spl_WarehouseWarrantDetailsOUTModel();
                            entity.Id                 = r.Id;
                            entity.WareDetailsId      = r.WareDetailsId;
                            entity.WarehouseId        = model.WarehouseId;
                            entity.WarehouseWarrantId = model.Id;
                            entity.Quantity           = r.Quantity;
                            entity.Price              = r.Price;
                            entity.TotalPrice         = r.Quantity * r.Price;
                            entity.Defined            = string.IsNullOrWhiteSpace(r.Defined) ? "" : r.Defined;
                            entity.CreateTime         = ResultHelper.NowTime;
                            detailsResultList.Add(entity);
                        }

                        try
                        {
                            m_BLL.SaveEditData(detailsResultList, model.Id);
                            LogHandler.WriteServiceLog(GetUserId(), "保存成功", "成功", "保存", "Spl_WarehouseWarrant");
                            return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
                        }
                        catch (Exception ex)
                        {
                            LogHandler.WriteServiceLog(GetUserId(), ex.Message, "失败", "保存", "Spl_WarehouseWarrant");
                            return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ex.Message)));
                        }
                    }
                    else
                    {
                        string ErrorCol = errors.Error;
                        LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",InTime" + model.OutTime + "," + ErrorCol, "失败", "创建", "Spl_WarehouseWarrant");
                        return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol)));
                    }
                }
            }
            return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ":没有明细")));
        }
        public ActionResult Create()
        {
            ViewBag.Warehouse     = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()), "Id", "Name");
            ViewBag.InOutCategory = new SelectList(InOutCategoryBLL.GetList(ref setNoPagerAscById, "出库"), "Id", "Name");
            AccountModel accountModel          = GetAccount();
            Spl_WarehouseWarrantOUTModel model = new Spl_WarehouseWarrantOUTModel()
            {
                Id = "CKD" + DateTime.Now.ToString("yyyyMMddHHmmssff"),
                //  Handler = accountModel.Id,
                Handler     = accountModel.TrueName,
                HandlerName = accountModel.TrueName,
            };

            ViewBag.Checker = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()), "Id", "ContactPerson").Distinct();
            return(View(model));
        }
示例#6
0
        public virtual bool Edit(ref ValidationErrors errors, Spl_WarehouseWarrantOUTModel model)
        {
            try
            {
                Spl_WarehouseWarrantOUT entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id              = model.Id;
                entity.OutTime         = model.OutTime;
                entity.Handler         = model.Handler;
                entity.Remark          = model.Remark;
                entity.PriceTotal      = model.PriceTotal;
                entity.State           = model.State;
                entity.Checker         = model.Checker;
                entity.CheckTime       = model.CheckTime;
                entity.CreateTime      = model.CreateTime;
                entity.CreatePerson    = model.CreatePerson;
                entity.ModifyTime      = model.ModifyTime;
                entity.ModifyPerson    = model.ModifyPerson;
                entity.Confirmation    = model.Confirmation;
                entity.InOutCategoryId = model.InOutCategoryId;
                entity.WarehouseId     = model.WarehouseId;
                entity.ContractNumber  = model.ContractNumber;



                if (m_Rep.Edit(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
示例#7
0
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public virtual bool CheckImportData(string fileName, List <Spl_WarehouseWarrantOUTModel> list, ref ValidationErrors errors)
        {
            var targetFile = new FileInfo(fileName);

            if (!targetFile.Exists)
            {
                errors.Add("导入的数据文件不存在");
                return(false);
            }

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.OutTime, "出库时间");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.Handler, "经办人");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.Remark, "说明");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.PriceTotal, "总价");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.State, "状态");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.Checker, "审查人");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.CheckTime, "审查时间");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.CreateTime, "创建时间");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.CreatePerson, "制单人");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.ModifyTime, "修改时间");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.ModifyPerson, "修改人");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.Confirmation, "单据确认");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.InOutCategoryId, "入库类别");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.WarehouseId, "所属仓库");
            excelFile.AddMapping <Spl_WarehouseWarrantOUTModel>(x => x.ContractNumber, "合同编号");

            //SheetName
            var excelContent = excelFile.Worksheet <Spl_WarehouseWarrantOUTModel>(0);
            int rowIndex     = 1;

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new Spl_WarehouseWarrantOUTModel();
                entity.Id              = row.Id;
                entity.OutTime         = row.OutTime;
                entity.Handler         = row.Handler;
                entity.Remark          = row.Remark;
                entity.PriceTotal      = row.PriceTotal;
                entity.State           = row.State;
                entity.Checker         = row.Checker;
                entity.CheckTime       = row.CheckTime;
                entity.CreateTime      = row.CreateTime;
                entity.CreatePerson    = row.CreatePerson;
                entity.ModifyTime      = row.ModifyTime;
                entity.ModifyPerson    = row.ModifyPerson;
                entity.Confirmation    = row.Confirmation;
                entity.InOutCategoryId = row.InOutCategoryId;
                entity.WarehouseId     = row.WarehouseId;
                entity.ContractNumber  = row.ContractNumber;

                //=============================================================================
                if (errorMessage.Length > 0)
                {
                    errors.Add(string.Format(
                                   "第 {0} 列发现错误:{1}{2}",
                                   rowIndex,
                                   errorMessage,
                                   "<br/>"));
                }
                list.Add(entity);
                rowIndex += 1;
            }
            if (errors.Count > 0)
            {
                return(false);
            }
            return(true);
        }
        public ActionResult Details(string id)
        {
            Spl_WarehouseWarrantOUTModel entity = m_BLL.GetById(id);

            return(View(entity));
        }