Esempio n. 1
0
        public async Task <bool> UpdateAsync(GoodsAddEditModel goods)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                GoodsEntity entity = await dbc.GetAll <GoodsEntity>().SingleOrDefaultAsync(g => g.Id == goods.Id);

                if (entity == null)
                {
                    return(false);
                }
                entity.Description       = goods.Description;
                entity.GoodsAreaId       = goods.GoodsAreaId;
                entity.GoodsSecondTypeId = goods.GoodsSecondTypeId.Value;
                entity.GoodsTypeId       = goods.GoodsTypeId;
                entity.Inventory         = goods.Inventory;
                entity.IsPutaway         = goods.IsPutaway;
                entity.IsRecommend       = goods.IsRecommend;
                entity.Name         = goods.Name;
                entity.Price        = goods.Price;
                entity.RealityPrice = goods.RealityPrice;
                await dbc.SaveChangesAsync();

                return(true);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 得到商品详情
        /// </summary>
        /// <returns></returns>
        public virtual IList <GoodsDetailEntity> GetGoodsDetails(GoodsEntity goods)
        {
            var dataEntity = GoodsDetail();
            var infos      = new List <GoodsDetailEntity>();
            var info       = new GoodsDetailEntity
            {
                Detail         = Editor1.TextArea.Value,
                Name           = "Detail",
                Attachment     = upAttchment.GetFileName(),
                AttachmentByte = upAttchment.GetFileByte(),
                Goods          = goods,
                Product        = new ProductEntity {
                    Id = 0
                }
            };

            if (dataEntity != null)
            {
                info.SaveType = SaveType.Modify;
                info.SetProperty(it => it.Detail);
                info.SetProperty(it => it.Attachment);
                info.Id = dataEntity.Id;
            }
            else
            {
                info.SaveType = SaveType.Add;
            }
            infos.Add(info);
            return(infos);
        }
Esempio n. 3
0
        public async Task <long> AddAsync(GoodsAddEditModel goods)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                GoodsEntity entity = new GoodsEntity();
                entity.Code              = CommonHelper.GetRandom2();
                entity.Description       = goods.Description;
                entity.GoodsAreaId       = goods.GoodsAreaId;
                entity.GoodsSecondTypeId = goods.GoodsSecondTypeId.Value;
                entity.GoodsTypeId       = goods.GoodsTypeId;
                entity.Inventory         = goods.Inventory;
                entity.IsPutaway         = goods.IsPutaway;
                entity.IsRecommend       = goods.IsRecommend;
                entity.Name              = goods.Name;
                entity.Price             = goods.Price;
                entity.RealityPrice      = goods.RealityPrice;
                entity.Standard          = "件";
                dbc.Goods.Add(entity);
                await dbc.SaveChangesAsync();

                BonusRatioEntity bonusRatio = new BonusRatioEntity();
                bonusRatio.GoodsId = entity.Id;
                dbc.BonusRatios.Add(bonusRatio);
                await dbc.SaveChangesAsync();

                return(entity.Id);
            }
        }
Esempio n. 4
0
        public async Task <long> UpdateAsync(long userId, long goodsId, long?num, bool?isSelected)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                GoodsCarEntity entity = await dbc.GetAll <GoodsCarEntity>().SingleOrDefaultAsync(g => g.UserId == userId && g.GoodsId == goodsId);

                if (entity == null)
                {
                    return(-1);
                }
                GoodsEntity goods = await dbc.GetAll <GoodsEntity>().SingleOrDefaultAsync(g => g.Id == entity.GoodsId);

                if (goods == null)
                {
                    return(-2);
                }
                if (num != null)
                {
                    if (goods.Inventory < num)
                    {
                        return(-3);
                    }
                    entity.Number = num.Value;
                }
                if (isSelected != null)
                {
                    entity.IsSelected = isSelected.Value;
                }
                await dbc.SaveChangesAsync();

                return(1);
            }
        }
