Exemple #1
0
        /// <summary>
        /// 添加操作
        /// </summary>
        /// <param name="Location"></param>
        /// <returns></returns>
        public ActionResult AddAjax(string LocationName, int StorageId, int LocationTypeId, string LocationNum)
        {
            Location location = new Location();
            //获取库位最大编号
            string locationNum = LocationManager.GetByWhere(item => item.IsDelete == 0).OrderByDescending(item => item.LocationNum).Take(1).Select(item => item.LocationNum).FirstOrDefault();

            if (string.IsNullOrEmpty(locationNum))
            {
                location.LocationNum = "000001";
            }
            else
            {
                location.LocationNum = "00000" + (int.Parse(locationNum) + 1);
                int num = int.Parse(locationNum);
                if (num >= 9)
                {
                    location.LocationNum = "0000" + (int.Parse(LocationNum) + 1);
                }
                else if (num >= 99)
                {
                    location.LocationNum = "000" + (int.Parse(LocationNum) + 1);
                }
            }
            location.LocationName = LocationName;
            location.StorageId    = StorageId;
            location.LocaTypeId   = LocationTypeId;
            location.IsDelete     = 0;
            location.CreateTime   = DateTime.Now;
            bool val = LocationManager.Add(location);

            if (val)
            {
                return(Json("新增成功", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("新增失败", JsonRequestBehavior.AllowGet));
            }
        }