Ejemplo n.º 1
0
        /// <summary>
        /// 仓库删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barDeleteHouse_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeListStockHouse.FocusedNode == null)
            {
                return;
            }

            if (stockHouseCode == Constants.DEFAULT_STOCKHOUSE_CODE)
            {
                XtraMessageBox.Show("系统默认仓库,不能删除", Constants.SYSTEM_PROMPT);
                return;
            }

            /*仓库中如果有商品则不能删除*/
            if (XtraMessageBox.Show(string.Format("是否删除仓库\n{0}", textHouseName.Text), Constants.SYSTEM_PROMPT, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                List <StockHouseProduct> productList = StockHouseService.GetStockHouseProduct(i => i.HouseCode == stockHouseCode);
                if (productList == null || productList.Count == 0)
                {
                    if (StockHouseService.RemoveStockHouse(stockHouseCode) == ReturnType.Success)
                    {
                        XtraMessageBox.Show("仓库删除成功", Constants.SYSTEM_PROMPT);
                        Init();
                    }
                    else
                    {
                        XtraMessageBox.Show("仓库删除失败", Constants.SYSTEM_PROMPT);
                    }
                }
                else
                {
                    XtraMessageBox.Show("该仓库有商品,不能删除", Constants.SYSTEM_PROMPT);
                }
            }
        }