Esempio n. 5
0
        public static GoodsEntity GetOneBySerial(string serialId, string hospitalId)
        {
            var sql = string.Format(@"
select top 1 {0} from goods 
where serial_id = @p_serial_id and hospital_id = @p_hospital_id 
and package_count > granted_count and status = @p_status", COLUMN_SQL);

            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_serial_id", DbType.String, serialId);
            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);
            db.AddInParameter(dc, "p_status", DbType.Int32, (int)GoodsStatus.Usable);

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var entity = new GoodsEntity();
                    entity.Init(reader);

                    return(entity);
                }

                return(null);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 从Entity到info
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static GoodsInfo TranslateGoodsInfo(GoodsEntity entity)
        {
            GoodsInfo info = new GoodsInfo();

            if (entity != null)
            {
                info.GoodsID     = entity.GoodsID;
                info.TypeCode    = entity.TypeCode;
                info.CustomerID  = entity.CustomerID;
                info.GoodsNo     = entity.GoodsNo;
                info.GoodsName   = entity.GoodsName;
                info.GoodsModel  = entity.GoodsModel;
                info.Weight      = entity.Weight;
                info.Size        = entity.Size;
                info.Units       = entity.Units;
                info.Costing     = entity.Costing;
                info.SalePrice   = entity.SalePrice;
                info.Torr        = entity.Torr;
                info.exDate      = entity.exDate;
                info.exUnits     = entity.exUnits;
                info.AnotherNO   = entity.AnotherNO;
                info.AnotherName = entity.AnotherName;
                info.Remark      = entity.Remark;
                info.OperatorID  = entity.OperatorID;
                info.Status      = entity.Status;
                info.BarCode     = entity.BarCode;
                info.CreateDate  = entity.CreateDate;
                info.ChangeDate  = entity.ChangeDate;
            }
            return(info);
        }
Esempio n. 7
0
        private static void AdjustInventory(GoodsEntity goods, string serialId, int count, int packageCount, string userId,
                                            Database db, DbTransaction trans)
        {
            var inventroy = new GoodsInventoryEntity
            {
                SerialId      = serialId,
                BatchNo       = goods.BatchNo,
                ProductId     = goods.ProductId,
                StoreroomId   = goods.StoreroomId,
                ExpiredDate   = goods.ExpiredDate,
                HospitalId    = goods.HospitalId,
                VendorId      = goods.VendorId,
                OriginalCount = count,
                SplitCount    = 0,
                UsableCount   = count,
                ApplyCount    = packageCount * count,
                GrantedCount  = 0,
                CreatedId     = userId,
                CreatedTime   = DateTime.Now
            };

            GoodsInventoryRepository.Create(inventroy, db, trans);

            Reduce(goods.Barcode, 1, goods.HospitalId, db, trans);
            GoodsInventoryRepository.Reduce(goods.SerialId, goods.HospitalId, 1, db, trans);

            if (goods.PackageCount == goods.GrantedCount + 1)
            {
                Complete(goods.Id, db, trans);
            }
        }
Esempio n. 8
0
        private GoodsDTO ToDTO(GoodsEntity entity)
        {
            GoodsDTO dto = new GoodsDTO();

            dto.Code                = entity.Code;
            dto.CreateTime          = entity.CreateTime;
            dto.Description         = entity.Description;
            dto.GoodsAreaId         = entity.GoodsAreaId;
            dto.GoodsAreaTitle      = "";
            dto.GoodsSecondTypeId   = entity.GoodsSecondType.Name == "空类型" ? (long?)null : entity.GoodsSecondTypeId;
            dto.GoodsSecondTypeName = entity.GoodsSecondType.Name == "空类型" ? "" : entity.GoodsSecondType.Name;
            dto.GoodsTypeId         = entity.GoodsTypeId;
            dto.GoodsTypeName       = entity.GoodsType.Name;
            dto.Id           = entity.Id;
            dto.Inventory    = entity.Inventory;
            dto.IsPutaway    = entity.IsPutaway;
            dto.IsRecommend  = entity.IsRecommend;
            dto.Name         = entity.Name;
            dto.Price        = entity.Price;
            dto.RealityPrice = entity.RealityPrice;
            dto.SaleNum      = entity.SaleNum;
            dto.Standard     = entity.Standard;
            dto.IsHotSale    = entity.IsHotSale;
            return(dto);
        }
