public ActionResult Add([ModelBinder(typeof(JsonBinder <LocationEntity>))] LocationEntity entity)
        {
            LocationProvider provider = new LocationProvider();

            if (entity.LocalNum.IsEmpty())
            {
                entity.LocalNum     = SequenceProvider.GetSequence(typeof(LocationEntity));
                entity.LocalBarCode = entity.LocalBarCode.IsEmpty() ? entity.LocalNum : entity.LocalBarCode;
                entity.IsForbid     = (int)EBool.No;
                entity.IsDelete     = (int)EIsDelete.NotDelete;
                entity.UnitNum      = "";
                entity.UnitName     = "";
                entity.CreateTime   = DateTime.Now;
                int line = provider.Add(entity);
                if (line > 0)
                {
                    this.ReturnJson.AddProperty("d", "success");
                }
            }
            else
            {
                entity.LocalBarCode = entity.LocalBarCode.IsEmpty() ? entity.LocalNum : entity.LocalBarCode;
                entity.Include(a => new { a.LocalName, a.LocalBarCode, a.StorageNum, a.LocalType, a.IsDefault });
                entity.Where(a => a.LocalNum == entity.LocalNum);
                int line = provider.Update(entity);
                if (line > 0)
                {
                    this.ReturnJson.AddProperty("d", "success");
                }
            }
            return(Content(this.ReturnJson.ToString()));
        }
Example #2
0
        /// <summary>
        /// 新增库位
        /// </summary>
        /// <returns></returns>
        public ActionResult Add()
        {
            string LocalNum     = WebUtil.GetFormValue <string>("LocalNum");
            string LocalBarCode = WebUtil.GetFormValue <string>("LocalBarCode");
            string LocalName    = WebUtil.GetFormValue <string>("LocalName");
            string StorageNum   = WebUtil.GetFormValue <string>("StorageNum");
            int    StorageType  = WebUtil.GetFormValue <int>("StorageType");
            int    LocalType    = WebUtil.GetFormValue <int>("LocalType");
            string Rack         = WebUtil.GetFormValue <string>("Rack");
            double Length       = WebUtil.GetFormValue <double>("Length");
            double Width        = WebUtil.GetFormValue <double>("Width");
            double Height       = WebUtil.GetFormValue <double>("Height");
            double X            = WebUtil.GetFormValue <double>("X");
            double Y            = WebUtil.GetFormValue <double>("Y");
            double Z            = WebUtil.GetFormValue <double>("Z");
            string UnitNum      = WebUtil.GetFormValue <string>("UnitNum");
            string UnitName     = WebUtil.GetFormValue <string>("UnitName");
            string Remark       = WebUtil.GetFormValue <string>("Remark");
            int    IsForbid     = WebUtil.GetFormValue <int>("IsForbid", (int)EBool.No);
            int    IsDefault    = WebUtil.GetFormValue <int>("IsDefault", (int)EBool.No);
            string CompanyID    = WebUtil.GetFormValue <string>("CompanyID");

            LocationEntity entity = new LocationEntity();

            entity.LocalNum     = ConvertHelper.NewGuid();
            entity.LocalBarCode = new TNumProvider(CompanyID).GetSwiftNum(typeof(LocationEntity), 5);
            entity.LocalName    = LocalName;
            entity.StorageNum   = StorageNum;
            entity.StorageType  = StorageType;
            entity.LocalType    = LocalType;
            entity.Rack         = Rack;
            entity.Length       = Length;
            entity.Width        = Width;
            entity.Height       = Height;
            entity.X            = X;
            entity.Y            = Y;
            entity.Z            = Z;
            entity.UnitNum      = UnitNum;
            entity.UnitName     = UnitName;
            entity.Remark       = Remark;
            entity.IsForbid     = IsForbid;
            entity.IsDefault    = IsDefault;
            entity.IsDelete     = (int)EIsDelete.NotDelete;
            entity.CreateTime   = DateTime.Now;
            entity.CompanyID    = CompanyID;

            LocationProvider provider = new LocationProvider(CompanyID);
            int        line           = provider.Add(entity);
            DataResult result         = new DataResult();

            if (line > 0)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "库位新增成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "库位新增失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }