示例#1
0
        /// <summary>
        /// 导出存放地点
        /// </summary>
        /// <param name="context"></param>
        private void OnExportStoragePlace(HttpContext context)
        {
            var bll = new StoragePlace();
            var ds  = bll.GetExportData("", null);
            var dt  = ds.Tables[0];

            HttpClientHelper.Export(context, dt);
        }
示例#2
0
        public void UpdateStoragePlace(StoragePlace updatedStoragePlace)
        {
            db.StoragePlaces.Attach(updatedStoragePlace);
            var entry = db.Entry(updatedStoragePlace);

            entry.State = EntityState.Modified;
            db.SaveChanges();
        }
示例#3
0
        public void CheckStoragePlace_Null_ShouldNotThrowExtractorException()
        {
            // Arrange
            var          data          = new TestListsData();
            var          storagePlaces = data.StoragePlaces;
            StoragePlace storagePlace  = null;
            // Act
            Action act = () => ImportBookValidator.CheckStoragePlace(storagePlaces, storagePlace);

            // Assert
            act.Should().NotThrow();
        }
示例#4
0
 public ResResultModel GetCbbStoragePlace(LoginFmModel model)
 {
     try
     {
         var bll  = new StoragePlace();
         var list = bll.GetList();
         return(ResResult.Response(true, "", JsonConvert.SerializeObject(list)));
     }
     catch (Exception ex)
     {
         return(ResResult.Response(false, ex.Message, null));
     }
 }
示例#5
0
        public void CheckStoragePlace_StoragePlaceNotAtList_ShouldThrowInvalidOperationException()
        {
            // Arrange
            var          data          = new TestListsData();
            var          storagePlaces = data.StoragePlaces;
            StoragePlace storagePlace  = storagePlaces[0];

            storagePlaces.Add(storagePlace);
            // Act
            Action act = () => ImportBookValidator.CheckStoragePlace(storagePlaces, storagePlace);

            // Assert
            act.Should().Throw <InvalidOperationException>("Sequence contains more than one element");
        }
示例#6
0
        public Result UpdatePlace(StoragePlace place)
        {
            var result = _storageHelper.GetResult(() =>
            {
                var parameters = new List <NpgsqlParameter>();
                _pgHelper.AddParam(parameters, "p_place_id", NpgsqlTypes.NpgsqlDbType.Integer, place.Id);
                _pgHelper.AddParam(parameters, "p_parent_place_id", NpgsqlTypes.NpgsqlDbType.Integer, place.ParentPlaceId);
                _pgHelper.AddParam(parameters, "p_place_code", NpgsqlTypes.NpgsqlDbType.Varchar, place.PlaceCode);
                _pgHelper.AddParam(parameters, "p_place_type_id", NpgsqlTypes.NpgsqlDbType.Integer, (int)place.PlaceType);
                _pgHelper.AddParam(parameters, "p_is_enabled", NpgsqlTypes.NpgsqlDbType.Boolean, place.IsEnabled);
                _pgClinet.ExecuteNonQuery("geo.place__update", parameters);
            });

            return(result);
        }