Esempio n. 9
0
        private static List <InventoryInfo> buildInventoryList(GoodsEntity entity, int StorageID, int Quantity, string BatchNumber, long OperatorID)
        {
            List <InventoryInfo> listInv = new List <InventoryInfo>();
            InventoryInfo        info    = new InventoryInfo();

            if (entity != null)
            {
                info.GoodsID       = entity.GoodsID;
                info.StorageID     = StorageID;
                info.Quantity      = Quantity;
                info.CustomerID    = entity.CustomerID;
                info.InventoryType = Common.InventoryType.入库.ToString();
                info.BatchNumber   = BatchNumber.Trim();
                info.ProductDate   = convertDatetime(BatchNumber);
                info.InventoryDate = DateTime.Parse(DateTime.Now.ToShortDateString());
                info.UnitPrice     = 0;
                info.Remark        = "PDA设备入库操作";
                info.OperatorID    = OperatorID;
                info.CreateDate    = DateTime.Now;
                info.ChangeDate    = DateTime.Now;
                listInv.Add(info);
            }

            return(listInv);
        }
Esempio n. 10
0
        public bool EditGoods(GoodsEntity goods)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbGoods set");
            strSql.Append("goods_name=@GoodsName,goods_intro=@GoodsIntro,goods_CP=@Goodsprice,goods_CBY=@CreateBy,goodsCDT=@CreateDateTime,goods_pic=@Picture,type_id=@TypeId");
            strSql.Append("where id = @GoodsId");
            SqlParameter[] paras =
            {
                new SqlParameter("@GoodsName",      goods.GoodsName),
                new SqlParameter("@GoodsIntro",     goods.GoodsIntro),
                new SqlParameter("@Goodsprice",     goods.GoodsPrice),
                new SqlParameter("@CreateBy",       goods.GoodsCreateBy),
                new SqlParameter("@CreateDateTime", goods.GoodsCreateTime),
                new SqlParameter("@Picture",        goods.GoodsPicture),
                new SqlParameter("@TypeId",         goods.GoodsType),
                new SqlParameter("@GoodsId",        goods.GoodsID)
            };
            object obj = SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), paras);

            if (Convert.ToInt32(obj) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 获取图片
        /// </summary>
        /// <param name="goods"></param>
        /// <returns></returns>
        public virtual IList <GoodsImageEntity> GetGoodsImages(GoodsEntity goods)
        {
            var infos = new List <GoodsImageEntity>();

            AddGoodsImage(infos, goods);
            return(infos);
        }
Esempio n. 12
0
        public static IList <GoodsEntity> GetByParent(string parentId, string hospitalId)
        {
            var sql = string.Format("select {0} from goods where parent_id = @p_parent_id and hospital_id = @p_hospital_id", COLUMN_SQL);

            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_parent_id", DbType.String, parentId);
            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);

            var list = new List <GoodsEntity>();

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var entity = new GoodsEntity();
                    entity.Init(reader);

                    list.Add(entity);
                }
            }

            return(list);
        }
