Esempio n. 1
0
        /// <summary>
        /// 合并订单信息显示 子交易信息
        /// </summary>
        /// <param name="ViewTradeList"></param>
        private void LoadTradeDetail()
        {
            List <IGrouping <string, View_TradeStock> > trade_stock_group = new List <IGrouping <string, View_TradeStock> >();
            DataRow row = _currentTradeRow;

            /*如果有数据*/
            if (gvTradeWaitPrint.RowCount >= 0 && _currentTradeRow != null)
            {
                if (Convert.ToBoolean(row["IsCombined"].ToString()))
                {
                    /*当点击合并项的时候才加载合并订单信息选项卡*/
                    detailCombineTradeMessage.PageVisible = true;
                    tabsTradeDetail.SelectedTabPage       = detailCombineTradeMessage;
                    List <View_TradeStock> TradeStockList = View_TradeStockService.GetView_TradeStock(q => q.CombineCode == row["CombineCode"].ToString());
                    /*通过customtid  归类*/
                    trade_stock_group = TradeStockList.GroupBy(q => q.CustomTid).ToList();
                }
                else
                {
                    detailCombineTradeMessage.PageVisible = false;
                }
            }


            DataSet dataSet = new DataSet();
            //从XML文件读出暂存数据库表格框架 包含TradeList表和OrderList表
            MemoryStream stream = new MemoryStream(Resources.TradeStockSchema);

            try
            {
                dataSet.ReadXmlSchema(stream);
            }
            finally
            {
                stream.Close();
            }
            #region 初始化数据
            foreach (IGrouping <string, View_TradeStock> tradeCur in trade_stock_group)
            {
                /* trade表初始化*/
                DataRow tradeRow = dataSet.Tables["TradeList"].NewRow();
                InitTradeRow(tradeRow, tradeCur);
                dataSet.Tables["TradeList"].Rows.Add(tradeRow);

                int productAccount = tradeCur.Where(o => o.OrderType == emumOrderType.SellGoods).Count(); //用于消除赠品的影响
                foreach (View_TradeStock orderCurrent in tradeCur)
                {
                    /* order表初始化  */
                    DataRow orderRow = dataSet.Tables["OrderList"].NewRow();
                    InitOrderRow(orderRow, orderCurrent);
                    dataSet.Tables["OrderList"].Rows.Add(orderRow);
                }
                // 数据绑定相关连操作
                gcCombineTrade.DataSource = dataSet.Tables["TradeList"];
                gcCombineTrade.ForceInitialize();                                                                       //强制初始化
                gvParentCombineTrade.BestFitColumns();
                gcCombineTrade.LevelTree.Nodes.Add(Alading.Taobao.Constants.TRADE_ORDER_RELATION, gvChildCombineOrder); //建立联级绑定
                #endregion
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 初始化函数
        /// </summary>
        /// <param name="CustomTidList"></param>
        /// <param name="combine_flag"></param>
        private void init(List <string> CustomTidList, string combine_flag)
        {
            foreach (string CustomTid in customTidList)
            {
                curTradeList.AddRange(View_TradeStockService.GetView_TradeStock(q => q.CustomTid == CustomTid));
                TradeStockList = curTradeList.GroupBy(q => q.CustomTid).ToList();
            }

            /*交易还原成一个交易的时候  提交按钮隐藏*/
            if (CombineFlag == combineStyle.ConbineTradeFlg)
            {
                BtnCombineSave.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                saveBtn.Visibility        = DevExpress.XtraBars.BarItemVisibility.Always;
                delete.Visibility         = DevExpress.XtraBars.BarItemVisibility.Never;
            }

            /*不同交易合并成一个交易的时候,保存按钮隐藏*/
            if (CombineFlag == combineStyle.ConbinePrintFlg)
            {
                BtnCombineSave.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                saveBtn.Visibility        = DevExpress.XtraBars.BarItemVisibility.Never;
                delete.Visibility         = DevExpress.XtraBars.BarItemVisibility.Always;
            }
            /*数据展示*/
            LoadData(TradeStockList, gvTradePst, gcWaitPst);
        }
Esempio n. 3
0
        /// <summary>
        /// 根据交易单号来判断一笔交易是否缺货
        /// </summary>
        /// <param name="customTid">交易号</param>
        /// <returns></returns>
        private string GetTradeLackMessage(string customTid)
        {
            List <View_TradeStock> orders = View_TradeStockService.GetView_TradeStock(p => p.CustomTid == customTid && p.OrderType != emumOrderType.GiftGoods);

            try
            {
                int max = (int)orders.Max(p => p.SkuQuantity - p.OccupiedQuantity - p.num);
                int min = (int)orders.Min(p => p.SkuQuantity - p.OccupiedQuantity - p.num);
                if (min >= 0)
                {
                    return(LackProductOrNot.Normal);
                }
                else if (max < 0)
                {
                    return(LackProductOrNot.Lack);
                }
                else
                {
                    return(LackProductOrNot.PartLack);
                }
            }
            catch (System.Exception ex)
            {
                XtraMessageBox.Show("未建立库存关联!");
            }
            return(string.Empty);
        }
Esempio n. 4
0
 /// <summary>
 /// 自定义构造函数
 /// </summary>
 /// <param name="customTid"></param>
 public TradeSplit(string customTid)
 {
     InitializeComponent();
     _customTid = customTid;
     /*从数据库获取数据CustomTid,非礼品并且是没有拆分过的 */
     ParentTradeList = View_TradeStockService.GetView_TradeStock(p => p.CustomTid == _customTid &&
                                                                 p.OrderType != emumOrderType.GiftGoods &&
                                                                 p.IsSplited == false);
     /*数据转换*/
     _parentOrderList = ViewTradeStockCopyData(ParentTradeList);
     LoadSpiltTrade(gcParentTrade, _parentOrderList);
 }
Esempio n. 5
0
        /// <summary>
        /// 获取宝贝属性,商品名等
        /// </summary>
        /// <param name="TradeOrderCode"></param>
        /// <param name="tradeOrderStock"></param>
        private void AddDetail(string TradeOrderCode, TradeOrderStock tradeOrderStock)
        {
            View_TradeStock tradeStock = View_TradeStockService.GetView_TradeStock(q => q.TradeOrderCode == TradeOrderCode).FirstOrDefault();

            if (tradeStock != null)
            {
                //宝贝性质
                tradeOrderStock.itemType = tradeStock.ItemType;
                //商品类别
                tradeOrderStock.orderType = tradeStock.OrderType;
                //商品名
                tradeOrderStock.itemName = tradeStock.ItemName;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 根据订单号来确定一笔交易是否缺货
        /// </summary>
        /// <param name="tradeOrderCode">本地唯一订单号</param>
        /// <returns></returns>
        private string GetOrderLackMessage(string tradeOrderCode)
        {
            View_TradeStock order = View_TradeStockService.GetView_TradeStock(p => p.TradeOrderCode == tradeOrderCode).FirstOrDefault();

            if (order != null)
            {
                if ((order.SkuQuantity - order.OccupiedQuantity - order.num) >= 0)
                {
                    return(LackProductOrNot.Normal);
                }
                else
                {
                    return(LackProductOrNot.Lack);
                }
            }
            else
            {
                return(LackProductOrNot.NotExist);
            }
        }
Esempio n. 7
0
        private void gvChildGV_RowCellClick(object sender, RowCellClickEventArgs e)
        {
            GridView gv = (sender as GridView).GridControl.GetViewAt(e.Location) as GridView;

            if (gv != null)
            {
                GridHitInfo hi = gv.CalcHitInfo(e.Location);
                if (hi.Column != null && hi.InRowCell)
                {
                    //记录当前焦点所在的OrderRow
                    DataRow currentMatch = gv.GetDataRow(hi.RowHandle);

                    #region 点击种类 如果是组合商品 下面显示
                    if (currentMatch["ItemType"].ToString() == ItemType.ConbineProduct.ToString())
                    {
                        detailAessemble.PageVisible     = true;
                        tabsTradeDetail.SelectedTabPage = detailAessemble;
                    }
                    else
                    {
                        detailAessemble.PageVisible = false;
                    }
                    #endregion

                    #region 如果不是连续点击 则绑定数据

                    //防止同一重复事件多次加载
                    if (_currentOrderRow != currentMatch)
                    {
                        //记录当前焦点所在的OrderRow
                        _currentOrderRow = currentMatch;

                        //记录当前订单的父Trade行
                        _currentTradeRow = currentMatch.GetParentRow(Alading.Taobao.Constants.TRADE_ORDER_RELATION);

                        //绑定TradeDetail信息
                        SetTradeDetailMessages(_currentTradeRow);

                        //绑定商品信息到面板
                        ShowItemPropValue(currentMatch["iid"].ToString(), currentMatch["sku_properties_name"].ToString());
                    }
                    #endregion

                    #region  如果选中列为’修改订单‘,则执行处理代码
                    if (hi.Column.ColumnHandle == 0)//
                    {
                        //如果是未建立库存 则不作处理
                        if (_currentOrderRow[1].ToString() == LackProductOrNot.NotBuildStock)
                        {
                            XtraMessageBox.Show("当前订单未关联库存,不能修改订单信息");
                            return;
                        }
                        //取得当前选中订单的数据库真实值
                        View_TradeStock focusedOrder =
                            View_TradeStockService.GetView_TradeStock(p => p.TradeOrderCode == _currentOrderRow["TradeOrderCode"].ToString()).FirstOrDefault();
                        if (focusedOrder == null)
                        {
                            return;
                        }
                        if (focusedOrder.LocalStatus != LocalTradeStatus.HasNotSummit)
                        {
                            XtraMessageBox.Show("该订单的交易状态已经改变,不能换货!");
                            return;
                        }
                        #region 利用时间戳来防止并发
                        DialogResult result = DialogResult.Yes;
                        if (!SystemHelper.CompareTimeStamp(_currentOrderRow["OrderTimeStamp"] as byte[], focusedOrder.OrderTimeStamp))
                        {
                            //如果订单信息已经被改,询问是否继续修改
                            result = XtraMessageBox.Show("订单信息已被修改,继续修改(YES)/查看流程信息(NO)", "订单修改",
                                                         MessageBoxButtons.YesNo);
                            if (result == DialogResult.No)//如果选择为NO,则查看流程信息,并返回
                            {
                                tabsTradeDetail.SelectedTabPage = detailTabFlowMsg;
                                return;
                            }
                        }
                        if (result == DialogResult.Yes)//如果result=YES,则继续修改
                        {
                            //传入时间戳,只有在最后修改提交前验证才能保证不并发
                            ModifyOrder modifyOrder = new ModifyOrder(focusedOrder, _currentOrderRow["OrderTimeStamp"] as byte[]);//转入修改订单页面
                            modifyOrder.ShowDialog();

                            switch (modifyOrder.DialogResult)
                            {
                            case DialogResult.Ignore:
                                return;

                            case DialogResult.OK:
                                InitSelectTab();
                                break;

                            case DialogResult.Cancel:
                                tabsTradeDetail.SelectedTabPage = detailTabFlowMsg;
                                break;
                            }
                        }
                        else//否则,直接返回
                        {
                            return;
                        }
                        #endregion
                    }
                    #endregion
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 自动拆分
        /// </summary>
        private void AutoSplit()
        {
            #region 自动拆分
            /*子列表清空*/
            _childOrderList.Clear();
            /*父列表清空*/
            _parentOrderList.Clear();
            /*获取值*/
            List <View_TradeStock> ParentTradeList = View_TradeStockService.GetView_TradeStock(p => p.CustomTid == _customTid);
            /*数据转换*/
            _parentOrderList = ViewTradeStockCopyData(ParentTradeList);

            /*删除列表*/
            List <ViewTradeStock> removeTradeList = new List <ViewTradeStock>();

            for (int i = 0; i < _parentOrderList.Count; i++)
            {
                int LeftQuantity = 0;

                /*剩余量*/
                LeftQuantity = _parentOrderList[i].SkuQuantity.Value - _parentOrderList[i].OccupiedQuantity.Value;
                /*自动拆分缺货的订单*/
                if (LeftQuantity < _parentOrderList[i].num)
                {
                    View_TradeStock viewTrade      = View_TradeStockService.GetView_TradeStock(q => q.TradeOrderCode == _parentOrderList[i].TradeOrderCode).FirstOrDefault();
                    ViewTradeStock  viewChildTrade = new ViewTradeStock();
                    if (viewTrade == null)
                    {
                        return;
                    }
                    /*数据转换*/
                    viewCopy(viewChildTrade, viewTrade);
                    /*订单量改变*/
                    viewChildTrade.num = _parentOrderList[i].num - LeftQuantity;
                    /*订单量改变*/
                    viewChildTrade.total_fee = (viewChildTrade.price) * viewChildTrade.num;
                    /*修改customtid*/
                    viewChildTrade.CustomTid = "child" + viewChildTrade.CustomTid;
                    /*tradeordercode*/
                    viewChildTrade.TradeOrderCode = Guid.NewGuid().ToString();
                    /*向子列表中填值*/
                    _childOrderList.Add(viewChildTrade);

                    /*订单量改变*/
                    _parentOrderList[i].num = LeftQuantity;

                    if (_parentOrderList[i].num == 0)
                    {
                        removeTradeList.Add(_parentOrderList[i]);
                    }
                    /*订单量改变*/
                    _parentOrderList[i].total_fee = (_parentOrderList[i].price) * _parentOrderList[i].num;
                } //if
            }     //for
            /*将全部缺货的订单分离出去*/
            foreach (ViewTradeStock tradeStock in removeTradeList)
            {
                _parentOrderList.Remove(tradeStock);
            }
            #endregion

            #region  子交易修改
            ChildTrade = TradeService.GetTrade(_customTid);
            if (ChildTrade == null)
            {
                return;
            }
            /*CustomTid 随机产生一个*/
            ChildTrade.CustomTid       = "child" + _customTid;
            ChildTrade.ParentCustomTid = _customTid;
            ChildTrade.IsSplited       = true;
            /*邮费*/
            ChildTrade.post_fee = ChildTrade.post_fee;
            /*修改应付金额,总费*/
            ChildTrade.payment   = 0;
            ChildTrade.total_fee = 0.0;
            float ChildTotalFee = 0;
            foreach (ViewTradeStock order in _childOrderList)
            {
                ChildTrade.payment += order.payment;
                ChildTotalFee      += (float)(order.total_fee);
            }
            ChildTrade.total_fee = ChildTotalFee;
            ChildTrade.post_fee  = ParentTradeList[0].post_fee;
            #endregion

            #region 父交易修改
            /*获取父交易*/
            ParentTrade = TradeService.GetTrade(_customTid);
            /*修改父交易*/
            ParentTrade.IsSplited       = true;
            ParentTrade.ParentCustomTid = "0";
            /*修改应付金额,总费*/
            ParentTrade.payment = 0;
            float total_fee = 0;
            foreach (ViewTradeStock order in _parentOrderList)
            {
                ParentTrade.payment += order.payment;
                total_fee           += (float)(order.total_fee);
            }
            ParentTrade.total_fee = total_fee;
            #endregion

            #region 数据展示
            LoadSpiltTrade(gcParentTrade, _parentOrderList);
            gcParentTrade.RefreshDataSource();

            LoadSpiltTrade(gcChildTrade, _childOrderList);
            gcChildTrade.RefreshDataSource();
            #endregion
        }
Esempio n. 9
0
        /// <summary>
        /// 拆分函数
        /// </summary>
        /// <param name="gc"></param>
        /// <param name="view"></param>
        private void FunSplit(GridControl gc, GridView view)
        {
            #region 订单拆分修改
            List <int> rowList = new List <int>();

            //接收从数据库视图表中传出来的值,此值不能修改
            Alading.Entity.View_TradeStock ParentOrder = new Alading.Entity.View_TradeStock();

            Alading.Entity.View_TradeStock ChildOrder = new Alading.Entity.View_TradeStock();

            //所勾选要被拆分的交易 ,用于修改数据库
            List <ViewTradeStock> tradeParentOrderList = new List <ViewTradeStock>();

            DataRow row = null;

            int NullRecord = 0;

            for (int rowHandle = 0; rowHandle < view.RowCount; rowHandle++)
            {
                //将从数据库视图表中传出来的值转换
                ViewTradeStock ParentOrderExtent = new ViewTradeStock();
                ViewTradeStock ChildOrderExtent  = new ViewTradeStock();

                row = view.GetDataRow(rowHandle);

                if (row == null)
                {
                    return;
                }
                if (Convert.ToBoolean(row["IsSelected"].ToString()))
                {
                    ParentOrder = View_TradeStockService.GetView_TradeStock(q => q.oid == row["oid"].ToString()).FirstOrDefault();
                    if (ParentOrder == null)
                    {
                        return;
                    }
                    /*数据转换*/
                    viewCopy(ParentOrderExtent, ParentOrder);
                    /*购买量的修改*/
                    if (row["numSplit"].ToString() == null || row["numSplit"].ToString() == string.Empty)
                    {
                        return;
                    }

                    ParentOrderExtent.num = int.Parse(row["num"].ToString()) - int.Parse(row["numSplit"].ToString());
                    /*total_fee的修改*/
                    ParentOrderExtent.total_fee = float.Parse(row["price"].ToString()) * ParentOrderExtent.num;
                    /*修改payment*/
                    ParentOrderExtent.payment = (ParentOrderExtent.total_fee + ParentOrderExtent.adjust_fee);
                    tradeParentOrderList.Add(ParentOrderExtent);

                    ChildOrder = ParentOrder;
                    if (ChildOrder == null)
                    {
                        return;
                    }
                    /*数据转换*/
                    viewCopy(ChildOrderExtent, ChildOrder);
                    /*购买量修改*/
                    ChildOrderExtent.num            = int.Parse(row["numSplit"].ToString());
                    ChildOrderExtent.TradeOrderCode = Guid.NewGuid().ToString();
                    /*total_fee的修改*/
                    ChildOrderExtent.total_fee = float.Parse(row["price"].ToString()) * ChildOrderExtent.num;
                    /*修改payment*/
                    ChildOrderExtent.payment = (ChildOrderExtent.total_fee);
                    /*修改customTid  子交易后面加1*/
                    ChildOrderExtent.CustomTid = "child" + ChildOrderExtent.CustomTid;

                    #region 如果新拆分后订单在子订单列表中存在,则累加相应的量
                    int count = 0;
                    for (count = 0; count < _childOrderList.Count; count++)
                    {
                        if (ChildOrderExtent.oid == _childOrderList[count].oid)
                        {
                            ChildOrderExtent.num += _childOrderList[count].num;

                            ChildOrderExtent.total_fee = (ChildOrderExtent.price) * ChildOrderExtent.num;
                            ChildOrderExtent.payment   = (ChildOrderExtent.total_fee);

                            /*修改相关量*/
                            _childOrderList[count].num       = ChildOrderExtent.num;
                            _childOrderList[count].total_fee = ChildOrderExtent.total_fee;
                            _childOrderList[count].payment   = ChildOrderExtent.payment;

                            break;
                        } //if
                    }     //for
                    /*子订单列表中没有新添加的订单*/
                    if (count >= _childOrderList.Count)
                    {
                        _childOrderList.Add(ChildOrderExtent);
                    }
                }/*if (Convert.ToBoolean(row["IsSelected"].ToString()))*/
                else
                {
                    /*记载没被勾选的行数*/
                    NullRecord++;
                }
            }/*for (int rowHandle = 0; rowHandle < view.RowCount; rowHandle++)*/
            if (NullRecord >= view.RowCount)
            {
                XtraMessageBox.Show(Alading.Properties.Resources.NotSelctCanNOtSplit, Alading.Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            #endregion

            #endregion

            #region 修改显示的订单列表
            List <ViewTradeStock> removeTradeList = new List <ViewTradeStock>();
            for (int i = 0; i < tradeParentOrderList.Count; i++)
            {
                for (int j = 0; j < _parentOrderList.Count; j++)
                {
                    if (tradeParentOrderList[i].oid == _parentOrderList[j].oid)
                    {
                        if (tradeParentOrderList[i].num == 0)
                        {
                            removeTradeList.Add(_parentOrderList[j]);
                        }
                        _parentOrderList[j].num       = tradeParentOrderList[i].num;
                        _parentOrderList[j].total_fee = tradeParentOrderList[i].total_fee;
                        _parentOrderList[j].payment   = tradeParentOrderList[i].payment;
                    }
                }
            }
            /*删除_parentOrderList.num 为零的交易*/
            foreach (ViewTradeStock tradeStock in removeTradeList)
            {
                _parentOrderList.Remove(tradeStock);
            }
            #endregion

            #region 所对应交易的修改
            /*获取父交易*/
            ParentTrade = TradeService.GetTrade(_customTid);
            if (ParentTrade == null)
            {
                return;
            }
            /*修改父交易*/
            ParentTrade.IsSplited       = true;
            ParentTrade.ParentCustomTid = "0";
            /*修改应付金额,总费*/
            ParentTrade.payment = 0;
            float total_fee = 0;
            foreach (ViewTradeStock order in _parentOrderList)
            {
                ParentTrade.payment += (double)order.payment;
                total_fee           += (float)order.total_fee;
            }
            ParentTrade.total_fee = total_fee;
            /*修改子交易*/
            ChildTrade = TradeService.GetTrade(_customTid);
            if (ChildTrade == null)
            {
                return;
            }
            /*CustomTid 随机产生一个*/
            ChildTrade.CustomTid       = "child" + _customTid;
            ChildTrade.ParentCustomTid = _customTid;
            ChildTrade.IsSplited       = true;
            /*邮费*/
            ChildTrade.post_fee = ChildTrade.post_fee;
            /*修改应付金额,总费*/
            ChildTrade.payment   = 0;
            ChildTrade.total_fee = 0.0;
            float ChildTotalFee = 0;
            foreach (ViewTradeStock order in _childOrderList)
            {
                ChildTrade.payment += order.payment;
                ChildTotalFee      += (float)(order.total_fee);
            }
            ChildTrade.total_fee = ChildTotalFee;
            /*子交易加上邮费*/
            ChildTrade.post_fee = ParentTradeList[0].post_fee;
            #endregion

            #region 数据展示
            //拆分不合理
            if (_parentOrderList.Count == 0)
            {
                XtraMessageBox.Show("拆分不合理!", "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);

                _parentOrderList.Clear();

                //数据转换
                _parentOrderList = ViewTradeStockCopyData(ParentTradeList);

                LoadSpiltTrade(gcParentTrade, _parentOrderList);

                _childOrderList.Clear();
            }
            LoadSpiltTrade(gcParentTrade, _parentOrderList);
            gcParentTrade.RefreshDataSource();

            LoadSpiltTrade(gcChildTrade, _childOrderList);
            gcChildTrade.RefreshDataSource();
            #endregion
        }