예제 #1
0
        /// <summary>
        /// 显示生产单
        /// </summary>
        /// <param name="page"></param>
        public void ShowBill(GridControl gridCtrl, GridView gridView, int inoutType, int page, int rowCount)
        {
            List <View_InOutDetailProduct> viewInOutBillList = StockInOutService.GetViewInOutDetailProduct(c => c.InOutType == inoutType, page, 40, out rowCount);

            gridCtrl.DataSource = viewInOutBillList;
            gridView.BestFitColumns();
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            List <StockHouseProduct>     shpList  = new List <StockHouseProduct>();
            List <View_StockItemProduct> vsipList = new List <View_StockItemProduct>();
            PayCharge payCharge = new PayCharge();

            try
            {
                if (purchaseIn1.GetData(stockInOut, payCharge, sdList, shpList, vsipList))
                {
                    StockInOutService.AddInOutAndDetails(stockInOut, payCharge, sdList, shpList, vsipList);
                    this.Close();
                }
                else
                {
                    stockInOut = new Alading.Entity.StockInOut();
                    sdList     = new List <StockDetail>();
                    return;
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }
예제 #3
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bbtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (gridViewStockInOut.RowCount > 0)
     {
         DialogResult   result   = XtraMessageBox.Show("您确定删除该记录?删除后将无法恢复!", "确定删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA);
         waitForm.Show();
         try
         {
             if (result == DialogResult.OK)
             {
                 productTable.Rows.Clear();
                 DataRow row = gridViewStockInOut.GetFocusedDataRow();
                 StockInOutService.RemoveInOutAndDetails(row[gcInOutCode.FieldName].ToString());
                 allVidpList.Remove(allVidpList.FirstOrDefault(c => c.Key == row[gcInOutCode.FieldName].ToString()));
                 currentVidpList.Remove(currentVidpList.FirstOrDefault(c => c.Key == row[gcInOutCode.FieldName].ToString()));
                 GetIntOutTableDataSource(GetDisplayGroup());
                 SetPageBtnEnable();
                 RowClick();
             }
             waitForm.Close();
         }
         catch (Exception ex)
         {
             waitForm.Close();
             XtraMessageBox.Show(ex.ToString(), Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
예제 #4
0
        private void SearchAllocation(DateTime start)
        {
            int rowHandle = gvAllocation.FocusedRowHandle;
            List <Alading.Entity.StockInOut> stockInOutList = StockInOutService.GetStockInOut(i => i.InOutType == (int)InOutType.AllocateIn);

            gridAllocation.DataSource = stockInOutList.Where(i => i.InOutTime >= start).ToList();

            if (rowHandle == 0 && gvAllocation.FocusedRowHandle > -1)
            {
                FocusedRowChange();
            }
        }
예제 #5
0
        /// <summary>
        /// 初始化、刷新
        /// </summary>
        private void Init()
        {
            int rowHandle = gvAllocation.FocusedRowHandle;
            List <Alading.Entity.StockInOut> stockInOutList = StockInOutService.GetStockInOut(i => i.InOutType == (int)InOutType.AllocateIn);

            gridAllocation.DataSource = stockInOutList;
            if (rowHandle == 0 && gvAllocation.FocusedRowHandle > -1)
            {
                FocusedRowChange();
            }
            //gvAllocation.FocusedRowChanged += gvAllocation_FocusedRowChanged;
            //}
        }
예제 #6
0
 public bool ExistInOutCode(string inOutCode)
 {
     Alading.Entity.StockInOut stockInOut = StockInOutService.GetStockInOut(inOutCode);
     if (stockInOut != null)
     {
         //存在
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #7
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void barBtnRemove_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     Alading.Entity.StockInOut stockInOut = gvAllocation.GetFocusedRow() as Alading.Entity.StockInOut;
     if (stockInOut != null)
     {
         if (XtraMessageBox.Show(string.Format("是否删除编号为\n{0}\n的调拨单?", stockInOut.InOutCode), "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             if (StockInOutService.RemoveStockInOutDetail(stockInOut.InOutCode) == ReturnType.Success)
             {
                 XtraMessageBox.Show("删除成功");
                 Init();//刷新
             }
         }
     }
 }
예제 #8
0
 /// <summary>
 /// 保存并新增
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void simpleBtnSaveAdd_Click(object sender, EventArgs e)
 {
     try
     {
         SortedList <List <Alading.Entity.StockInOut>, List <StockDetail> > stockDetail = GetStockInOutDetail();
         if (stockDetail != null && stockDetail.Count > 0)
         {
             StockInOutService.AddStockInOutDetail(stockDetail.Keys[0], stockDetail.Values[0]);
         }
         dTable.Rows.Clear();
         ComponentInit();
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message, Constants.SYSTEM_PROMPT);
     }
 }
예제 #9
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleBtnSearch_Click(object sender, EventArgs e)
        {
            int rowHandle = gvAllocation.FocusedRowHandle;

            if (textKeyWord.Text == string.Empty)
            {
                XtraMessageBox.Show("请输入关键词", Constants.SYSTEM_PROMPT);
                return;
            }

            List <Alading.Entity.StockInOut> stockInOutList = StockInOutService.GetStockInOut(i => i.InOutType == (int)InOutType.AllocateIn);

            gridAllocation.DataSource = stockInOutList.Where(i => i.InOutCode.Contains(textKeyWord.Text) || i.InOutTime.ToString().Contains(textKeyWord.Text) || i.OperatorName.Contains(textKeyWord.Text)).ToList();
            if (rowHandle == 0 && gvAllocation.FocusedRowHandle > -1)
            {
                FocusedRowChange();
            }
        }
예제 #10
0
 public StockInOut()
 {
     InitializeComponent();
     allVidpList = StockInOutService.GetAllView_InOutDetailProducts().GroupBy(c => c.InOutCode).ToList();
     AddInOutTableColumns();
     AddProductTableColumns();
     gridCtrlStockInOut.DataSource = inOutTable;
     gridCtrlStockItem.DataSource  = productTable;
     currentVidpList = allVidpList;
     GetIntOutTableDataSource(GetDisplayGroup());
     GetAllIndex();
     SetPageBtnEnable();
     AddTreeListNodes();
     foreach (TreeListNode node in tcInOutType.Nodes)
     {
         node.Expanded = true;
     }
     RowClick();
 }
예제 #11
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleBtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SortedList <List <Alading.Entity.StockInOut>, List <StockDetail> > stockDetail = GetStockInOutDetail();
                if (stockDetail != null && stockDetail.Count > 0)
                {
                    //新增
                    if (IsAddFlag == true)
                    {
                        ReturnType type = StockInOutService.AddStockInOutDetail(stockDetail.Keys[0], stockDetail.Values[0]);
                        if (type == ReturnType.Success)
                        {
                            XtraMessageBox.Show("保存成功", Constants.SYSTEM_PROMPT);
                            this.Close();
                        }
                        else if (type == ReturnType.PropertyExisted)
                        {
                            XtraMessageBox.Show("调拨单编号重复,请重输", Constants.SYSTEM_PROMPT);
                        }
                        else
                        {
                            XtraMessageBox.Show("保存失败", Constants.SYSTEM_PROMPT);
                        }
                    }
                    //else
                    //{
                    //    //修改

                    //    XtraMessageBox.Show("还没写好怎么更新", Constants.SYSTEM_PROMPT);

                    //}
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, Constants.SYSTEM_PROMPT);
            }
        }
예제 #12
0
        /// <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);
            }
        }
예제 #13
0
        /// <summary>
        /// 焦点行改变触发展示调拨详情
        /// </summary>
        private void FocusedRowChange()
        {
            Alading.Entity.StockInOut stockInOut = gvAllocation.GetFocusedRow() as Alading.Entity.StockInOut;
            if (stockInOut == null)
            {
                gridStockProduct.DataSource = null;
            }
            else
            {
                List <View_StockDetailInOut> detailList = StockInOutService.GetStockDetailInOut(i => i.InOutCode == stockInOut.InOutCode);
                DataTable dTable = new DataTable();
                dTable.Columns.Add("Name");
                dTable.Columns.Add("OuterID");
                dTable.Columns.Add("Specification");
                dTable.Columns.Add("Model");
                dTable.Columns.Add("SaleProps");

                dTable.Columns.Add("SkuOuterID");
                dTable.Columns.Add("SkuQuantity");
                //dTable.Columns.Add("StockHouseCodeOut");
                //dTable.Columns.Add("StockHouseCodeIn");
                dTable.Columns.Add("LayoutCodeIn");

                dTable.Columns.Add("LayoutCodeOut");
                //dTable.Columns.Add("HouseNameIn");
                dTable.Columns.Add("LayoutNameIn");
                //dTable.Columns.Add("HouseNameOut");
                dTable.Columns.Add("LayoutNameOut");

                //List<string> inOutCodeList = new List<string>();
                //var q = from i in detailList
                //        select i.InOutCode;
                //inOutCodeList = q.Distinct().ToList();
                //if (inOutCodeList == null || inOutCodeList.Count == 0)
                //    return;

                //foreach (string inOutCode in inOutCodeList)
                //{

                List <View_StockDetailInOut> stockOutList = detailList.Where(i => i.InOutCode == stockInOut.InOutCode && i.DetailType == (int)DetailType.AllocateOut).ToList();
                List <View_StockDetailInOut> stockInList  = detailList.Where(i => i.InOutCode == stockInOut.InOutCode && i.DetailType == (int)DetailType.AllocateIn).ToList();

                if (stockOutList != null && stockInList != null && stockOutList.Count() > 0 && stockOutList.Count() == stockInList.Count())
                {
                    for (int i = 0; i < stockOutList.Count(); i++)
                    {
                        View_StockDetailInOut stockOut = stockOutList[i];
                        View_StockDetailInOut stockIn  = stockInList[i];

                        DataRow dRow = dTable.NewRow();
                        if (stockIn != null)
                        {
                            dRow["Name"]          = stockIn.Name;
                            dRow["OuterID"]       = stockIn.OuterID;
                            dRow["Specification"] = stockIn.Specification;
                            dRow["Model"]         = stockIn.Model;
                            dRow["SaleProps"]     = stockIn.SkuProps_Str;
                            //dRow["HouseNameIn"] = stockIn.HouseName;
                            dRow["LayoutNameIn"] = stockIn.LayoutName;
                            //dRow["StockHouseCodeIn"] = stockIn.StockHouseCode;
                            dRow["LayoutCodeIn"] = stockIn.StockLayOutCode;
                        }
                        if (stockOut != null)
                        {
                            dRow["SkuOuterID"]  = stockOut.ProductSkuOuterId;
                            dRow["SkuQuantity"] = stockOut.Quantity;
                            //dRow["StockHouseCodeOut"] = stockOut.StockHouseCode;
                            dRow["LayoutCodeOut"] = stockOut.StockLayOutCode;
                            //dRow["HouseNameOut"] = stockOut.HouseName;
                            dRow["LayoutNameOut"] = stockOut.LayoutName;
                        }
                        dTable.Rows.Add(dRow);
                        //}
                    }
                }

                gridStockProduct.DataSource = dTable;
                gVStockProduct.BestFitColumns();
            }
        }
예제 #14
0
        /// <summary>
        /// 同外界交互的接口,生成入库单及明细
        /// </summary>
        public bool GetData(Alading.Entity.StockInOut stockInOut, PayCharge payCharge, List <StockDetail> sdList, List <StockHouseProduct> shpList, List <View_StockItemProduct> vsipList)
        {
            #region 验证
            /*验证是否选择了商品*/
            if (gvProductSJ.RowCount == 0)
            {
                XtraMessageBox.Show("请先选择一个商品!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (!IsAllNecessaryInput())
            {
                XtraMessageBox.Show("请填写完整的入库单详情!(带*的为必填。)", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (!IsAllNecessaryCellInput())
            {
                XtraMessageBox.Show("请将列表中的仓库、库位、数量及价格信息输入完整!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            string inoutCode = textEditInOutCode.Text.Trim();
            if (StockInOutService.GetAllStockInOut().FirstOrDefault(c => c.InOutCode == inoutCode) != null)
            {
                XtraMessageBox.Show("入库单编码与数据库中已有入库单编码重复,请重输!", Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            #endregion

            #region StockInOut
            stockInOut.AmountTax   = !string.IsNullOrEmpty(textEditAmountTax.Text)? float.Parse(textEditAmountTax.Text):0;
            stockInOut.DiscountFee = !string.IsNullOrEmpty(textEditDiscountFee.Text)?float.Parse(textEditDiscountFee.Text):0;
            stockInOut.DueFee      = !string.IsNullOrEmpty(textEditTotalFee.Text)?float.Parse(textEditTotalFee.Text):0;
            stockInOut.FreightCode = pceFreightCompany.Tag != null?pceFreightCompany.Tag.ToString() : string.Empty;

            stockInOut.FreightCompany = pceFreightCompany.Text != null?pceFreightCompany.Text:string.Empty;
            stockInOut.IncomeTime     = dateEditIncomeTime.DateTime;
            stockInOut.InOutCode      = textEditInOutCode.Text;
            stockInOut.InOutStatus    = (int)Alading.Core.Enum.InOutStatus.AllReach;
            stockInOut.InOutTime      = DateTime.Now;
            stockInOut.InOutType      = (int)InOutType.PurchaseIn;
            /*权宜之计*/
            //stockInOut.货运单号
            stockInOut.OperatorCode = pceOperator.Tag != null?pceOperator.Tag.ToString() : string.Empty;

            stockInOut.OperatorName   = pceOperator.Text != null?pceOperator.Text:string.Empty;
            stockInOut.PayTerm        = 0;
            stockInOut.PayThisTime    = !string.IsNullOrEmpty(textEditPayThisTime.Text)?float.Parse(textEditPayThisTime.Text):0;
            stockInOut.PayType        = comboPayType.SelectedIndex + 1;
            stockInOut.TradeOrderCode = string.Empty;//
            stockInOut.IsSettled      = stockInOut.PayThisTime >= stockInOut.DueFee;

            #endregion

            #region 付款信息

            payCharge.AmountTax       = !string.IsNullOrEmpty(textEditAmountTax.Text) ? float.Parse(textEditAmountTax.Text) : 0;
            payCharge.ChargerCode     = string.Empty; /*付款编号*/
            payCharge.ChargerName     = string.Empty; //
            payCharge.DiscountFee     = !string.IsNullOrEmpty(textEditDiscountFee.Text) ? float.Parse(textEditDiscountFee.Text) : 0;
            payCharge.InOutCode       = stockInOut.InOutCode;
            payCharge.NeedToPay       = !string.IsNullOrEmpty(textEditNeedToPay.Text) ? float.Parse(textEditNeedToPay.Text) : 0;
            payCharge.OperateTime     = DateTime.Now;
            payCharge.OperatorCode    = string.Empty; //
            payCharge.OperatorName    = string.Empty; //
            payCharge.PayChargeCode   = string.Empty; //
            payCharge.PayChargeRemark = string.Empty;
            payCharge.PayChargeType   = comboPayType.SelectedIndex;
            payCharge.PayerCode       = string.Empty;
            payCharge.PayerName       = string.Empty;
            payCharge.PayThisTime     = !string.IsNullOrEmpty(textEditPayThisTime.Text) ? float.Parse(textEditPayThisTime.Text) : 0;
            payCharge.TotalFee        = !string.IsNullOrEmpty(textEditTotalFee.Text) ? float.Parse(textEditTotalFee.Text) : 0;
            payCharge.IncomeDay       = !string.IsNullOrEmpty(textEditPayTerm.Text) ? int.Parse(textEditPayTerm.Text) : 0;
            payCharge.IncomeTime      = dateEditIncomeTime.DateTime;

            #endregion

            #region StockHouseProduct,View_StockItemProduct,StockDetail

            int count = gvProductSJ.RowCount;

            /*找到商品在仓库中的位置,并更新该仓库中商品的数量*/
            List <StockHouseProduct> allShpList = StockHouseService.GetAllStockHouseProduct();
            //IEnumerable<View_StockItemProduct> allVispList = View_StockItemProductService.GetAllView_StockItemProduct();
            for (int i = 0; i < count; i++)
            {
                DataRow row = gvProductSJ.GetDataRow(i);
                //总金额
                double totalMoney = row["TotalMoney"] != null?double.Parse(row["TotalMoney"].ToString()) : 0;

                //入库数量
                int num = row["TotalCount"] != null?int.Parse(row["TotalCount"].ToString()) : 0;

                /*仓库名称*/
                string houseName = row[gcStockHouse.FieldName].ToString();
                /*库位名称*/
                string layoutName = row[gcStockLayout.FieldName].ToString();
                //最新进价
                double LastStockPrice = totalMoney / num;
                /*修改仓库商品表数量增加*/
                StockHouseProduct shp = allShpList.FirstOrDefault(c => c.HouseCode == row["StockHouseCode"].ToString() && c.SkuOuterID == row["SkuOuterID"].ToString() && c.LayoutCode == row["StockLayoutCode"].ToString());
                if (shp != null)
                {
                    shp.Num += num;
                    shpList.Add(shp);
                }
                else
                {
                    shp                  = new StockHouseProduct();
                    shp.HouseCode        = row["StockHouseCode"].ToString();
                    shp.HouseProductCode = System.Guid.NewGuid().ToString();
                    shp.LayoutCode       = row["StockLayoutCode"].ToString();
                    shp.Num              = num;
                    shp.HouseName        = houseName;
                    shp.LayoutName       = layoutName;
                    shp.SkuOuterID       = row["SkuOuterID"].ToString();
                    shpList.Add(shp);
                }
                View_StockItemProduct vsip = View_StockItemProductService.GetView_StockItemProductBySkuOuterId(row["SkuOuterID"].ToString());
                if (vsip != null)
                {
                    //视图无法直接修改其属性值,所以需要new一个然后给之赋值
                    View_StockItemProduct tempVsip = new View_StockItemProduct();
                    tempVsip.SkuOuterID = vsip.SkuOuterID;
                    tempVsip.OuterID    = vsip.OuterID;

                    tempVsip.LastStockPrice = LastStockPrice;
                    int lastNum = vsip.SkuQuantity;
                    tempVsip.TotalQuantity = vsip.TotalQuantity + num;
                    tempVsip.SkuQuantity   = vsip.SkuQuantity + num;
                    //平均价格=(上次剩余商品的平均价格*上次剩余数量+本次总金额)/本次剩余数量
                    tempVsip.AvgStockPrice = (vsip.AvgStockPrice * lastNum + totalMoney) / vsip.SkuQuantity;
                    vsipList.Add(tempVsip);
                }
                /*价格问题该如何处理???*/

                StockDetail sd = new StockDetail();
                sd.DetailRemark      = string.Empty;
                sd.DetailType        = (int)Alading.Core.Enum.DetailType.PurchaseIn;
                sd.DurabilityDate    = DateTime.MinValue;//有效期?
                sd.InOutCode         = stockInOut.InOutCode;
                sd.HouseName         = houseName;
                sd.LayoutName        = layoutName;
                sd.Price             = float.Parse((totalMoney / num).ToString());
                sd.Quantity          = num;
                sd.StockDetailCode   = System.Guid.NewGuid().ToString();
                sd.ProductSkuOuterId = row["SkuOuterId"].ToString();
                sd.StockHouseCode    = row["StockHouseCode"].ToString();
                sd.StockLayOutCode   = row["StockLayOutCode"].ToString();
                sd.Tax      = string.Empty;//税额??
                sd.TotalFee = float.Parse(totalMoney.ToString());
                sdList.Add(sd);
            }

            #endregion

            return(true);
        }