示例#7
0
        public bool onAddClick(StoragePlace storagePlace, SilageStoragePlace silageStoragePlace)
        {
            string weight = silageStoragePlace.Weight.Replace(",", ".");

            if (!DAO.getInstance().addStoragePlace(storagePlace.IdRaw, silageStoragePlace.Number,
                                                   weight, SilageStoragePlace.NameTable, SilageStoragePlace.NumberAttr, SilageStoragePlace.WeightAttr))
            {
                MessageBox.Show("Данное сырье уже присутствует в данном хранилище!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#8
0
        public void CheckStoragePlace_StoragePlaceNotAtList_ShouldThrowExtractorException()
        {
            // Arrange
            var          data          = new TestListsData();
            var          storagePlaces = data.StoragePlaces;
            StoragePlace storagePlace  = storagePlaces[0];

            storagePlaces.RemoveAt(0);
            // Act
            Action act = () => ImportBookValidator.CheckStoragePlace(storagePlaces, storagePlace);

            // Assert
            act.Should()
            .Throw <ExtractorException>(
                $"Cannot find storage place on ImportStoragePlacesList, storage place [{storagePlace}]");
        }
示例#9
0
        public static void CheckStoragePlace(List <StoragePlace> storagePlaces, StoragePlace storagePlace)
        {
            if (storagePlace == null)
            {
                return;
            }

            var query = storagePlaces
                        .SingleOrDefault(a => a.StoragePlaceName == storagePlace.StoragePlaceName);

            if (query == null)
            {
                throw new ExtractorException(
                          $"Cannot find storage place on ImportStoragePlacesList, storage place [{storagePlace}]",
                          $"{storagePlace}");
            }
        }
示例#10
0
        public void SetUp()
        {
            var sp1 = new StoragePlace {
                Name = "sp1", PalletNumber = 298
            };

            this.StoragePlaceService
            .GetStoragePlace(Arg.Any <StoragePlaceRequestResource>()).Returns(
                new SuccessResult <StoragePlace>(sp1));

            this.Response = this.Browser.Get(
                "/inventory/storage-place",
                with =>
            {
                with.Header("Accept", "application/json");
                with.Query("palletNumber", "298");
            }).Result;
        }
示例#11
0
        public void SetUp()
        {
            var sp1 = new StoragePlace {
                Name = "sp1"
            };
            var sp2 = new StoragePlace {
                Name = "sp2"
            };

            this.StoragePlaceService.GetStoragePlaces("sp").Returns(
                new SuccessResult <IEnumerable <StoragePlace> >(new List <StoragePlace> {
                sp1, sp2
            }));

            this.Response = this.Browser.Get(
                "/inventory/storage-places",
                with =>
            {
                with.Header("Accept", "application/json");
                with.Query("searchTerm", "sp");
            }).Result;
        }
        private void Save_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (!ApplicationDbContext.Instance.StoragePlaces.Any(a =>
                                                                 a.StoragePlaceName.ToLower() == StoragePlaceTextBox.Text.ToLower()))
            {
                var storagePlace = new StoragePlace
                {
                    StoragePlaceName = StoragePlaceTextBox.Text, Id = Guid.NewGuid()
                };
                ApplicationDbContext.Instance.Entry(storagePlace).State = EntityState.Added;
                ApplicationDbContext.Instance.SaveChanges();
                StoragePlaceAdded?.Invoke(this, new EntityEventArgs <StoragePlace> {
                    Entity = storagePlace
                });

                this.Close();
            }

            else
            {
                StoragePlaceExistsTextBlock.Visibility = Visibility.Visible;
            }
        }
示例#13
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            double d = Convert.ToDouble(textBoxWeight.Text);

            if (Convert.ToDouble(textBoxWeight.Text) > weight)
            {
                MessageBox.Show(String.Format("Вес не должен превышать {0} тонн!", weight), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (comboBoxStorage.Text == "Склад")
                {
                    string[] res = DAO.getInstance().correctAddStorage(comboBoxNumber.Text, StoreStoragePlace.NameTable, StoreStoragePlace.NumberAttr);
                    if ((raw == res[0] && type == res[1] && subtype == res[2] && classRaw == res[3]) ||
                        (res[0] == null))
                    {
                        double capacity = DAO.getInstance().calcCapacity(StoreStoragePlace.NameTable, StoreStoragePlace.WeightAttr,
                                                                         StoreStoragePlace.NumberAttr, comboBoxNumber.Text);
                        double count = capacity + Convert.ToDouble(textBoxWeight.Text);
                        if (count > Store.Capacity)
                        {
                            MessageBox.Show(String.Format("Склад переполнен на {0} тонн(ы)! Вместимость 3500 тонн!", count - Store.Capacity), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            if (store == null)
                            {
                                storagePlace = new StoragePlace(idRaw);
                                store        = new StoreStoragePlace(idRaw, comboBoxNumber.Text, textBoxWeight.Text);
                                if (controller.onAddClick(storagePlace, store))
                                {
                                    this.Close();
                                }
                                else
                                {
                                    store = null;
                                }
                            }
                            else
                            {
                                store.Number = comboBoxNumber.Text;
                                store.Weight = textBoxWeight.Text;
                                if (controller.onUpdateClick(store, number))
                                {
                                    this.Close();
                                }
                                else
                                {
                                    store = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Сырье не может находится в данном хранилище, произойдет смешивание!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    string[] res = DAO.getInstance().correctAddStorage(comboBoxNumber.Text, SilageStoragePlace.NameTable, SilageStoragePlace.NumberAttr);
                    if ((raw == res[0] && type == res[1] && subtype == res[2] && classRaw == res[3]) ||
                        (res[0] == null))
                    {
                        double capacity = DAO.getInstance().calcCapacity(SilageStoragePlace.NameTable, SilageStoragePlace.WeightAttr,
                                                                         SilageStoragePlace.NumberAttr, comboBoxNumber.Text);
                        double count = capacity + Convert.ToDouble(textBoxWeight.Text);
                        if (count > Silage.Capacity)
                        {
                            MessageBox.Show(String.Format("Силос переполнен на {0} тонн(ы)! Вместимость 150 тонн!", count - Silage.Capacity), "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            if (silage == null)
                            {
                                storagePlace = new StoragePlace(idRaw);
                                silage       = new SilageStoragePlace(idRaw, comboBoxNumber.Text, textBoxWeight.Text);
                                if (controller.onAddClick(storagePlace, silage))
                                {
                                    this.Close();
                                }
                                else
                                {
                                    silage = null;
                                }
                            }
                            else
                            {
                                silage.Number = comboBoxNumber.Text;
                                silage.Weight = textBoxWeight.Text;
                                if (controller.onUpdateClick(silage, number))
                                {
                                    this.Close();
                                }
                                else
                                {
                                    silage = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Сырье не может находится в данном хранилище, произойдет смешивание!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
示例#14
0
        /// <summary>
        /// 导入资产信息
        /// </summary>
        /// <param name="context"></param>
        private void OnImportProduct(HttpContext context)
        {
            var files = context.Request.Files;

            if (files.Count == 0)
            {
                throw new ArgumentException(MC.M_UploadFileNotExist);
            }

            var appCode = context.Request.Form["AppCode"];
            var userId  = WebCommon.GetUserId();
            var orgId   = new Staff().GetOrgId(userId);

            var bll      = new Product();
            var orgBll   = new OrgDepmt();
            var spBll    = new StoragePlace();
            var cBll     = new Category();
            int effect   = 0;
            var currTime = DateTime.Now;

            foreach (string item in files.AllKeys)
            {
                HttpPostedFile file = files[item];
                if (file == null || file.ContentLength == 0)
                {
                    continue;
                }
                var dt = ExcelHelper.Import(file.InputStream);
                if (dt == null || dt.Rows.Count == 0)
                {
                    throw new CustomException(MC.M_UploadFileDataNotExist);
                }
                //var id = Guid.Empty;

                var drc = dt.Rows;
                foreach (DataRow dr in drc)
                {
                    var currInfo = new ProductInfo();

                    #region 请求参数集

                    if (dr["资产分类编码"] != null)
                    {
                        currInfo.CategoryCode = dr["资产分类编码"].ToString().Trim();
                    }
                    if (dr["资产分类"] != null)
                    {
                        currInfo.CategoryName = dr["资产分类"].ToString().Trim();
                    }

                    if (string.IsNullOrWhiteSpace(currInfo.CategoryCode) || string.IsNullOrWhiteSpace(currInfo.CategoryName))
                    {
                        throw new CustomException(MC.GetString(MC.Request_InvalidArgument, "资产编码、资产名称"));
                    }
                    var oldCategoryInfo = cBll.GetModel(currInfo.CategoryCode, currInfo.CategoryName);
                    if (oldCategoryInfo == null)
                    {
                        throw new CustomException(MC.GetString(MC.P_InvalidError, string.Format("资产分类编码“{0}”、资产分类为“{1}”", currInfo.CategoryCode, currInfo.CategoryName)));
                    }
                    currInfo.CategoryId = oldCategoryInfo.Id;

                    //if (dr["资产编码"] != null) currInfo.Coded = dr["资产编码"].ToString().Trim();
                    if (dr["资产名称"] != null)
                    {
                        currInfo.Named = dr["资产名称"].ToString().Trim();
                    }
                    //if (bll.IsExist(currInfo.Coded, currInfo.Named)) continue;
                    var sCoded = bll.GetRndCode(oldCategoryInfo.Coded, 8);
                    currInfo.Coded = sCoded;
                    var qty = 0;
                    if (dr["数量"] != null)
                    {
                        int.TryParse(dr["数量"].ToString(), out qty);
                    }
                    currInfo.Qty = 1;
                    if (qty < 1)
                    {
                        throw new CustomException(string.Format("数量为“{0}”", qty));
                    }
                    if (dr["规格型号"] != null)
                    {
                        currInfo.SpecModel = dr["规格型号"].ToString().Trim();
                    }
                    var price = 0m;
                    if (dr["单价"] != null && decimal.TryParse(dr["单价"].ToString(), out price))
                    {
                        currInfo.Price = price;
                    }
                    var amount = 0m;
                    if (dr["金额"] != null && decimal.TryParse(dr["金额"].ToString(), out amount))
                    {
                        currInfo.Amount = amount;
                    }
                    if (dr["计量单位"] != null)
                    {
                        currInfo.MeterUnit = dr["计量单位"].ToString().Trim();
                    }
                    var pieceQty = 0;
                    //if (dr["件数"] != null && int.TryParse(dr["件数"].ToString(),out pieceQty)) currInfo.PieceQty = pieceQty;
                    if (dr["资产属性"] != null)
                    {
                        currInfo.Pattr = dr["资产属性"].ToString().Trim();
                    }
                    if (dr["资产来源"] != null)
                    {
                        currInfo.SourceFrom = dr["资产来源"].ToString().Trim();
                    }
                    if (dr["供应商"] != null)
                    {
                        currInfo.Supplier = dr["供应商"].ToString().Trim();
                    }
                    var buyDate = DateTime.MinValue;
                    if (dr["购入日期"] != null)
                    {
                        DateTime.TryParse(dr["购入日期"].ToString(), out buyDate);
                    }
                    if (buyDate == DateTime.MinValue)
                    {
                        buyDate = DateTime.Parse("1754-01-01");
                    }
                    currInfo.BuyDate = buyDate;
                    var enableDate = DateTime.MinValue;
                    if (dr["启用日期"] != null && DateTime.TryParse(dr["启用日期"].ToString(), out enableDate))
                    {
                        currInfo.EnableDate = enableDate.ToString("yyyy-MM-dd");
                    }
                    if (dr["使用期限"] != null)
                    {
                        currInfo.UseDateLimit = dr["使用期限"].ToString().Trim();
                    }
                    if (dr["使用部门"] != null)
                    {
                        currInfo.UseOrgName = dr["使用部门"].ToString().Trim();
                    }
                    if (dr["使用部门编码"] != null)
                    {
                        currInfo.UseOrgCode = dr["使用部门编码"].ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(currInfo.UseOrgCode) || !string.IsNullOrEmpty(currInfo.UseOrgName))
                    {
                        var useOrgInfo = orgBll.GetModel(currInfo.UseOrgCode, currInfo.UseOrgName);
                        if (useOrgInfo == null)
                        {
                            throw new CustomException(MC.GetString(MC.P_InvalidError, string.Format("使用部门编码“{0}”、使用部门“{1}”", currInfo.UseOrgCode, currInfo.UseOrgName)));
                        }
                        currInfo.UseDepmtId = useOrgInfo.Id;
                    }

                    if (dr["实物管理部门"] != null)
                    {
                        currInfo.MgrOrgName = dr["实物管理部门"].ToString().Trim();
                    }
                    if (dr["实物管理部门编码"] != null)
                    {
                        currInfo.MgrOrgCode = dr["实物管理部门编码"].ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(currInfo.MgrOrgCode) || !string.IsNullOrEmpty(currInfo.MgrOrgName))
                    {
                        var mgrOrgInfo = orgBll.GetModel(currInfo.MgrOrgCode, currInfo.MgrOrgName);
                        if (mgrOrgInfo == null)
                        {
                            throw new CustomException(MC.GetString(MC.P_InvalidError, string.Format("实物管理部门编码“{0}”、实物管理部门“{1}”", currInfo.MgrOrgCode, currInfo.MgrOrgName)));
                        }
                        currInfo.MgrDepmtId = mgrOrgInfo.Id;
                    }

                    if (dr["存放地点"] != null)
                    {
                        currInfo.StoragePlaceName = dr["存放地点"].ToString().Trim();
                    }
                    if (dr["存放地点编码"] != null)
                    {
                        currInfo.StoragePlaceCode = dr["存放地点编码"].ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(currInfo.StoragePlaceCode) || !string.IsNullOrEmpty(currInfo.StoragePlaceName))
                    {
                        var storagePlaceInfo = spBll.GetModel(currInfo.StoragePlaceCode, currInfo.StoragePlaceName);
                        if (storagePlaceInfo == null)
                        {
                            throw new CustomException(MC.GetString(MC.P_InvalidError, string.Format("存放地点编码“{0}”、存放地点“{1}”", currInfo.StoragePlaceCode, currInfo.StoragePlaceName)));
                        }
                        currInfo.StoragePlaceId = storagePlaceInfo.Id;
                    }

                    if (dr["使用人"] != null)
                    {
                        currInfo.UsePersonName = dr["使用人"].ToString().Trim();
                    }

                    #endregion

                    currInfo.AppCode         = appCode;
                    currInfo.UserId          = userId;
                    currInfo.DepmtId         = orgId;
                    currInfo.RecordDate      = currTime;
                    currInfo.LastUpdatedDate = currTime;

                    effect += bll.Insert(currInfo);

                    if (qty > 1)
                    {
                        for (var i = 1; i < qty; i++)
                        {
                            currInfo.Coded = bll.GetRndCode(sCoded, 11);
                            effect        += bll.Insert(currInfo);
                        }
                    }
                }
            }
            if (effect < 1)
            {
                context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
            }
            else
            {
                context.Response.Write(ResResult.ResJsonString(true, MC.M_Save_Ok, effect));
            }
        }
示例#15
0
        /// <summary>
        /// 导入存放地点
        /// </summary>
        /// <param name="context"></param>
        private void OnImportStoragePlace(HttpContext context)
        {
            var files = context.Request.Files;

            if (files.Count == 0)
            {
                throw new ArgumentException(MC.M_UploadFileNotExist);
            }

            var appCode = context.Request.Form["AppCode"];
            var userId  = WebCommon.GetUserId();
            var orgId   = new Staff().GetOrgId(userId);

            var bll    = new StoragePlace();
            int effect = 0;

            foreach (string item in files.AllKeys)
            {
                HttpPostedFile file = files[item];
                if (file == null || file.ContentLength == 0)
                {
                    continue;
                }
                var dt = ExcelHelper.Import(file.InputStream);
                if (dt == null || dt.Rows.Count == 0)
                {
                    throw new ArgumentException(MC.M_UploadFileDataNotExist);
                }
                var currTime = DateTime.Now;
                var id       = Guid.Empty;

                var drc = dt.Rows;
                foreach (DataRow dr in drc)
                {
                    #region 请求参数集

                    string coded = string.Empty;
                    if (dr["存放地点编码"] != null)
                    {
                        coded = dr["存放地点编码"].ToString().Trim();
                    }
                    string named = string.Empty;
                    if (dr["存放地点"] != null)
                    {
                        named = dr["存放地点"].ToString().Trim();
                    }

                    if (!string.IsNullOrWhiteSpace(named))
                    {
                        if (string.IsNullOrWhiteSpace(coded))
                        {
                            coded = bll.GetRndCode(6);
                        }
                        if (bll.GetModel(null, named) != null)
                        {
                            continue;
                        }
                        var currInfo = new StoragePlaceInfo(id, appCode, userId, orgId, coded, named, currTime, currTime);
                        effect += bll.Insert(currInfo);
                    }

                    #endregion
                }
            }
            if (effect < 1)
            {
                context.Response.Write(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
            }
            else
            {
                context.Response.Write(ResResult.ResJsonString(true, MC.M_Save_Ok, effect));
            }
        }
示例#16
0
 public StoragePlaceViewModel(Base.Models.StoragePlace StoragePlace, IDataProvider <Base.Models.StoragePlace> StoragePlacesProvider)
 {
     this.StoragePlace          = StoragePlace;
     this.StoragePlacesProvider = StoragePlacesProvider;
 }