public virtual Spl_WarehouseAllocationModel GetById(object id)
        {
            if (IsExists(id))
            {
                Spl_WarehouseAllocation      entity = m_Rep.GetById(id);
                Spl_WarehouseAllocationModel model  = new Spl_WarehouseAllocationModel();
                model.Id              = entity.Id;
                model.InTime          = entity.InTime;
                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.FromWarehouseId = entity.FromWarehouseId;
                model.ToWarehouseId   = entity.ToWarehouseId;
                model.ContractNumber  = entity.ContractNumber;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        public ActionResult Print(string id)
        {
            ViewBag.ComName = siteConfig.webcompany;
            Spl_WarehouseAllocationModel entity = m_BLL.GetById(id);

            return(View(entity));
        }
Example #3
0
        public JsonResult Create(Spl_WarehouseAllocationModel model, string inserted)
        {
            var detailsList = JsonHandler.DeserializeJsonToList <Spl_WarehouseAllocationDetailsModel>(inserted);

            if (detailsList != null && detailsList.Count != 0)
            {
                //model.Id = ResultHelper.NewId;
                model.CreateTime   = ResultHelper.NowTime;
                model.CreatePerson = GetUserId();
                //计算总价
                model.PriceTotal = detailsList.Sum(a => a.Quantity * a.Price);
                if (model != null && ModelState.IsValid)
                {
                    if (m_BLL.Create(ref errors, model))
                    {
                        var detailsResultList = new List <Spl_WarehouseAllocationDetailsModel>();
                        //新加

                        foreach (var r in detailsList)
                        {
                            //过滤无效数据
                            if (string.IsNullOrEmpty(r.WareDetailsId))
                            {
                                continue;
                            }
                            Spl_WarehouseAllocationDetailsModel entity = new Spl_WarehouseAllocationDetailsModel();
                            entity.Id                    = "";
                            entity.WareDetailsId         = r.WareDetailsId;
                            entity.WarehouseId           = model.ToWarehouseId;//到的仓库
                            entity.WarehouseAllocationId = 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.SaveData(detailsResultList);
                            LogHandler.WriteServiceLog(GetUserId(), "保存成功", "成功", "保存", "Spl_WarehouseAllocation");
                            return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
                        }
                        catch (Exception ex)
                        {
                            LogHandler.WriteServiceLog(GetUserId(), ex.Message, "失败", "保存", "Spl_WarehouseAllocation");
                            return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ex.Message)));
                        }
                    }
                    else
                    {
                        string ErrorCol = errors.Error;
                        LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",InTime" + model.InTime + "," + ErrorCol, "失败", "创建", "Spl_WarehouseAllocation");
                        return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol)));
                    }
                }
            }
            return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ":没有明细")));
        }
Example #4
0
        public ActionResult Edit(string id)
        {
            Spl_WarehouseAllocationModel entity = m_BLL.GetById(id);

            ViewBag.FromWarehouse = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, ""), "Id", "Name", entity.FromWarehouseId);
            ViewBag.ToWarehouse   = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, ""), "Id", "Name", entity.ToWarehouseId);
            return(View(entity));
        }
Example #5
0
        ///修改
        ///
        public override bool Edit(ref ValidationErrors errors, Spl_WarehouseAllocationModel model)
        {
            try
            {
                Spl_WarehouseAllocation entity = m_Rep.GetById(model.Id);
                if (entity.Confirmation == true)
                {
                    errors.Add("单据已确认不能被修改");
                    return(false);
                }//修改于2018年2月5日
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id              = model.Id;
                entity.InTime          = model.InTime;
                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.ToWarehouseId   = model.ToWarehouseId;
                entity.FromWarehouseId = model.FromWarehouseId;
                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);
            }
        }
Example #6
0
        public ActionResult Create()
        {
            ViewBag.FromWarehouse = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()), "Id", "Name");
            ViewBag.ToWarehouse   = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, ""), "Id", "Name");
            AccountModel accountModel          = GetAccount();
            Spl_WarehouseAllocationModel model = new Spl_WarehouseAllocationModel()
            {
                Id = "DBD" + DateTime.Now.ToString("yyyyMMddHHmmssff"),
                //  Handler = accountModel.Id,
                Handler     = accountModel.TrueName,
                HandlerName = accountModel.TrueName,
            };

            return(View(model));
        }
        public virtual bool Create(ref ValidationErrors errors, Spl_WarehouseAllocationModel model)
        {
            try
            {
                Spl_WarehouseAllocation entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity                 = new Spl_WarehouseAllocation();
                entity.Id              = model.Id;
                entity.InTime          = model.InTime;
                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.FromWarehouseId = model.FromWarehouseId;
                entity.ToWarehouseId   = model.ToWarehouseId;
                entity.ContractNumber  = model.ContractNumber;


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

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

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.InTime, "入库时间");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.Handler, "经手人");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.Remark, "说明");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.PriceTotal, "总价");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.State, "1 正常 2 审核中 3 审核完成 0作废");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.Checker, "审查人");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.CheckTime, "审查时间");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.CreateTime, "创建时间");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.CreatePerson, "制单人");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.ModifyTime, "修改时间");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.ModifyPerson, "修改人");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.Confirmation, "单据确认");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.FromWarehouseId, "所属仓库");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.ToWarehouseId, "ToWarehouseId");
            excelFile.AddMapping <Spl_WarehouseAllocationModel>(x => x.ContractNumber, "合同编号");

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

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new Spl_WarehouseAllocationModel();
                entity.Id              = row.Id;
                entity.InTime          = row.InTime;
                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.FromWarehouseId = row.FromWarehouseId;
                entity.ToWarehouseId   = row.ToWarehouseId;
                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);
        }
Example #9
0
        public ActionResult Details(string id)
        {
            Spl_WarehouseAllocationModel entity = m_BLL.GetById(id);

            return(View(entity));
        }