Esempio n. 13
0
        //        public static IList<ProductInventoryEntity> QueryProductInventory(ProductInventoryCondition condition)
        //        {
        //            var list = new List<ProductInventoryEntity>();
        //            SplittingProductInventory(condition, list);
        //            UsableProductInventory(condition, list);

        //            return list;
        //        }

        //        private static void SplittingProductInventory(ProductInventoryCondition condition, IList<ProductInventoryEntity> list)
        //        {
        //            var conditionSql = "";
        //            if (!string.IsNullOrEmpty(condition.StoreroomId))
        //            {
        //                conditionSql += "and a.storeroom_id=@p_storeroom_id";
        //            }
        //            if (!string.IsNullOrEmpty(condition.ProductId))
        //            {
        //                conditionSql += " and a.product_id=@p_product_id";
        //            }

        //            var sql = string.Format(@"select
        //	a.storeroom_id,a.product_id,a.expired_date,count(*) number
        //from goods a join goods_extra b on a.extra_id=b.id and b.need_split=1
        //where hospital_id=@p_hospital_id {0}
        //group by a.storeroom_id, a.product_id, a.expired_date", conditionSql);

        //            var db = DatabaseFactory.CreateDatabase();
        //            var dc = db.GetSqlStringCommand(sql);

        //            db.AddInParameter(dc, "p_hospital_id", DbType.String, condition.HospitalId);
        //            if (!string.IsNullOrEmpty(condition.StoreroomId))
        //            {
        //                db.AddInParameter(dc, "p_storeroom_id", DbType.String, condition.StoreroomId);
        //            }
        //            if (!string.IsNullOrEmpty(condition.ProductId))
        //            {
        //                db.AddInParameter(dc, "p_product_id", DbType.String, condition.ProductId);
        //            }

        //            using (var reader = db.ExecuteReader(dc))
        //            {
        //                while (reader.Read())
        //                {
        //                    var entity = new ProductInventoryEntity();
        //                    entity.Init(reader, true);

        //                    list.Add(entity);
        //                }
        //            }
        //        }

        //        private static void UsableProductInventory(ProductInventoryCondition condition, IList<ProductInventoryEntity> list)
        //        {
        //            var conditionSql = "";
        //            if (!string.IsNullOrEmpty(condition.StoreroomId))
        //            {
        //                conditionSql += "and a.storeroom_id=@p_storeroom_id";
        //            }
        //            if (!string.IsNullOrEmpty(condition.ProductId))
        //            {
        //                conditionSql += " and a.product_id=@p_product_id";
        //            }

        //            var sql = string.Format(@"select
        //	a.storeroom_id,a.product_id,a.expired_date,count(*) number
        //from goods a join goods_extra b on a.extra_id=b.id and b.need_split=0
        //where hospital_id=@p_hospital_id {0}
        //group by a.storeroom_id, a.product_id, a.expired_date", conditionSql);

        //            var db = DatabaseFactory.CreateDatabase();
        //            var dc = db.GetSqlStringCommand(sql);

        //            db.AddInParameter(dc, "p_hospital_id", DbType.String, condition.HospitalId);
        //            if (!string.IsNullOrEmpty(condition.StoreroomId))
        //            {
        //                db.AddInParameter(dc, "p_storeroom_id", DbType.String, condition.StoreroomId);
        //            }
        //            if (!string.IsNullOrEmpty(condition.ProductId))
        //            {
        //                db.AddInParameter(dc, "p_product_id", DbType.String, condition.ProductId);
        //            }

        //            using (var reader = db.ExecuteReader(dc))
        //            {
        //                while (reader.Read())
        //                {
        //                    var entity = new ProductInventoryEntity();
        //                    entity.Init(reader, false);

        //                    list.Add(entity);
        //                }
        //            }
        //        }
        #endregion

        public static List <GoodsEntity> GetMovableGoods(string hospitalId, string storeroomId, string productId)
        {
            var sql = string.Format(@"select {0} from goods g
where hospital_id = @p_hospital_id 
and storeroom_id = @p_storeroom_id 
and product_id = @p_product_id
and status = 1
and granted_count = 0 
and not exists(select 1 from goods_runtime gr where g.serial_id = gr.serial_id and g.barcode = gr.barcode) 
and not exists(select 1 from goods_runtime gr, move_form_serial mfs where gr.apply_id = mfs.move_id and gr.serial_id = mfs.to_serial and g.serial_id = mfs.from_serial and g.barcode = gr.barcode)
order by expired_date, created_time ", COLUMN_SQL);

            var db = DatabaseFactory.CreateDatabase();
            var dc = db.GetSqlStringCommand(sql);

            db.AddInParameter(dc, "p_hospital_id", DbType.String, hospitalId);
            db.AddInParameter(dc, "p_storeroom_id", DbType.String, storeroomId);
            db.AddInParameter(dc, "p_product_id", DbType.String, productId);

            var list = new List <GoodsEntity>();

            using (var reader = db.ExecuteReader(dc))
            {
                while (reader.Read())
                {
                    var entity = new GoodsEntity();
                    entity.Init(reader);

                    list.Add(entity);
                }
            }
            return(list);
        }
Esempio n. 14
0
    /// <summary>
    /// 请求商店配置回调
    /// </summary>
    /// <param name="args"></param>
    private void OnRequestShopConfigCallBack(NetWorkHttp.CallBackArgs args)
    {
        if (args.HasError)
        {
            ShowMessage("提示", "网络连接失败");
        }
        else
        {
            if (args.Value.code < 0)
            {
                ShowMessage("提示", args.Value.msg);
                return;
            }
            TransferData        data    = new TransferData();
            List <TransferData> lstShop = new List <TransferData>();

            m_GoodsList.Clear();

            for (int i = 0; i < args.Value.data.Count; ++i)
            {
                LitJson.JsonData jsonData = args.Value.data[i];
                int    id        = jsonData["id"].ToString().ToInt();
                string name      = jsonData["name"].ToString();
                string iosCode   = jsonData["iosCode"].ToString();
                int    money     = jsonData["money"].ToString().ToInt();
                int    amount    = jsonData["amount"].ToString().ToInt();
                int    giveCount = jsonData["give"].ToString().ToInt();
                bool   isHot     = jsonData["isHot"].ToString().ToBool();
                string icon      = jsonData["icon"].ToString();

                TransferData shopData = new TransferData();
                shopData.SetValue("ShopId", id);
                shopData.SetValue("ShopName", name);
                shopData.SetValue("IosCode", iosCode);
                shopData.SetValue("Money", money);
                shopData.SetValue("Amount", amount);
                shopData.SetValue("GiveCount", giveCount);
                shopData.SetValue("IsHot", isHot);
                shopData.SetValue("Icon", icon);
                lstShop.Add(shopData);

                GoodsEntity goods = new GoodsEntity()
                {
                    amount    = amount,
                    giveCount = giveCount,
                    icon      = icon,
                    id        = id,
                    iosCode   = iosCode,
                    isHot     = isHot,
                    money     = money,
                    name      = name
                };

                m_GoodsList.Add(goods);
            }
            data.SetValue("ShopList", lstShop);
            data.SetValue("BindCode", AccountProxy.Instance.CurrentAccountEntity.codebind);
            m_UIShopWindow.SetUI(data, OnPropClick, OnBtnInfoClick);
        }
    }
Esempio n. 15
0
        public async Task <long> AddListAsync(List <OrderListAdd> goodsLists)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                foreach (var goods in goodsLists)
                {
                    GoodsEntity goodsEntity = await dbc.GetAll <GoodsEntity>().SingleOrDefaultAsync(g => g.Id == goods.GoodsId);

                    if (goodsEntity == null)
                    {
                        return(-1);
                    }
                    OrderListEntity entity = new OrderListEntity();
                    entity.OrderId = goods.OrderId;
                    entity.GoodsId = goods.GoodsId;
                    entity.Number  = goods.Number;
                    entity.Price   = goodsEntity.RealityPrice;
                    string imgUrl = await dbc.GetAll <GoodsImgEntity>().Where(g => g.GoodsId == goods.GoodsId).Select(g => g.ImgUrl).FirstOrDefaultAsync();

                    if (imgUrl == null)
                    {
                        entity.ImgUrl = "";
                    }
                    else
                    {
                        entity.ImgUrl = imgUrl;
                    }
                    entity.TotalFee = entity.Price * entity.Number;
                    dbc.OrderLists.Add(entity);
                }
                await dbc.SaveChangesAsync();

                return(1);
            }
        }
