コード例 #1
0
ファイル: ProductAdd.cs プロジェクト: treesan/taobao-alading
        private void btnSaveAndNew_Click(object sender, EventArgs e)
        {
            WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA);

            waitForm.Show();
            try
            {
                List <StockHouseProduct> shpList = new List <StockHouseProduct>();
                StockItem stockItem = new StockItem();
                List <Alading.Entity.StockProduct> stockProductList = new List <Alading.Entity.StockProduct>();
                List <StockDetail> sdList = new List <StockDetail>();
                if (productAddCtrl1.GetData(waitForm, stockItem, stockProductList, sdList, shpList))
                {
                    StockItemService.AddStockItemProducts(stockItem, stockProductList, sdList, shpList);
                    productAddCtrl1.AllClear();
                    waitForm.Close();
                    XtraMessageBox.Show("保存成功!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    productAddCtrl1.StockHouseFlag  = false;
                    productAddCtrl1.StockLayoutFlag = false;
                }
                else
                {
                    XtraMessageBox.Show("保存失败!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    waitForm.Close();
                    return;
                }
            }
            catch (Exception ex)
            {
                waitForm.Close();
                XtraMessageBox.Show(ex.ToString(), Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
 public StockItemController(AuthenticationService authenticationService, LogService logService, StockItemService stockItemService, EquipmentService equipmentService)
 {
     _authenticationService = authenticationService;
     _logService            = logService;
     _stockItemService      = stockItemService;
     _equipmentService      = equipmentService;
 }
コード例 #3
0
        public async Task AddStockItemAsync_Returns_New_StockItem()
        {
            //Arrange
            var service = new StockItemService(_myRestaurantContext);

            //Act
            var result = await service.AddStockItemAsync(new StockItem
            {
                Name            = "Cream Soda",
                TypeId          = 2,
                UnitOfMeasureId = 3,
                ItemUnit        = 300
            });

            //Assert
            result.Should().BeAssignableTo <StockItem>();
            result.Name.Should().Be("Cream Soda");
            result.UnitOfMeasure.Code.Should().Be("ml");

            //Act
            var stockItems = await service.GetStockItemsAsync();

            //Assert
            stockItems.Should().HaveCount(30);
        }
コード例 #4
0
        public ActionResult CloseTill()
        {
            var conn         = ConfigurationManager.ConnectionStrings[1].ConnectionString;
            var cashierId    = Person.PersonID;
            var allSoldItems = StockItemService.GetSoldItems(cashierId, conn);

            PrintReceipt(allSoldItems);
            StockItemService.CloseTill(cashierId, conn);
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public async Task GetStockItemAsync_Returns_Null()
        {
            //Arrange
            var id      = 10001;
            var service = new StockItemService(_myRestaurantContext);

            //Act
            var result = await service.GetStockItemAsync(d => d.Id == id);

            //Assert
            result.Should().BeNull();
        }
コード例 #6
0
        public async Task GetStockItemsAsync_Returns_StockItems()
        {
            //Arrange
            var service = new StockItemService(_myRestaurantContext);

            //Act
            var result = await service.GetStockItemsAsync();

            //Assert
            result.Should().BeAssignableTo <IEnumerable <StockItem> >();
            result.Should().HaveCount(29);
        }
コード例 #7
0
        public async Task GetStockItemAsync_Returns_StockItem()
        {
            //Arrange
            var id      = 1;
            var service = new StockItemService(_myRestaurantContext);

            //Act
            var result = await service.GetStockItemAsync(d => d.Id == id);

            //Assert
            result.Should().BeAssignableTo <StockItem>();
            result !.Id.Should().Be(id);
            result.Name.Should().Be("Rice");
            result.Type.Type.Should().Be("Grocery");
        }
コード例 #8
0
        public async Task GetStockItemsAsync_Returns_Next_Paged_StockItems()
        {
            //Arrange
            var service = new StockItemService(_myRestaurantContext);

            //Act
            var result = await service.GetStockItemsAsync(d => d.TypeId == 1, 1, 10);

            //Assert
            result.Should().BeAssignableTo <CollectionEnvelop <StockItem> >();
            result.Items.Should().BeAssignableTo <IEnumerable <StockItem> >();
            result.Items.Should().HaveCount(6);
            result.TotalItems.Should().Be(16);
            result.ItemsPerPage.Should().Be(10);
            result.TotalPages().Should().Be(2);
        }
コード例 #9
0
        public async Task DeleteStockItemAsync_Successfully_Deleted()
        {
            //Arrange
            var id      = 1;
            var service = new StockItemService(_myRestaurantContext);

            //Act
            var dbStockItem = await service.GetStockItemAsync(d => d.Id == id);

            await service.DeleteStockItemAsync(dbStockItem !);

            var result = await service.GetStockItemAsync(d => d.Id == id);

            //Assert
            result.Should().BeNull();
        }
コード例 #10
0
        /// <summary>
        /// 点击显示商品属性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gvProductSJ_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            DataRow row = gvProductSJ.GetFocusedDataRow();

            if (row != null && row["OuterID"] != null && row["SkuOuterID"] != null)
            {
                StockItem    stockItem    = StockItemService.GetStockItemByOutId(row["OuterID"].ToString());
                StockProduct stockProduct = StockProductService.GetStockProduct(row["SkuOuterID"].ToString());
                if (stockItem != null && stockProduct != null)
                {
                    View_ShopItem item = new View_ShopItem();
                    item.props          = stockItem.Props;
                    item.input_pids     = stockItem.InputPids;
                    item.input_str      = stockItem.InputStr;
                    item.property_alias = stockProduct.PropsAlias;
                    item.cid            = stockItem.Cid;
                    UIHelper.LoadItemPropValue(item, categoryKeyProps, categorySaleProps, categoryNotKeyProps, categoryInputProps);
                }
            }
        }
コード例 #11
0
        static void Main(string[] args)
        {
            //seed initial data to files on first project build
            DataSeed dataSeed = new DataSeed();

            dataSeed.SeedStockToFile();

            //get data from files
            DataService      dataService = new DataService();
            List <StockItem> stock       = dataService.GetStock();
            List <MenuItem>  menu        = dataService.GetMenu();
            List <OrderItem> orders      = dataService.GetOrders();

            // services initialization
            StockItemService stockService = new StockItemService(stock);
            MenuItemService  menuService  = new MenuItemService(stock, menu);
            OrderItemService orderService = new OrderItemService(stock, menu, orders);

            // uncomment bellow method to use it

            //stockService.CreateStockItem();
            //stockService.UpdateStockItem();
            //stockService.RemoveStockItem();
            stockService.DisplayStockItems();
            //dataService.SaveStock(stock);

            //menuService.CreateMenuItem();
            menuService.DisplayMenuItems();
            //menuService.UpdateMenuItemProducts();
            //menuService.UpdateMenuItemName();
            //dataService.SaveMenu(menu);

            orderService.PlaceNewOrder();
            stockService.DisplayStockItems();
            menuService.DisplayMenuItems();
            orderService.DisplayOrderList();
            dataService.SaveStock(stock);
            dataService.SaveOrders(orders);
        }
コード例 #12
0
ファイル: InOutHelper.cs プロジェクト: treesan/taobao-alading
        /// <summary>
        /// 加载库位和商品属性
        /// </summary>
        /// <param name="repositoryItemComboBoxLayout"></param>
        /// <param name="houseCode"></param>
        /// <param name="skuOuterID"></param>
        /// <param name="outerID"></param>
        /// <param name="categoryRowKeyProps"></param>
        /// <param name="categoryRowSaleProps"></param>
        /// <param name="categoryRowNotKeyProps"></param>
        /// <param name="categoryRowStockProps"></param>
        public void LoadLayoutAndProps(RepositoryItemComboBox repositoryItemComboBoxLayout, GridView gridView
                                       , CategoryRow categoryRowKeyProps, CategoryRow categoryRowSaleProps, CategoryRow categoryRowNotKeyProps, CategoryRow categoryRowStockProps)
        {
            DataRow row = gridView.GetFocusedDataRow();

            if (row == null)
            {
                return;
            }

            string houseCode  = row["HouseCode"] == null ? string.Empty : row["HouseCode"].ToString();
            string outerID    = row["OuterID"] == null ? string.Empty : row["OuterID"].ToString();
            string skuOuterID = row["SkuOuterID"] == null ? string.Empty : row["SkuOuterID"].ToString();

            repositoryItemComboBoxLayout.Items.Clear();
            if (!string.IsNullOrEmpty(houseCode))
            {
                LoadLayout(repositoryItemComboBoxLayout, houseCode);
            }

            /*点击显示商品属性*/
            if (!string.IsNullOrEmpty(outerID) && !string.IsNullOrEmpty(skuOuterID))
            {
                StockItem    stockItem    = StockItemService.GetStockItemByOutId(outerID);
                StockProduct stockProduct = StockProductService.GetStockProduct(skuOuterID);
                if (stockItem != null && stockProduct != null)
                {
                    View_ShopItem item = new View_ShopItem();
                    item.props          = stockItem.Props;
                    item.input_pids     = stockItem.InputPids;
                    item.input_str      = stockItem.InputStr;
                    item.property_alias = stockProduct.PropsAlias;
                    item.cid            = stockItem.Cid;
                    UIHelper.LoadItemPropValue(item, categoryRowKeyProps, categoryRowSaleProps, categoryRowNotKeyProps, categoryRowStockProps);
                }
            }
        }
コード例 #13
0
        public async Task UpdateStockItemAsync_Successfully_Updated()
        {
            //Arrange
            var id      = 1;
            var service = new StockItemService(_myRestaurantContext);

            //Act
            var dbStockItem = await service.GetStockItemAsync(d => d.Id == id);

            dbStockItem !.Name          = "Rice";
            dbStockItem.ItemUnit        = 10;
            dbStockItem.UnitOfMeasureId = 1;
            dbStockItem.Description     = "10kg bag";

            await service.UpdateStockItemAsync(dbStockItem);

            var result = await service.GetStockItemAsync(d => d.Id == id);

            //Assert
            result.Should().BeAssignableTo <StockItem>();
            result !.Id.Should().Be(id);
            result.ItemUnit.Should().Be(10);
            result.Description.Should().Be("10kg bag");
        }
コード例 #14
0
ファイル: InputStock.cs プロジェクト: treesan/taobao-alading
        /// <summary>
        /// 初始化入库,将outer_id相同的商品作为同种商品处理,将成功的商品
        /// 从失败列表failedViewItemList里删除,并更新成功商品的IsAssociate为TRUE
        /// </summary>
        /// <param name="ViewItemlist"></param>
        private void InPutStock(List <ViewShopItemInherit> vItemlist, DoWorkEventArgs e)
        {
            if (vItemlist == null || vItemlist.Count == 0)
            {
                return;
            }
            //存放需要更新和关联的商品iid,outer_id
            Dictionary <string, string> itemOuterIdDic = new Dictionary <string, string>();

            //去除outer_id相同的商品
            List <ViewShopItemInherit> ViewItemlist = vItemlist.Distinct(new ShopItemComparer()).ToList();

            /*查找与数据库重复的商品,将其从入库列表中跳过*/
            List <string> dRepeatedOuterIdList = StockItemService.GetWhereInOuterIds(vItemlist.Select(v => v.outer_id).Distinct().ToList());

            ViewItemlist = ViewItemlist.SkipWhile(v => dRepeatedOuterIdList.Contains(v.outer_id)).ToList();
            /*将跳过入库的商品信息加进itemOuterIdDic中*/
            foreach (string outer_id in dRepeatedOuterIdList)
            {
                //失败列表删除与当前商品outer_id相同的所有商品
                inPutFailedViewItemList.RemoveAll(v => v.outer_id == outer_id);
                //查找所有outer_id下的商品iid并加入iidlist中
                vItemlist.FindAll(v => v.outer_id == outer_id).ForEach(a => itemOuterIdDic.Add(a.iid, a.outer_id));
            }
            if (ViewItemlist.Count > 0)
            {
                //获取cid下的所有属性值
                List <View_ItemPropValue> viewPropValueList = ItemPropValueService.GetView_ItemPropValueList(ViewItemlist.First().cid, "-1", "-1");

                /*销售属性是否有必填项*/
                bool salePropHasMust = false;
                if (viewPropValueList.Where(v => v.is_sale_prop && v.must).ToList().Count > 0)
                {
                    salePropHasMust = true;
                }

                //获取该类目下所有销售属性Id
                List <string> salePidList = viewPropValueList.Where(v => v.is_sale_prop).Select(v => v.pid).Distinct().ToList();

                /*StockInOut*/
                StockInOut stockIntOut = new StockInOut();
                #region 赋值stockInOut
                stockIntOut.AmountTax      = 0;
                stockIntOut.DiscountFee    = 0;
                stockIntOut.DueFee         = 0;
                stockIntOut.FreightCode    = string.Empty;
                stockIntOut.FreightCompany = string.Empty;
                stockIntOut.IncomeTime     = DateTime.Now;
                stockIntOut.InOutCode      = System.Guid.NewGuid().ToString();
                stockIntOut.InOutStatus    = (int)InOutStatus.AllReach;
                stockIntOut.InOutTime      = DateTime.Now;
                stockIntOut.InOutType      = (int)InOutType.InitInput;
                stockIntOut.IsSettled      = true;
                /*操作人*/
                stockIntOut.OperatorCode = string.Empty;
                stockIntOut.OperatorName = string.Empty;
                stockIntOut.PayTerm      = 0;
                stockIntOut.PayThisTime  = 0;
                stockIntOut.PayType      = (int)PayType.OTHER;
                /*模糊查询字段*/
                stockIntOut.SearchText     = string.Empty;
                stockIntOut.TradeOrderCode = string.Empty;
                stockIntOut.TransportCode  = string.Empty;
                #endregion

                //进度报告暂存值
                int temp = 0;
                #region for循环入库
                for (int j = 0; j < ViewItemlist.Count; j++)
                {
                    if (workerInput.CancellationPending)
                    {
                        e.Cancel = true;
                        break;
                    }
                    ViewShopItemInherit viewItem = ViewItemlist[j];

                    StockItem stock = new StockItem();
                    stock.HasSaleProps = !string.IsNullOrEmpty(viewItem.skus);
                    #region 赋值StockItem
                    stock.Name           = viewItem.title;
                    stock.SimpleName     = viewItem.title;
                    stock.OuterID        = viewItem.outer_id;
                    stock.TotalQuantity  = (double)viewItem.TotalQuantity;//总数量,默认值
                    stock.ProductID      = viewItem.product_id;
                    stock.CatName        = viewItem.name ?? string.Empty;
                    stock.Cid            = viewItem.cid ?? string.Empty;
                    stock.Created        = DateTime.Now;
                    stock.InputPids      = viewItem.input_pids ?? string.Empty;
                    stock.InputStr       = viewItem.input_str ?? string.Empty;
                    stock.IsConsignment  = false;
                    stock.KeyProps       = viewItem.KeyProps ?? string.Empty;
                    stock.Modified       = DateTime.Now;
                    stock.NotKeyProps    = viewItem.NotKeyProps ?? string.Empty;
                    stock.PicUrl         = viewItem.pic_url ?? string.Empty;
                    stock.Property_Alias = viewItem.property_alias ?? string.Empty;
                    stock.Props          = viewItem.props ?? string.Empty;
                    stock.SaleProps      = viewItem.StockProps ?? string.Empty;
                    /*库存类目*/
                    stock.StockCatName    = viewItem.StockCatName;
                    stock.StockCid        = viewItem.StockCid;
                    stock.StockItemCode   = System.Guid.NewGuid().ToString();
                    stock.StockItemDesc   = viewItem.desc ?? string.Empty;
                    stock.StockItemImgs   = viewItem.item_imgs ?? string.Empty;
                    stock.StockItemRemark = Constants.INIT_FROM_TOP;
                    stock.StockItemType   = (int)Alading.Core.Enum.StockItemType.FinishGoods;
                    stock.UnitCode        = viewItem.UnitCode; //单位

                    /*空值字段*/
                    stock.SearchText    = string.Empty;
                    stock.Specification = string.Empty;
                    stock.Model         = string.Empty;
                    stock.Tax           = string.Empty;
                    stock.TaxName       = string.Empty;
                    stock.StockProps    = string.Empty;//自定义属性
                    stock.StockCheckUrl = string.Empty;
                    /*辅助字段*/
                    stock.IsSelected = false;
                    #endregion

                    List <StockProduct>      stockProductList      = new List <StockProduct>();
                    List <StockDetail>       stockDetailList       = new List <StockDetail>();
                    List <StockHouseProduct> stockHouseProductList = new List <StockHouseProduct>();
                    int stockTotalQuantity = 0;
                    if (!string.IsNullOrEmpty(viewItem.props))
                    {
                        List <Taobao.Entity.Sku> skuList = new List <Taobao.Entity.Sku>();

                        SortedDictionary <string, List <string> > propValueDic = new SortedDictionary <string, List <string> >();
                        #region  照;分割,同时去掉空白项,每一项是一个pid:vid,值放进字典propValueDic里
                        List <string> propsList = viewItem.props.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                        foreach (string pv in propsList)
                        {
                            string[] pvArr = pv.Split(new Char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                            if (pvArr.Length == 2)
                            {
                                if (!propValueDic.Keys.Contains(pvArr[0]))
                                {
                                    List <string> vidlist = new List <string>();
                                    vidlist.Add(pvArr[1]);
                                    propValueDic.Add(pvArr[0], vidlist);
                                }
                                else
                                {
                                    propValueDic[pvArr[0]].Add(pvArr[1]);
                                }
                            }
                        }
                        #endregion

                        /*销售属性有两个,根据条件组合Sku*/
                        if (salePidList.Count == 2)
                        {
                            //保存有值的销售属性个数
                            int salePropValueCount = 0;
                            //将props里存在值的属性串的pid放进列表itemPidlist
                            List <string> itemPidList = propValueDic.Keys.ToList();
                            //求itemPidList与salePropIdList的交集,结果的个数表示销售属性选择的个数
                            salePropValueCount = itemPidList.Intersect(salePidList).ToList().Count;

                            #region 如果销售属性包含必选项但填写项数不为2,或者不包含必选项但选择项个数为1时,组合SKU
                            //用于存放两组vid列表
                            SortedList <string, List <string> > saleValueList = new SortedList <string, List <string> >();
                            if ((salePropHasMust && salePropValueCount != 2) || !salePropHasMust && salePropValueCount == 1)
                            {
                                #region 查询属性值放进saleValueList
                                for (int i = 0; i < 2; i++)
                                {
                                    string pid = salePidList[i];
                                    /*如果商该品选择了此销售属性,则把其值加进字典里*/
                                    if (propValueDic.Keys.Contains(pid))
                                    {
                                        saleValueList.Add(pid, propValueDic[pid]);
                                    }
                                    /*该商品没有选则此销售属性,则把此属性下的所有属性值加进字典*/
                                    else
                                    {
                                        List <string> vidlist = new List <string>();
                                        viewPropValueList.Where(v => v.is_sale_prop && v.pid == pid).Select(v => v.vid).Distinct().ToList().ForEach(a => vidlist.Add(a));
                                        saleValueList.Add(pid, vidlist);
                                    }
                                }
                                #endregion

                                #region 组合Sku,加进skuList
                                if (saleValueList.Count == 2)
                                {
                                    foreach (string vid0 in saleValueList.Values[0])
                                    {
                                        foreach (string vid1 in saleValueList.Values[1])
                                        {
                                            Taobao.Entity.Sku sku = new Taobao.Entity.Sku();
                                            sku.SkuProps = string.Format("{0}:{1};{2}:{3}", saleValueList.Keys[0], vid0, saleValueList.Keys[1], vid1);
                                            sku.Quantity = 0;
                                            sku.Price    = "0";
                                            /*sku.OuterId在这里不编码,最后统一编码*/
                                            skuList.Add(sku);
                                        }
                                    }
                                }
                                #endregion
                            }
                            #endregion
                        }

                        Alading.Taobao.Entity.Extend.Skus skus = JsonConvert.DeserializeObject <Alading.Taobao.Entity.Extend.Skus>(viewItem.skus);
                        if (skus != null && skus.Sku != null)
                        {
                            skuList.AddRange(skus.Sku);
                        }
                        if (skuList.Count == 0)
                        {
                            Taobao.Entity.Sku sku = new Taobao.Entity.Sku();
                            sku.SkuProps = string.Empty;
                            sku.Price    = viewItem.price;
                            sku.Quantity = (int)stock.TotalQuantity;
                            /*sku.OuterId在这里不编码,最后统一编码*/
                            skuList.Add(sku);
                        }
                        //根据SkuProps去重
                        skuList = skuList.Distinct(new SkuComparer()).ToList();
                        for (int i = 0; i < skuList.Count; i++)
                        {
                            Alading.Taobao.Entity.Sku sku = skuList[i];
                            StockProduct product          = new StockProduct();
                            #region 赋值StockProduct
                            product.LastStockPrice   = product.AvgStockPrice = 0;
                            product.CommissionPrice  = 0;
                            product.MaxSkuPrice      = 0;
                            product.MinSkuPrice      = 0;
                            product.OccupiedQuantity = 0;
                            product.OuterID          = stock.OuterID;
                            product.SkuQuantity      = sku.Quantity;
                            //重新计算库存总量
                            stockTotalQuantity += sku.Quantity;

                            product.SkuPrice = product.MarketPrice = sku.Price == null ? 0 : double.Parse(sku.Price);
                            //由于sku.OuterId是不允许编辑的,所有系统编码不会有重复
                            product.SkuOuterID = string.Format("{0}-{1}", product.OuterID, i + 1);
                            product.SkuProps   = sku.SkuProps;
                            //分割属性查找
                            #region 翻译销售属性组合
                            List <string> skuPropsList = product.SkuProps.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                            string        propstr      = string.Empty;
                            //每个PV值都为pid:vid格式
                            foreach (string pv in skuPropsList)
                            {
                                string[] pvArr = pv.Split(new Char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                                if (pvArr.Length == 2)
                                {
                                    View_ItemPropValue viewProp = viewPropValueList.SingleOrDefault(vv => vv.pid == pvArr[0] && vv.vid == pvArr[1]);
                                    if (viewProp != null)
                                    {
                                        //重新命名销售属性,如:1627207:28341:黑色;1627207:3232481:棕色
                                        if (!string.IsNullOrEmpty(viewItem.property_alias) && viewItem.property_alias.Contains(pv))
                                        {
                                            List <string> propertyAliasList = viewItem.property_alias.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                                            foreach (string propertyAlias in propertyAliasList)
                                            {
                                                if (propertyAlias.Contains(pv))
                                                {
                                                    propstr += string.Format("{0}:{1};", viewProp.prop_name, propertyAlias.Substring(propertyAlias.LastIndexOf(':') + 1));
                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            propstr += string.Format("{0}:{1};", viewProp.prop_name, viewProp.name_alias);
                                        }
                                    }
                                }
                            }
                            propstr = propstr.TrimEnd(';');
                            if (string.IsNullOrEmpty(propstr))
                            {
                                product.SkuProps_Str = string.Empty;
                            }
                            else
                            {
                                /*重新分割,按默认排序进行排序*/
                                skuPropsList = propstr.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                                skuPropsList.Sort();
                                foreach (string property in skuPropsList)
                                {
                                    product.SkuProps_Str += string.Format("{0};", property);
                                }
                                product.SkuProps_Str = product.SkuProps_Str.TrimEnd(';');
                            }
                            #endregion

                            product.ProductStatus      = 0;//
                            product.HighestNum         = 0;
                            product.IsUsingWarn        = false;
                            product.LowestNum          = 0;
                            product.PropsAlias         = string.Empty;
                            product.StockProductRemark = Constants.INIT_FROM_TOP;
                            product.WarningCount       = 0;
                            product.WholeSalePrice     = 0;
                            product.ProductTimeStamp   = new byte[] { };
                            #endregion
                            /*加入product列表*/
                            stockProductList.Add(product);

                            StockDetail stockDetail = new StockDetail();
                            #region 赋值StockDetail
                            stockDetail.DetailRemark   = string.Empty;
                            stockDetail.DetailType     = (int)DetailType.InitInput;
                            stockDetail.DurabilityDate = DateTime.Now;
                            /*仓库名称*/
                            stockDetail.HouseName       = viewItem.StockHouseName;
                            stockDetail.LayoutName      = viewItem.StockLayoutName;
                            stockDetail.StockHouseCode  = viewItem.StockHouseCode;
                            stockDetail.StockLayOutCode = viewItem.StockLayoutCode;

                            stockDetail.InOutCode         = stockIntOut.InOutCode;
                            stockDetail.Price             = float.Parse(product.SkuPrice.ToString());
                            stockDetail.ProductSkuOuterId = product.SkuOuterID;
                            stockDetail.Quantity          = product.SkuQuantity;
                            /*搜索字段*/
                            stockDetail.SearchText      = string.Empty;
                            stockDetail.StockDetailCode = System.Guid.NewGuid().ToString();
                            stockDetail.Tax             = string.Empty;
                            stockDetail.TotalFee        = float.Parse((product.SkuPrice * stockDetail.Quantity).ToString());
                            #endregion
                            /*加入stockDetail列表*/
                            stockDetailList.Add(stockDetail);

                            StockHouseProduct houseProduct = new StockHouseProduct();
                            #region 赋值StockHouseProduct
                            houseProduct.HouseCode        = viewItem.StockHouseCode;
                            houseProduct.HouseName        = viewItem.StockHouseName;
                            houseProduct.HouseProductCode = System.Guid.NewGuid().ToString();
                            houseProduct.LayoutCode       = viewItem.StockLayoutCode;
                            houseProduct.LayoutName       = viewItem.StockLayoutName;
                            houseProduct.Num        = product.SkuQuantity;
                            houseProduct.SkuOuterID = product.SkuOuterID;
                            #endregion
                            stockHouseProductList.Add(houseProduct);
                        }
                    }
                    //库存总量重新赋值
                    stock.TotalQuantity = stockTotalQuantity;
                    if (StockItemService.InitInput(stock, stockProductList, stockDetailList, stockHouseProductList) == ReturnType.Success)
                    {
                        StockInOutService.AddStockInOut(stockIntOut);
                        //成功一个,失败列表删除与当前商品outer_id相同的所有商品
                        inPutFailedViewItemList.RemoveAll(v => v.outer_id == viewItem.outer_id);
                        //查找所有outer_id下的商品iid并加入iidlist中
                        vItemlist.FindAll(v => v.outer_id == viewItem.outer_id).ForEach(a => itemOuterIdDic.Add(a.iid, a.outer_id));
                    }
                    //进度报告
                    if (workerInput != null)
                    {
                        int propgress = (int)((float)(j + 1) / ViewItemlist.Count * 100);
                        if (propgress > temp)
                        {
                            workerInput.ReportProgress(propgress, null);
                        }
                        temp = propgress;
                    }
                } //for
                #endregion
            }     // if (ViewItemlist.Count>0)

            /*更新入库成功商品的Outer_id及IsAssociate*/
            if (itemOuterIdDic.Count > 0)
            {
                ItemService.UpdateItemsOuterId(itemOuterIdDic, true);
            }
        }
コード例 #15
0
        public ActionResult CheckIn(string suspend)
        {
            if (!string.IsNullOrEmpty(suspend))
            {
                return(new JsonResult());
            }

            int count       = 0;
            int guestId     = 0;
            int guestRoomId = 0;

            int paymentMethodId = 1;

            int.TryParse(Request.Form["rpaidby"], out paymentMethodId);

            var rpaidby = Request.Form["rpaidby"].ToString();

            paymentMethodId = GetPaymentMethod(rpaidby.ToUpper());


            var cc_no_val     = Request.Form["cc_no_val"].ToString();
            var cc_holder_val = Request.Form["cc_holder_val"].ToString();
            var cheque_no_val = Request.Form["cheque_no_val"].ToString();

            var paymentMethodNote = cc_no_val + " " + cc_holder_val + " " + cheque_no_val;

            int.TryParse(Request.Form["count"], out count);
            int.TryParse(Request.Form["HotelGuestId"], out guestId);
            int.TryParse(Request.Form["GuestRoomId"], out guestRoomId);

            List <POSService.Entities.StockItem> lst = new List <POSService.Entities.StockItem>();

            if (paymentMethodId == (int)PaymentMethodEnum.POSTBILL && guestId == 0)
            {
                return(Content(@"<script language='javascript' type='text/javascript'>
                alert('You cannot post a bill for a customer who is not staying in the hotel! Please go back and select a guest!');
                $(this).location = 'POS/Index';
                </script>"));
            }

            var totalBill = Decimal.Zero;

            for (int i = 1; i < count; i++)
            {
                string p  = "product" + i.ToString();
                string q  = "quantity" + i.ToString();
                string pr = "price" + i.ToString();

                int     productId = 0;
                int     qty       = 0;
                decimal price     = decimal.Zero;

                int.TryParse(Request.Form[p], out productId);
                int.TryParse(Request.Form[q], out qty);
                decimal.TryParse(Request.Form[pr], out price);

                if (productId == 0)
                {
                    break;
                }

                totalBill += (price * qty);

                var itemDescription = ProductsList.FirstOrDefault(x => x.Id == productId).StockItemName;

                lst.Add(new POSService.Entities.StockItem {
                    Id = productId, Quantity = qty, UnitPrice = price, Description = itemDescription
                });
            }

            //Save Item To Database

            var conn = ConfigurationManager.ConnectionStrings[1].ConnectionString;

            var ticks = (int)DateTime.Now.Ticks;

            var transactionId = _personService.GetAllForLogin().FirstOrDefault(x => x.Username.ToUpper().Equals(User.Identity.Name.ToUpper())).PersonID;

            var cl = HttpContext.GetCourseListCookie("FrontOfficeTerminal");

            var terminal = "Terminal";

            if (!string.IsNullOrEmpty(cl.FirstOrDefault()))
            {
                terminal = cl.FirstOrDefault();
            }

            int terminalId = GetFrontOfficeTerminalId(terminal);

            var timeOfSale = DateTime.Now;

            //if (guestId > 0)
            StockItemService.UpdateSalesHouseKeeping(lst, transactionId, guestId, Person.PersonID, 1, guestRoomId, conn, paymentMethodId, paymentMethodNote, timeOfSale, DistributionPointId, terminalId);

            double dTotal = 0;

            double.TryParse(totalBill.ToString(), out dTotal);

            try
            {
                PrintReceipt(lst, dTotal, 0, 0);
            }
            catch
            {
            }

            return(RedirectToAction("Index"));
        }