Ejemplo n.º 2
0
 private void ModifyLayout_Load(object sender, EventArgs e)
 {
     if (modifyFlag == true)
     {
         comboBoxHouse.Properties.ReadOnly = true;
     }
     else
     {
         //加载仓库
         List <Alading.Entity.StockHouse> houseList = StockHouseService.GetAllStockHouse();
         if (houseList != null && houseList.Count > 0)
         {
             string tag = string.Empty;
             foreach (Alading.Entity.StockHouse house in houseList)
             {
                 if (string.IsNullOrEmpty(house.HouseName))
                 {
                     continue;
                 }
                 comboBoxHouse.Properties.Items.Add(house.HouseName);
                 tag += house.StockHouseCode + ",";
             }
             comboBoxHouse.Tag = tag.Trim(',');
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 库位删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void barDeleteLayout_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     /*库位中如果有商品则不能删除*/
     Alading.Entity.StockLayout layout = gViewStockLayout.GetFocusedRow() as Alading.Entity.StockLayout;
     if (layout != null)
     {
         if (layout.StockLayoutCode == Constants.DEFAULT_STOCKLAYOUT_CODE || layout.LayoutName == "默认库位")
         {
             XtraMessageBox.Show("系统默认库位,不能删除", Constants.SYSTEM_PROMPT);
             return;
         }
         if (XtraMessageBox.Show(string.Format("是否删除库位\n{0}", layout.LayoutName), Constants.SYSTEM_PROMPT, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             List <StockHouseProduct> productList = StockHouseService.GetStockHouseProduct(i => i.LayoutCode == layout.StockLayoutCode);
             if (productList == null || productList.Count == 0)
             {
                 if (StockLayoutService.RemoveStockLayout(layout.StockLayoutCode) == ReturnType.Success)
                 {
                     XtraMessageBox.Show("库位删除成功", Constants.SYSTEM_PROMPT);
                     //重新加载库位
                     LoadLayout(stockHouseCode);
                 }
                 else
                 {
                     XtraMessageBox.Show("库位删除失败", Constants.SYSTEM_PROMPT);
                 }
             }
             else
             {
                 XtraMessageBox.Show("该库位有商品,不能删除", Constants.SYSTEM_PROMPT);
             }
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 库位变化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rICBLayout_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataRow row = gvProductCheck.GetFocusedDataRow();

            if (row != null)
            {
                gvProductCheck.BeginUpdate();
                string       houseCode = (comboBoxStockHouse.Tag as Hashtable)[comboBoxStockHouse.SelectedIndex].ToString();
                ComboBoxEdit cbe       = (ComboBoxEdit)sender;
                row[gcLayoutName.FieldName] = cbe.Properties.Items[cbe.SelectedIndex].ToString();

                Hashtable table      = rICBLayout.Tag as Hashtable;
                string    layoutCode = table[cbe.SelectedIndex].ToString();
                row[gcLayoutCode.FieldName] = layoutCode;
                List <StockHouseProduct> list = StockHouseService.GetStockHouseProduct(c => c.HouseCode == houseCode && c.LayoutCode == layoutCode && c.SkuOuterID == row[gcSkuOuterID.FieldName].ToString());
                if (list.Count > 0)
                {
                    StockHouseProduct houseProduct = list.First();
                    row[gcSkuQuantity.FieldName] = houseProduct.Num;
                }
                else
                {
                    row[gcSkuQuantity.FieldName] = 0;
                }
                gvProductCheck.EndUpdate();
                CalculateProfitOrLoss();
                GetDetails();
            }
            gvProductCheck.BestFitColumns();
            gridViewDetail.BestFitColumns();
        }
Ejemplo n.º 5
0
        private void repositoryItemComboBoxLayoutOut_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = ((DevExpress.XtraEditors.ComboBoxEdit)(sender)).SelectedIndex;

            string[] codeList = repositoryItemComboBoxLayoutOut.Tag.ToString().Split(',');
            if (index != -1 && codeList.Length > index)
            {
                DataRow dRow = gVStockProduct.GetFocusedDataRow();
                gVStockProduct.SetFocusedRowCellValue("LayoutCodeOut", codeList[index]);
                if (dRow != null)
                {
                    string stockHouseCode = string.Empty;
                    if (comboStockOut.Tag != null)
                    {
                        string[] houseCodeList = comboStockOut.Tag.ToString().Split(',');
                        if (houseCodeList.Length > comboStockOut.SelectedIndex)
                        {
                            stockHouseCode = houseCodeList[comboStockOut.SelectedIndex];
                        }
                    }

                    int num = StockHouseService.GetQuantity(dRow["SkuOuterID"].ToString(), stockHouseCode, codeList[index]);//调出仓库库位库存量
                    gVStockProduct.SetFocusedRowCellValue("Num", num);
                }
            }
            else
            {
                gVStockProduct.SetFocusedRowCellValue("LayoutCodeOut", string.Empty);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 加载全部仓库
        /// </summary>
        /// <param name="repositoryItemComboBox"></param>
        public void LoadAllHouse(RepositoryItemComboBox repositoryItemComboBoxHouse)
        {
            //加载所有仓库
            List <StockHouse> list  = StockHouseService.GetAllStockHouse();
            Hashtable         table = new Hashtable();
            int i = 0;

            foreach (StockHouse sh in list)
            {
                repositoryItemComboBoxHouse.Items.Add(sh.HouseName);
                table.Add(i++, sh.StockHouseCode);
            }
            repositoryItemComboBoxHouse.Tag = table;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 加载仓库信息
        /// </summary>
        private void ComponentInit()
        {
            //加载仓库
            List <StockHouse> stockHouseList = StockHouseService.GetAllStockHouse();
            Hashtable         table          = new Hashtable();
            int index = 0;

            foreach (StockHouse stockHouse in stockHouseList)
            {
                comboBoxStockHouse.Properties.Items.Add(stockHouse.HouseName);
                table.Add(index++, stockHouse.StockHouseCode);
            }
            comboBoxStockHouse.Tag = table;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 取得商品在仓库中的信息并更新数量
        /// </summary>
        /// <param name="HouseCode"></param>
        /// <param name="SkuOuterID"></param>
        /// <param name="LayoutCode"></param>
        /// <param name="num"></param>
        /// <param name="shpList"></param>
        /// <returns></returns>
        bool GetStockHouseProduct(string HouseCode, string SkuOuterID, string LayoutCode, int num, List <StockHouseProduct> shpList)
        {
            List <StockHouseProduct> tempshpList = StockHouseService.GetStockHouseProduct(c => c.HouseCode == HouseCode && c.SkuOuterID == SkuOuterID && c.LayoutCode == LayoutCode);
            StockHouseProduct        shp;

            if (tempshpList.Count > 0)
            {
                shp = tempshpList.First();
            }
            else
            {
                return(false);
            }
            shp.Num += num;
            shpList.Add(shp);
            return(true);
        }
Ejemplo n.º 9
0
        //下方界面行值改变事件响应
        private void gvSaleInfo_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            DataRow currentRow = gvSaleInfo.GetFocusedDataRow();

            ShowItemPropValue(currentRow["iid"].ToString(), currentRow["SkuProps_Str"].ToString());
            //加载出库仓库
            repositoryItemComboStockHouse.Items.Clear();
            List <StockHouseProduct> stockHouseList = StockHouseService.GetStockHouseProduct(i => i.SkuOuterID == currentRow["SkuOuterID"].ToString());
            string houseCode = string.Empty;

            foreach (StockHouseProduct stockHouse in stockHouseList)
            {
                repositoryItemComboStockHouse.Items.Add(stockHouse.HouseName);
                houseCode += stockHouse.HouseCode + ",";
            }
            repositoryItemComboStockHouse.Tag = houseCode.Trim(',');
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 调出仓库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboStockOut_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (gVStockProduct.RowCount > 0)
            {
                SetCellLayoutEmpty(true);
                repositoryItemComboBoxLayoutOut.Items.Clear();

                if (comboStockOut.Tag != null)
                {
                    int      index    = ((DevExpress.XtraEditors.ComboBoxEdit)(sender)).SelectedIndex;
                    string[] codeList = comboStockOut.Tag.ToString().Split(',');
                    //repositoryItemComboBoxLayoutOut.Items.Clear();
                    if (index != -1 && codeList.Length > index)
                    {
                        string houseCode = codeList[index];

                        //出库库位
                        string  tag  = string.Empty;
                        DataRow dRow = gVStockProduct.GetFocusedDataRow();
                        if (dRow != null)
                        {
                            string skuOuterID = dRow["SkuOuterID"].ToString();
                            List <StockHouseProduct> stockLayoutList = StockHouseService.GetStockHouseProduct(i => i.SkuOuterID == skuOuterID && i.HouseCode == houseCode);
                            foreach (StockHouseProduct vStockHouse in stockLayoutList)
                            {
                                if (string.IsNullOrEmpty(vStockHouse.LayoutName))
                                {
                                    continue;
                                }
                                repositoryItemComboBoxLayoutOut.Items.Add(vStockHouse.LayoutName);
                                tag += vStockHouse.LayoutCode + ",";
                            }
                            repositoryItemComboBoxLayoutOut.Tag = tag.Trim(',');
                        }
                    }
                    else
                    {
                        SetCellLayoutEmpty(true);
                        //gVStockProduct.SetFocusedRowCellValue("LayoutCodeOut", string.Empty);
                        //gVStockProduct.SetFocusedRowCellValue("LayoutNameOut", string.Empty);
                        //gVStockProduct.SetFocusedRowCellValue("Num", string.Empty);
                    }
                }
            }
        }
Ejemplo n.º 11
0
 private void comboStockIn_ButtonPressed(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     if (e.Button.Kind.ToString() == "Plus")
     {
         Alading.Forms.Stock.SettingUp.ModifyHouse modifyHouse = new Alading.Forms.Stock.SettingUp.ModifyHouse();
         modifyHouse.ShowDialog();
         //刷新入库仓库
         comboStockIn.Properties.Items.Clear();
         List <StockHouse> stockHouseList = StockHouseService.GetAllStockHouse();
         string            houseCode      = string.Empty;
         foreach (StockHouse stockHouse in stockHouseList)
         {
             comboStockIn.Properties.Items.Add(stockHouse.HouseName);
             houseCode += stockHouse.StockHouseCode + ",";
         }
         comboStockIn.Tag = houseCode.Trim(',');
     }
 }
Ejemplo n.º 12
0
        private void AllocationAdd_Load(object sender, EventArgs e)
        {
            gVStockProduct.BestFitColumns();
            //出库及入库仓库
            comboStockOut.Properties.Items.Clear();
            comboStockIn.Properties.Items.Clear();
            List <StockHouse> stockHouseList = StockHouseService.GetAllStockHouse();
            string            houseCode      = string.Empty;

            foreach (StockHouse stockHouse in stockHouseList)
            {
                comboStockOut.Properties.Items.Add(stockHouse.HouseName);
                comboStockIn.Properties.Items.Add(stockHouse.HouseName);
                houseCode += stockHouse.StockHouseCode + ",";
            }
            comboStockOut.Tag = houseCode.Trim(',');
            comboStockIn.Tag  = houseCode.Trim(',');
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 通过条形码获取商品
        /// </summary>
        /// <param name="barCode"></param>
        /// <param name="gridView"></param>
        /// <param name="dataTable"></param>
        /// <returns></returns>
        public bool GetProByBarCode(string barCode, GridView gridView, DataTable dataTable)
        {
            View_StockItemProduct vsip         = View_StockItemProductService.GetView_StockItemProductBySkuOuterId(barCode);
            StockHouseProduct     houseProduct = StockHouseService.GetStockHouseProduct(barCode);

            if (vsip != null)
            {
                DataRow dRow     = dataTable.NewRow();
                int     rowCount = gridView.RowCount;
                for (int i = 0; i < rowCount; i++)
                {
                    DataRow row = gridView.GetDataRow(i);
                    if (row["SkuOuterID"].ToString() == vsip.SkuOuterID)
                    {
                        return(true);
                    }
                }
                //dRow["Select"] = false;
                dRow["CatName"]       = vsip.CatName;
                dRow["StockCatName"]  = vsip.StockCatName;
                dRow["ProductName"]   = vsip.Name;
                dRow["Num"]           = vsip.SkuQuantity;
                dRow["HouseName"]     = houseProduct.HouseName;
                dRow["LayoutName"]    = houseProduct.LayoutName;
                dRow["SaleProps"]     = vsip.SkuProps_Str;
                dRow["Specification"] = vsip.Specification;
                dRow["Model"]         = vsip.Model;
                dRow["SkuOuterID"]    = barCode;
                dRow["OuterID"]       = vsip.OuterID;
                dRow["HouseCode"]     = houseProduct.HouseCode;
                dRow["LayoutCode"]    = houseProduct.LayoutCode;
                //dRow["Count"] = 0.0;
                dRow["price"]         = vsip.SkuPrice;
                dRow["StockUnitName"] = vsip.StockUnitName;
                dataTable.Rows.Add(dRow);
                gridView.BestFitColumns();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 完成一些准备工作,如入库单号的生成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PurchaseIn_Load(object sender, EventArgs e)
        {
            //加载付款方式
            inoutHelper.GetPayType(comboPayType);
            //显示到账时间
            dateEditIncomeTime.Text = DateTime.Now.ToShortDateString();
            textEditPayTerm.Text    = "0";

            List <StockHouse> list  = StockHouseService.GetAllStockHouse();
            Hashtable         table = new Hashtable();
            int i = 0;

            foreach (StockHouse sh in list)
            {
                repositoryItemComboBoxStockHouse.Items.Add(sh.HouseName);
                table.Add(i++, sh.StockHouseCode);
            }
            repositoryItemComboBoxStockHouse.Tag = table;
        }
Ejemplo n.º 15
0
        private void Init()
        {
            List <Alading.Entity.StockHouse> stockHouseList = StockHouseService.GetAllStockHouse();

            if (stockHouseList != null && stockHouseList.Count > 0)
            {
                treeListStockHouse.DataSource = stockHouseList;
            }
            else
            {
                treeListStockHouse.DataSource = null;
                textHouseAddr.Text            = string.Empty;
                textHouseName.Text            = string.Empty;
                textEditHouseCode.Text        = string.Empty;
                textContact.Text           = string.Empty;
                memoHouseRemark.Text       = string.Empty;
                stockHouseCode             = string.Empty;
                gridStockLayout.DataSource = null;
            }
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
0
        public AllocationAdd(Alading.Entity.StockInOut stockInOut, DataTable dTable)
        {
            InitializeComponent();

            IsAddFlag = false;
            this.Text = "库存调拨-修改";
            AddColumns();//给table增加row
            textOperatorName.Text    = stockInOut.OperatorName;
            dateInOutTime.DateTime   = stockInOut.InOutTime;
            textInOutCode.Text       = stockInOut.InOutCode;
            comboStockOut.Text       = stockInOut.HouseNameOut;
            comboStockIn.Text        = stockInOut.HouseNameIn;
            simpleBtnSaveAdd.Visible = false;
            foreach (DataRow dRow in dTable.Rows)
            {
                DataRow newRow = this.dTable.NewRow();
                newRow["IsSelected"]    = false;
                newRow["Name"]          = dRow["Name"];
                newRow["OuterID"]       = dRow["OuterID"];
                newRow["Specification"] = dRow["Specification"];
                newRow["Model"]         = dRow["Model"];
                newRow["SaleProps"]     = dRow["SaleProps"];
                newRow["Num"]           = StockHouseService.GetQuantity(dRow["SkuOuterID"].ToString(), stockInOut.HouseCodeOut, dRow["LayoutCodeOut"].ToString());//调出仓库库位库存量
                newRow["SkuOuterID"]    = dRow["SkuOuterID"];
                newRow["SkuQuantity"]   = dRow["SkuQuantity"];
                newRow["LayoutCodeIn"]  = dRow["LayoutCodeIn"];
                newRow["LayoutCodeOut"] = dRow["LayoutCodeOut"];
                newRow["LayoutNameIn"]  = dRow["LayoutNameIn"];
                newRow["LayoutNameOut"] = dRow["LayoutNameOut"];
                this.dTable.Rows.Add(newRow);
            }

            int rowHandle = gVStockProduct.FocusedRowHandle;

            //gVStockProduct.FocusedRowChanged -= gVStockProduct_FocusedRowChanged;
            gridStockProduct.DataSource = this.dTable;
            if (rowHandle == 0 && gVStockProduct.FocusedRowHandle > -1)
            {
                FocusedRowChange();
            }

            //加载出库库位
            string  tag     = string.Empty;
            DataRow dataRow = gVStockProduct.GetFocusedDataRow();

            if (dataRow != null)
            {
                string skuOuterID = dataRow["SkuOuterID"].ToString();
                List <StockHouseProduct> stockLayoutList = StockHouseService.GetStockHouseProduct(i => i.SkuOuterID == skuOuterID && i.HouseCode == stockInOut.HouseCodeOut);
                foreach (StockHouseProduct vStockHouse in stockLayoutList)
                {
                    if (string.IsNullOrEmpty(vStockHouse.LayoutName))
                    {
                        continue;
                    }
                    repositoryItemComboBoxLayoutOut.Items.Add(vStockHouse.LayoutName);
                    tag += vStockHouse.LayoutCode + ",";
                }
                repositoryItemComboBoxLayoutOut.Tag = tag.Trim(',');
            }

            //加载入库库位
            string             tagIn      = string.Empty;
            List <StockLayout> LayoutList = StockLayoutService.GetStockLayout(i => i.StockHouseCode == stockInOut.HouseCodeIn);

            foreach (StockLayout layout in LayoutList)
            {
                if (string.IsNullOrEmpty(layout.LayoutName))
                {
                    continue;
                }
                repositoryItemComboBoxLayoutIn.Items.Add(layout.LayoutName);
                tagIn += layout.StockLayoutCode + ",";
            }
            repositoryItemComboBoxLayoutIn.Tag = tagIn.Trim(',');
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleConfirm_Click(object sender, EventArgs e)
        {
            if (textHouseName.Text == string.Empty)
            {
                XtraMessageBox.Show("请输入仓库名称", Constants.SYSTEM_PROMPT);
                return;
            }

            if (modifyFlag == true)
            {
                /*新建一个实例,防止这边更新失败,但是还是修改了原来传进来的那个实例*/
                Alading.Entity.StockHouse newStockHouse = new Alading.Entity.StockHouse();
                newStockHouse.HouseAddress   = textHouseAddr.Text;
                newStockHouse.HouseName      = textHouseName.Text;
                newStockHouse.HouseRemark    = memoHouseRemark.Text;
                newStockHouse.StockHouseCode = stockHouse.StockHouseCode;
                newStockHouse.HouseTel       = textEditHouseTel.Text;
                newStockHouse.HouseContact   = textEditHouseContact.Text;
                if (StockHouseService.UpdateStockHouse(newStockHouse) == ReturnType.Success)
                {
                    XtraMessageBox.Show("修改仓库信息成功", Constants.SYSTEM_PROMPT);
                    /*修改成功同时修改传进来的实例*/
                    stockHouse.HouseAddress = textHouseAddr.Text;
                    stockHouse.HouseName    = textHouseName.Text;
                    stockHouse.HouseRemark  = memoHouseRemark.Text;
                    stockHouse.HouseTel     = textEditHouseTel.Text;
                    stockHouse.HouseContact = textEditHouseContact.Text;
                    this.Close();
                }
                else
                {
                    XtraMessageBox.Show("修改仓库信息失败", Constants.SYSTEM_PROMPT);
                }
            }
            else
            {
                stockHouse.HouseAddress = textHouseAddr.Text;
                stockHouse.HouseName    = textHouseName.Text;
                stockHouse.HouseRemark  = memoHouseRemark.Text;
                stockHouse.HouseTel     = textEditHouseTel.Text;
                stockHouse.HouseContact = textEditHouseContact.Text;
                if (!string.IsNullOrEmpty(textHouseCode.Text))
                {
                    stockHouse.StockHouseCode = textHouseCode.Text;
                    List <Alading.Entity.StockHouse> houseList = StockHouseService.GetStockHouse(c => c.StockHouseCode == stockHouse.StockHouseCode);
                    if (houseList != null && houseList.Count > 0)
                    {
                        XtraMessageBox.Show("仓库编码重复,请重输!", Constants.SYSTEM_PROMPT);
                        return;
                    }
                }
                else
                {
                    //XtraMessageBox.Show("请输入仓库编码!", Constants.SYSTEM_PROMPT);
                    //return;
                    stockHouse.StockHouseCode = Guid.NewGuid().ToString();
                }

                if (StockHouseService.AddStockHouse(stockHouse) == ReturnType.Success)
                {
                    XtraMessageBox.Show("新增仓库成功", Constants.SYSTEM_PROMPT);
                    this.Close();
                }
                else
                {
                    XtraMessageBox.Show("新增仓库失败", Constants.SYSTEM_PROMPT);
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 焦点行改变触发,加载该商品的所在仓库
        /// </summary>
        private void FocusedRowChange()
        {
            try
            {
                DataRow dRow       = gVStockProduct.GetFocusedDataRow();
                string  skuOuterID = string.Empty;
                if (dRow != null && dRow["SkuOuterID"] != null)
                {
                    skuOuterID = dRow["SkuOuterID"].ToString();
                }
                if (skuOuterID != string.Empty)
                {
                    //加载出库库位
                    string stockHouseCode = string.Empty;
                    if (comboStockOut.Tag != null)
                    {
                        string[] codeList = comboStockOut.Tag.ToString().Split(',');
                        if (codeList.Length > comboStockOut.SelectedIndex)
                        {
                            stockHouseCode = codeList[comboStockOut.SelectedIndex];
                        }
                    }
                    List <StockHouseProduct> stockHouseListOut = StockHouseService.GetStockHouseProduct(i => i.SkuOuterID == skuOuterID && i.HouseCode == stockHouseCode);
                    repositoryItemComboBoxLayoutOut.Items.Clear();
                    string tag = string.Empty;
                    foreach (StockHouseProduct stockHouse in stockHouseListOut)
                    {
                        repositoryItemComboBoxLayoutOut.Items.Add(stockHouse.LayoutName);
                        tag += stockHouse.LayoutCode + ",";
                    }
                    repositoryItemComboBoxLayoutOut.Tag = tag.Trim(',');
                }

                //加载入库库位
                //if (comboStockIn.Text != string.Empty)
                //{
                //    string stockHouseCode = string.Empty;
                //    if (comboStockOut.Tag != null)
                //    {
                //        string[] codeList = comboStockOut.Tag.ToString().Split(',');
                //        if (codeList.Length > comboStockOut.SelectedIndex)
                //        {
                //            stockHouseCode = codeList[comboStockOut.SelectedIndex];
                //        }
                //    }
                //    //HouseCode为空
                //    if (string.IsNullOrEmpty(stockHouseCode))
                //    {
                //        repositoryItemComboBoxLayoutIn.Items.Clear();
                //    }
                //    else
                //    {
                //        //加载Layout
                //        repositoryItemComboBoxLayoutIn.Items.Clear();
                //        List<StockLayout> layOutList = StockLayoutService.GetStockLayout(i => i.StockHouseCode == stockHouseCode);
                //        if (layOutList != null && layOutList.Count > 0)
                //        {
                //            string tag = string.Empty;

                //            foreach (StockLayout stockLayout in layOutList)
                //            {
                //                repositoryItemComboBoxLayoutIn.Items.Add(stockLayout.LayoutName);
                //                tag += stockLayout.StockLayoutCode + ",";
                //            }
                //            repositoryItemComboBoxLayoutIn.Tag = tag.Trim(',');
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, Constants.SYSTEM_PROMPT);
            }
        }