Esempio n. 16
0
    /// <summary>
    /// 商品点击
    /// </summary>
    /// <param name="propId"></param>
    private void OnPropClick(int goodsId)
    {
#if IS_DAZHONG
        if (AccountProxy.Instance.CurrentAccountEntity.codebind == 0 && !m_isPrompted)
        {
            m_isPrompted = true;
            ShowMessage("提示", "您还没有绑定邀请码,是否前往绑定?(绑定后可获得房卡奖励)", MessageViewType.OkAndCancel, OnTipOkClick, null);
            return;
        }
#endif
        if (GlobalInit.Instance.PaymentType == PaymentType.Official)
        {
            WXPayOrder(goodsId, 0);
        }
        else
        {
            GoodsEntity goods = null;
            for (int i = 0; i < m_GoodsList.Count; ++i)
            {
                if (m_GoodsList[i].id == goodsId)
                {
                    goods = m_GoodsList[i];
                }
            }
            OpenPaymentView(goods.amount, goods.money);
            m_CurrentSelectId = goodsId;
        }
    }
Esempio n. 17
0
        /// <summary>
        /// 从info到Entity
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static GoodsEntity TranslateGoodsEntity(GoodsInfo info)
        {
            GoodsEntity entity = new GoodsEntity();

            if (info != null)
            {
                entity.GoodsID     = info.GoodsID;
                entity.TypeCode    = info.TypeCode;
                entity.CustomerID  = info.CustomerID;
                entity.GoodsNo     = info.GoodsNo;
                entity.GoodsName   = info.GoodsName;
                entity.GoodsModel  = info.GoodsModel;
                entity.Weight      = info.Weight;
                entity.Size        = info.Size;
                entity.Units       = info.Units;
                entity.Costing     = info.Costing;
                entity.SalePrice   = info.SalePrice;
                entity.Torr        = info.Torr;
                entity.exDate      = info.exDate;
                entity.exUnits     = info.exUnits;
                entity.AnotherNO   = info.AnotherNO;
                entity.AnotherName = info.AnotherName;
                entity.Remark      = info.Remark;
                entity.BarCode     = info.BarCode;
                entity.OperatorID  = info.OperatorID;
                entity.Status      = info.Status;
                entity.CreateDate  = info.CreateDate;
                entity.ChangeDate  = info.ChangeDate;

                entity.customer = new CustomerEntity();
                entity.customer = CustomerService.GetCustomerById(info.CustomerID);
            }
            return(entity);
        }
Esempio n. 18
0
        /// <summary>
        /// 添加商品属性
        /// </summary>
        /// <param name="infos"></param>
        /// <param name="goods"></param>
        /// <param name="ids"></param>
        protected virtual void AddGoodsProperty(IList <GoodsPropertyEntity> infos, GoodsEntity goods, IDictionary <long, object> ids)
        {
            if (string.IsNullOrEmpty(hfPropertyValue.Value))
            {
                return;
            }
            var arrayList = hfPropertyValue.Value.Replace("\\", "\\\\").DeserializeJson <IList <IDictionary <string, object> > >();

            foreach (Dictionary <string, object> dictionary in arrayList)
            {
                if (ids.ContainsKey(dictionary["PropertyId"].Convert <long>()))
                {
                    continue;
                }
                var info = new GoodsPropertyEntity {
                    Product = new ProductEntity {
                        Id = 0
                    }
                };
                foreach (var o in dictionary)
                {
                    if (SaveType == SaveType.Add && o.Key.Equals("Id"))
                    {
                        continue;
                    }
                    var name = o.Key.Equals("PropertyId") ? "Property.Id" : o.Key;
                    Winner.Creator.Get <IProperty>().SetValue(info, name, o.Value);
                }
                infos.Add(info);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 得到商品属性
        /// </summary>
        /// <returns></returns>
        public virtual IList <GoodsPropertyEntity> GetGoodsProperties(GoodsEntity goods)
        {
            var infos = new List <GoodsPropertyEntity>();
            var ids   = new Dictionary <long, object>();

            foreach (var product in goods.Products)
            {
                if (product.SkuJsons == null)
                {
                    continue;
                }
                foreach (var json in product.SkuJsons)
                {
                    infos.Add(new GoodsPropertyEntity
                    {
                        Product  = product,
                        Goods    = goods,
                        Property = new PropertyEntity {
                            Id = json.Id
                        },
                        Value = json.Value
                    });
                    if (!ids.ContainsKey(json.Id))
                    {
                        ids.Add(json.Id, json.Id);
                    }
                }
            }
            AddGoodsProperty(infos, goods, ids);
            return(infos);
        }
Esempio n. 20
0
        /// <summary>
        /// 得到商品属性
        /// </summary>
        /// <returns></returns>
        public virtual IList <ProductEntity> GetProducts(GoodsEntity goods)
        {
            var infos = new List <ProductEntity>();

            AddProduct(goods, infos);
            if (infos.Count == 0)
            {
                var info = new ProductEntity
                {
                    Id             = hfProductId.Value.Convert <long>(),
                    Count          = txtCount.Value.Convert <int>(),
                    OrderMinCount  = txtOrderMinCount.Value.Convert <int>(),
                    OrderStepCount = txtOrderStepCount.Value.Convert <int>(),
                    DataId         = txtDataId.Value,
                    Cost           = txtCost.Value.Convert <decimal>(),
                    Price          = txtPrice.Value.Convert <decimal>(),
                    Sku            = "",
                    IsReturn       = ckIsReturn.Checked,
                    IsCustom       = ckIsCustom.Checked,
                    DepositRate    = txtDespoitRate.Value.Convert <decimal>(),
                    IsSales        = ckIsSales.Checked,
                    Name           = goods.Name
                };
                infos.Add(info);
            }
            return(infos);
        }
Esempio n. 21
0
        private Storage CreateStorage(GoodsEntity goods, int limit)
        {
            var storage = new Storage(goods, limit);

            storages.Add(storage);

            return(storage);
        }
Esempio n. 22
0
 public void Modify(GoodsEntity goods)
 {
     if (goods != null)
     {
         goods.OperatorID = CurrentUser.UserID;
     }
     GoodsService.ModifyGoods(goods);
     Response.Redirect("/Goods/Index?" + goods.Url);
 }
Esempio n. 23
0
        /// <summary>
        /// 创建商品
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        protected virtual void CreateGoods(DirectoryInfo directory, CategoryEntity category)
        {
            var files = directory.GetFiles().Where(it => it.Name.ToLower().EndsWith(".xls") || it.Name.ToLower().EndsWith(".xlsx")).ToArray();

            if (files.Length == 0)
            {
                return;
            }
            var goods = new GoodsEntity
            {
                SaveType = SaveType.Add,
                Account  = new AccountEntity {
                    Id = 0
                },
                Name           = directory.Name,
                Category       = category,
                UnusedStatus   = "1",
                IsSales        = false,
                Sequence       = 1,
                OrderMinCount  = 1,
                OrderStepCount = 1,
                DepositRate    = 0,
                IsCustom       = false,
                IsReturn       = true,
                DataId         = "",
                PublishTime    = DateTime.Now,
                Freight        = Freights == null ? null : Freights.FirstOrDefault()
            };
            var zutuDics  = directory.GetDirectories("主图");
            var xiangDics = directory.GetDirectories("详情图");

            FillProducts(files[0], goods, category);
            FillGoodsProperties(files[0], goods, category);
            FillGoodImages(zutuDics.FirstOrDefault(), category, goods, "");
            FillGoodsDetail(xiangDics.FirstOrDefault(), goods, "");
            var rev = goods.Errors != null && goods.Errors.Count > 0 ? false : Ioc.Resolve <IApplicationService, GoodsEntity>().Save(goods);

            if (rev)
            {
                DeleteDirectory(directory.FullName);
                directory.Delete();
            }
            else
            {
                dataGridView1.Rows.Clear();
                var builder = new StringBuilder();
                if (goods.Errors != null)
                {
                    foreach (var error in goods.Errors)
                    {
                        builder.AppendFormat("{0},", error.Message);
                    }
                }
                dataGridView1.Rows.Add(new object[] { directory.FullName, builder.ToString() });
            }
        }
Esempio n. 24
0
        private void AddToGrid()
        {
            if (string.IsNullOrEmpty(txtRetailPrice.Text))
            {
                ShowMessage("零售价不可为空!", ico: MessageBoxIcon.Warning);
                txtRetailPrice.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtInQuantityStock.Text))
            {
                txtInQuantityStock.Focus();
                ShowMessage("入库数量不可为空!");
                return;
            }
            if (cboCategory.EditValue == null)
            {
                cboCategory.Focus();
                ShowMessage("商品类别不可为空!");
                return;
            }
            var         barItem      = cboBarID.SelectedItem as BindUtil.ComboBoxItem;
            var         index        = cboCategory.SelectedIndex;
            var         categoryItem = cboCategory.EditValue as BindUtil.ComboBoxItem;
            GoodsEntity entity       = new GoodsEntity();

            entity.BarID           = barItem == null ? cboBarID.Text : barItem.Value;
            entity.Name            = barItem == null?txtName.Text:barItem.OrginText;
            entity.SPEC            = txtSPEC.Text;
            entity.ModelNumber     = txtModelNumber.Text;
            entity.Category        = categoryItem.Text;
            entity.CategoryID      = categoryItem.Value.ToInt32();
            entity.CodeNumber      = txtCodeNumber.Text;
            entity.BatchNo         = txtBatchNo.Text;
            entity.Supplier        = txtSupplier.Text;
            entity.ProductionDate  = dteProductionDate.EditValue.ToDateTime();
            entity.ProductionPlace = txtProductionPlace.Text;
            entity.BuyingPrice     = txtBuyingPrice.Text.ToDecimal();
            entity.RetailPrice     = txtRetailPrice.Text.ToDecimal();
            entity.InQuantityStock = txtInQuantityStock.Text.ToInt32();
            entity.Remark          = txtRemark.Text;
            entity.InstockAmount   = entity.RetailPrice * entity.InQuantityStock;
            var existsGoods = listGoods.Find(item => item.BarID == entity.BarID);

            if (existsGoods != null)
            {
                existsGoods.InstockAmount   += entity.InstockAmount;
                existsGoods.InQuantityStock += entity.InQuantityStock;
            }
            else
            {
                listGoods.Add(entity);
            }
            txtInQuantityStock.Text = "";
            txtInStockAmount.Text   = "";
            RefreshLoadGrid();
        }
Esempio n. 25
0
 /// <summary>
 /// 更新门店商品库存预警数量
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public static int UpdateGoogsAlarmCount(GoodsEntity entity)
 {
     return(utity.ExecuteNonQuery(CommandType.Text, "update Goods set AlarmAmount=@AlarmAmount where StoreID=@StoreID and BarID=@BarID",
                                  new System.Data.Common.DbParameter[]
     {
         new SqlParameter("@AlarmAmount", entity.AlarmAmount),
         new SqlParameter("@StoreID", entity.StoreID),
         new SqlParameter("@BarID", entity.BarID)
     }));
 }
Esempio n. 26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="GoodsID"></param>
        /// <param name="InventoryID"></param>
        /// <param name="StorageID"></param>
        /// <param name="BatchNumber"></param>
        /// <param name="Quantity"></param>
        public static void ApiInInventoty(int GoodsID, int InventoryID, int StorageID, string BatchNumber, int Quantity, long OperatorID)
        {
            // 商品信息
            GoodsEntity goodsEntity = GoodsService.GetGoodsEntityById(GoodsID);
            // 入库

            List <InventoryInfo> listInv = buildInventoryList(goodsEntity, StorageID, Quantity, BatchNumber, OperatorID);

            InventoryService.InventoryProcess(listInv, "", StorageID, DateTime.Now.ToShortDateString(), OperatorID);
        }
Esempio n. 27
0
        /// <summary>
        /// 更新库存、销量
        /// </summary>
        /// <param name="dbc"></param>
        /// <param name="order"></param>
        private static void UpdateGoodsInfo(MyDbContext dbc, OrderEntity order)
        {
            var orderlists = dbc.GetAll <OrderListEntity>().Where(o => o.OrderId == order.Id).ToList();

            foreach (var orderlist in orderlists)
            {
                GoodsEntity goods = dbc.GetAll <GoodsEntity>().SingleOrDefault(g => g.Id == orderlist.GoodsId);
                goods.Inventory = goods.Inventory - orderlist.Number;
                goods.SaleNum   = goods.SaleNum + orderlist.Number;
            }
        }
Esempio n. 28
0
        public static void Create(string incomingId, GoodsEntity goods, GoodsExtraEntity goodsExtra, int goodsCount, string userId, Database db, DbTransaction trans)
        {
            goods.SerialId = GoodsExtraRepsitory.Create(goodsExtra, db, trans);
            Create(incomingId, goods, userId, db, trans);

            GoodsInventoryRepository.AddOriginalCount(goods.ProductId, goods.HospitalId, goodsCount, db, trans);
            if (!goodsExtra.NeedSplit)
            {
                GoodsInventoryRepository.AddUsableCount(goods.ProductId, goods.HospitalId, goodsCount, db, trans);
            }
        }
Esempio n. 29
0
        public GoodsModel ToModel(GoodsEntity goods)
        {
            var factory        = new GoodsFactory();
            var convertedGoods = factory.GetGoods(goods.Type);

            convertedGoods.Id    = goods.Id;
            convertedGoods.Name  = goods.Name;
            convertedGoods.Price = goods.Price;

            return(convertedGoods);
        }
Esempio n. 30
0
        public static GoodsEntity GetGoodsEntityById(long cid)
        {
            GoodsEntity     result = new GoodsEntity();
            GoodsRepository mr     = new GoodsRepository();
            GoodsInfo       info   = mr.GetGoodsByKey(cid);

            if (info != null)
            {
                result = TranslateGoodsEntity(info);
            }
            return(result);
        }