public ConsignSettlementContractSet(ConsignSettlementItemInfoVM viewVM)
 {
     InitializeComponent();
     validationList = new List <ValidationEntity>();
     vm             = new ConsignSettlementItemInfoVM();
     vm             = Newegg.Oversea.Silverlight.Utilities.UtilityHelper.DeepClone <ConsignSettlementItemInfoVM>(viewVM);
     this.Loaded   += new RoutedEventHandler(ConsignSettlementContractSet_Loaded);
 }
Пример #2
0
        private void btnAddSettleItems_Click(object sender, RoutedEventArgs e)
        {
            //添加结算商品:
            int selectCount = 0;

            listProductsVM.ForEach(x =>
            {
                if (x.IsCheckedItem)
                {
                    selectCount++;
                }
            });
            if (selectCount <= 0)
            {
                CurrentWindow.Alert(ResSettledProductsRuleQuery.InfoMsg_CheckProducts);
                return;
            }
            if (CheckMaxinumItemsCount())
            {
                this.listProductsVM.Where(i => i.IsCheckedItem == true).ToList().ForEach(x =>
                {
                    x.IsCheckedItem = false;
                    if (SettleSysNo.HasValue)
                    {
                        x.SettleSysNo = SettleSysNo.Value;
                    }
                    //添加进现有的List中(不重复添加:):
                    ConsignSettlementItemInfoVM getExistItem = OldItemVM.SingleOrDefault(i => i.ConsignToAccLogInfo.LogSysNo == x.ConsignToAccLogInfo.LogSysNo);
                    if (getExistItem == null)
                    {
                        x.IsSettleCostTextBoxReadOnly       = x.SettleType == SettleType.O ? false : true;
                        x.IsSettlePercentageTextBoxReadOnly = x.SettleType == SettleType.P ? false : true;
                        x.SettlePercentageTextBoxVisibility = x.SettleType == SettleType.P ? Visibility.Visible : Visibility.Collapsed;
                        //毛利:
                        x.ConsignToAccLogInfo.RateMargin = x.ConsignToAccLogInfo.SalePrice.ToDecimal() - x.ConsignToAccLogInfo.Cost.ToDecimal();
                        //毛利总额 :
                        x.ConsignToAccLogInfo.RateMarginTotal = x.ConsignToAccLogInfo.RateMargin.ToDecimal() * x.ConsignToAccLogInfo.ProductQuantity.ToInteger();
                        OldItemVM.Add(x);
                    }
                    else
                    {
                        if (getExistItem.SettleSysNo == -1)
                        {
                            getExistItem.SettleSysNo      = null;
                            getExistItem.SettlePercentage = x.SettlePercentage;
                            getExistItem.Cost             = string.IsNullOrEmpty(x.ConsignToAccLogInfo.Cost) ? (decimal?)null : x.ConsignToAccLogInfo.Cost.ToDecimal();
                            getExistItem.SettleRuleSysNo  = x.SettleRuleSysNo;
                            getExistItem.SettleRuleName   = x.SettleRuleName;
                        }
                    }
                });

                this.Dialog.ResultArgs.Data         = OldItemVM;
                this.Dialog.ResultArgs.DialogResult = DialogResultType.OK;
                Dialog.Close(true);
            }
        }
Пример #3
0
        private void hpkSettleRuleName_Click(object sender, RoutedEventArgs e)
        {
            ConsignSettlementItemInfoVM vm = this.SettleProductsQueryResultGrid.SelectedItem as ConsignSettlementItemInfoVM;

            if (null != vm)
            {
                Window.Navigate(string.Format("/ECCentral.Portal.UI.PO/SettledProductsRuleQuery/{0}", vm.SettleRuleName), null, true);
            }
        }
Пример #4
0
        private void hpkOrderCount_Click(object sender, RoutedEventArgs e)
        {
            //订单数量链接,链接至代销转财务记录查询:
            ConsignSettlementItemInfoVM vm = this.SettleProductsQueryResultGrid.SelectedItem as ConsignSettlementItemInfoVM;

            if (null != vm)
            {
                Window.Navigate(string.Format("/ECCentral.Portal.UI.PO/AccountLogQuery/{0}", vm.AllOrderSysNoFormatString), null, true);
            }
        }
Пример #5
0
        private void txtSettleCost_LostFocus(object sender, RoutedEventArgs e)
        {
            TextBox txt = sender as TextBox;

            if (null != txt && !txt.IsReadOnly)
            {
                this.SettleProductsQueryResultGrid.UpdateLayout();
                decimal getInputDecimal = 0;
                if (!string.IsNullOrEmpty(txt.Text.Trim()) && !decimal.TryParse(txt.Text.Trim(), out getInputDecimal))
                {
                    getInputDecimal = 0;
                    //txt.Text = getInputDecimal.ToString("f2");
                }

                //根据修改的结算金额,重新计算此行的其它Row:
                ConsignSettlementItemInfoVM getSelectedItemVM = txt.DataContext as ConsignSettlementItemInfoVM;
                if (null != getSelectedItemVM)
                {
                    //结算:
                    getSelectedItemVM.Cost = getInputDecimal;

                    //总金额:
                    getSelectedItemVM.ConsignToAccLogInfo.CountMany = getSelectedItemVM.ConsignToAccLogInfo.ProductQuantity * getInputDecimal;
                    //毛利:
                    getSelectedItemVM.ConsignToAccLogInfo.RateMargin = getSelectedItemVM.ConsignToAccLogInfo.SalePrice - getInputDecimal;
                    //毛利总额 :
                    getSelectedItemVM.ConsignToAccLogInfo.RateMarginTotal = getSelectedItemVM.ConsignToAccLogInfo.RateMargin * getSelectedItemVM.ConsignToAccLogInfo.ProductQuantity;
                    //差额
                    getSelectedItemVM.ConsignToAccLogInfo.FoldCost = (getSelectedItemVM.ConsignToAccLogInfo.CreateCost ?? 0m) - (getSelectedItemVM.Cost ?? 0m);
                    //把改变的结算价格更新到数据源中:
                    foreach (var item in this.newVM.ConsignSettlementItemInfoList)
                    {
                        if (item.ProductID == getSelectedItemVM.ProductID &&
                            item.ConsignToAccLogInfo.CreateCost == getSelectedItemVM.ConsignToAccLogInfo.CreateCost &&
                            item.ConsignToAccLogInfo.SettleType == getSelectedItemVM.ConsignToAccLogInfo.SettleType &&
                            item.ConsignToAccLogInfo.SalePrice == getSelectedItemVM.ConsignToAccLogInfo.SalePrice &&
                            item.ConsignToAccLogInfo.StockSysNo == getSelectedItemVM.ConsignToAccLogInfo.StockSysNo &&
                            item.SettleRuleSysNo == getSelectedItemVM.SettleRuleSysNo &&
                            item.ConsignToAccLogInfo.Point.ToInteger() == getSelectedItemVM.ConsignToAccLogInfo.Point.ToInteger())
                        {
                            item.Cost = getInputDecimal;
                            item.ConsignToAccLogInfo.FoldCost        = (item.ConsignToAccLogInfo.CreateCost ?? 0m) - (item.Cost ?? 0m);
                            item.ConsignToAccLogInfo.CountMany       = item.ConsignToAccLogInfo.ProductQuantity * getInputDecimal;
                            item.ConsignToAccLogInfo.RateMargin      = item.ConsignToAccLogInfo.SalePrice - getInputDecimal;
                            item.ConsignToAccLogInfo.RateMarginTotal = item.ConsignToAccLogInfo.RateMargin * item.ConsignToAccLogInfo.ProductQuantity;
                        }
                    }
                    CalcSettleProducts();
                }
            }
        }
Пример #6
0
        private void txtSettlePercentage_LostFocus(object sender, RoutedEventArgs e)
        {
            TextBox txt = sender as TextBox;

            if (null != txt && !txt.IsReadOnly)
            {
                this.SettleProductsQueryResultGrid.UpdateLayout();
                decimal getInputPercentage = 0m;
                if (!string.IsNullOrEmpty(txt.Text.Trim()) && !decimal.TryParse(txt.Text.Trim(), out getInputPercentage))
                {
                    getInputPercentage = 0m;
                }

                //根据修改的佣金百分比,重新计算此行的其它Row:
                ConsignSettlementItemInfoVM getSelectedItemVM = txt.DataContext as ConsignSettlementItemInfoVM;
                if (null != getSelectedItemVM)
                {
                    //结算:
                    var profit = getSelectedItemVM.ConsignToAccLogInfo.SalePrice.ToDecimal() * getInputPercentage / 100;
                    var cost   = getSelectedItemVM.ConsignToAccLogInfo.SalePrice * (1 - getInputPercentage / 100);
                    if (profit >= getSelectedItemVM.ConsignToAccLogInfo.MinCommission.ToDecimal())
                    {
                        getSelectedItemVM.Cost = cost;
                    }
                    else
                    {
                        getSelectedItemVM.Cost = getSelectedItemVM.ConsignToAccLogInfo.SalePrice - getSelectedItemVM.ConsignToAccLogInfo.MinCommission;
                    }

                    decimal getCost = getSelectedItemVM.Cost ?? 0m;
                    //佣金百分比
                    getSelectedItemVM.SettlePercentage = getInputPercentage.ToString();
                    //总金额:
                    getSelectedItemVM.ConsignToAccLogInfo.CountMany = getSelectedItemVM.ConsignToAccLogInfo.ProductQuantity * getCost;
                    //毛利:
                    getSelectedItemVM.ConsignToAccLogInfo.RateMargin = getSelectedItemVM.ConsignToAccLogInfo.SalePrice - getCost;
                    //毛利总额 :
                    getSelectedItemVM.ConsignToAccLogInfo.RateMarginTotal = getSelectedItemVM.ConsignToAccLogInfo.RateMargin * getSelectedItemVM.ConsignToAccLogInfo.ProductQuantity;
                    //差额
                    getSelectedItemVM.ConsignToAccLogInfo.FoldCost = (getSelectedItemVM.ConsignToAccLogInfo.CreateCost ?? 0m) - (getSelectedItemVM.Cost ?? 0m);
                    //把改变的结算价格更新到数据源中:
                    foreach (var item in this.newVM.ConsignSettlementItemInfoList)
                    {
                        if (item.ProductID == getSelectedItemVM.ProductID &&
                            item.ConsignToAccLogInfo.CreateCost == getSelectedItemVM.ConsignToAccLogInfo.CreateCost &&
                            item.ConsignToAccLogInfo.SettleType == getSelectedItemVM.ConsignToAccLogInfo.SettleType &&
                            item.ConsignToAccLogInfo.SalePrice == getSelectedItemVM.ConsignToAccLogInfo.SalePrice &&
                            item.ConsignToAccLogInfo.StockSysNo == getSelectedItemVM.ConsignToAccLogInfo.StockSysNo &&
                            item.ConsignToAccLogInfo.Point.ToInteger() == getSelectedItemVM.ConsignToAccLogInfo.Point.ToInteger())
                        {
                            item.Cost             = getCost;
                            item.SettlePercentage = getInputPercentage.ToString();
                            item.ConsignToAccLogInfo.CountMany       = item.ConsignToAccLogInfo.ProductQuantity * getCost;
                            item.ConsignToAccLogInfo.RateMargin      = item.ConsignToAccLogInfo.SalePrice - getCost;
                            item.ConsignToAccLogInfo.RateMarginTotal = item.ConsignToAccLogInfo.RateMargin * item.ConsignToAccLogInfo.ProductQuantity;
                        }
                    }
                    CalcSettleProducts();
                }
            }
        }
Пример #7
0
        private void hpyContractSet_Click(object sender, RoutedEventArgs e)
        {
            ConsignSettlementItemInfoVM vm = this.SettleProductsQueryResultGrid.SelectedItem as ConsignSettlementItemInfoVM;

            if (null != vm)
            {
                ConsignSettlementContractSet contractSetCtrl = new ConsignSettlementContractSet(vm);
                contractSetCtrl.Dialog = Window.ShowDialog("结算商品返利信息", contractSetCtrl, (obj, args) =>
                {
                    if (args.DialogResult == DialogResultType.OK && args.Data != null)
                    {
                        string actionStr = ((List <object>)args.Data)[0].ToString();
                        vm = (ConsignSettlementItemInfoVM)((List <object>)args.Data)[1];

                        for (int i = 0; i < newVM.ConsignSettlementItemInfoList.Count; i++)
                        {
                            var x = newVM.ConsignSettlementItemInfoList[i];

                            bool condition = false;
                            switch (actionStr)
                            {
                            case "Save":
                                condition = (x.ProductSysNo == vm.ProductSysNo &&
                                             x.ConsignToAccLogInfo.CreateCost == vm.ConsignToAccLogInfo.CreateCost &&
                                             x.ConsignToAccLogInfo.SettleType == vm.ConsignToAccLogInfo.SettleType &&
                                             x.ConsignToAccLogInfo.SalePrice == vm.ConsignToAccLogInfo.SalePrice &&
                                             x.ConsignToAccLogInfo.Point.ToInteger() == vm.ConsignToAccLogInfo.Point.ToInteger());
                                break;

                            case "SaveSame":
                                condition = (x.ProductSysNo == vm.ProductSysNo);
                                break;

                            case "SaveAll":
                                condition = true;
                                break;

                            default:
                                break;
                            }


                            if (condition)
                            {
                                if (x.SettleType == SettleType.P && x.SettlePercentage != vm.SettlePercentage)
                                {
                                    continue;
                                }
                                x.AcquireReturnPointType = vm.AcquireReturnPointType;
                                x.AcquireReturnPoint     = vm.AcquireReturnPoint;

                                if (x.AcquireReturnPointType.HasValue)
                                {
                                    x.ContractReturnPointSet = ResConsignMaintain.Msg_AlreadySet;
                                    if (x.AcquireReturnPointType == 0)
                                    {
                                        x.ExpectGetPoint = x.AcquireReturnPoint * x.ConsignToAccLogInfo.ProductQuantity;
                                    }
                                    if (x.AcquireReturnPointType == 1)
                                    {
                                        x.ExpectGetPoint = x.AcquireReturnPoint / 100 * x.ConsignToAccLogInfo.ProductQuantity * vm.Cost.ToDecimal();
                                    }
                                }
                            }
                        }
                        CountConsignSettleItems();
                        CalcSettleProducts();
                        this.SettleProductsQueryResultGrid.Bind();
                    }
                }, new Size(500, 150));
            }
        }
Пример #8
0
        /// <summary>
        /// 合并代销结算单Items:
        /// </summary>
        private void CountConsignSettleItems()
        {
            List <ConsignSettlementItemInfoVM> cloneList         = Newegg.Oversea.Silverlight.Utilities.UtilityHelper.DeepClone <List <ConsignSettlementItemInfoVM> >(this.newVM.ConsignSettlementItemInfoList);
            List <ConsignSettlementItemInfoVM> tmpmergedItemList = new List <ConsignSettlementItemInfoVM>();
            int index = 0;

            if (null != this.newVM.ConsignSettlementItemInfoList)
            {
                foreach (ConsignSettlementItemInfoVM item in cloneList)
                {
                    if (item.SettleSysNo != -1)
                    {
                        ConsignSettlementItemInfoVM vm = tmpmergedItemList.SingleOrDefault(x =>
                                                                                           x.ProductID == item.ProductID &&
                                                                                           x.ConsignToAccLogInfo.CreateCost == item.ConsignToAccLogInfo.CreateCost &&
                                                                                           x.ConsignToAccLogInfo.SettleType == item.ConsignToAccLogInfo.SettleType &&
                                                                                           x.SettlePercentage == item.SettlePercentage &&
                                                                                           x.ConsignToAccLogInfo.SalePrice == item.ConsignToAccLogInfo.SalePrice &&
                                                                                           x.ConsignToAccLogInfo.Point.ToInteger() == item.ConsignToAccLogInfo.Point.ToInteger() &&
                                                                                           x.ConsignToAccLogInfo.StockSysNo == item.ConsignToAccLogInfo.StockSysNo &&
                                                                                           x.SettleRuleSysNo == item.SettleRuleSysNo);

                        //如果不存在,则添加进List:
                        if (vm == null)
                        {
                            item.OrderCount = 1;
                            item.AllOrderSysNoFormatString = (item.ConsignToAccLogInfo.LogSysNo.HasValue ? item.ConsignToAccLogInfo.LogSysNo.Value.ToString() : string.Empty);
                            if (!item.AcquireReturnPointType.HasValue)
                            {
                                item.ContractReturnPointSet = ResConsignNew.InfoMsg_ReturnPointNotSet;
                            }
                            else
                            {
                                item.ContractReturnPointSet = ResConsignMaintain.Msg_AlreadySet;
                            }
                            if (item.SettleType == SettleType.P)
                            {
                                //代销(佣金百分比添加) 设置数据信息
                                var profit = item.ConsignToAccLogInfo.SalePrice.ToDecimal() * item.SettlePercentage.ToDecimal() / 100;
                                if (profit >= item.ConsignToAccLogInfo.MinCommission.ToDecimal())
                                {
                                    //<!--CRL21118 去除积分扣除
                                    item.Cost = item.ConsignToAccLogInfo.SalePrice.ToDecimal() * (1 - item.SettlePercentage.ToDecimal() / 100); //- (item.ConsignToAccLogInfo.Point.ToInteger() / 10.0)).ToString("f2");
                                    newVM.ConsignSettlementItemInfoList[index].Cost = item.Cost;
                                }
                                else
                                {
                                    item.Cost = item.ConsignToAccLogInfo.SalePrice.Value - item.ConsignToAccLogInfo.MinCommission.Value;
                                }
                            }
                            else
                            {
                                item.Cost = item.SettleRuleSysNo.HasValue ? item.SettlePrice : item.Cost;
                                newVM.ConsignSettlementItemInfoList[index].Cost = item.Cost;
                            }
                            item.ConsignToAccLogInfo.FoldCost   = item.ConsignToAccLogInfo.CreateCost - item.Cost; //结算成本差额
                            item.ConsignToAccLogInfo.RateMargin = item.ConsignToAccLogInfo.SalePrice - item.Cost;  //毛利
                            tmpmergedItemList.Add(item);
                        }
                        else
                        {
                            //如果存在,则进行累加:
                            vm.ConsignToAccLogInfo.ProductQuantity += item.ConsignToAccLogInfo.ProductQuantity;//商品总数
                            if ((vm.Cost ?? 0m) >= (item.Cost ?? 0m))
                            {
                                vm.Cost = item.SettleRuleSysNo.HasValue ? item.SettlePrice : item.Cost;
                                newVM.ConsignSettlementItemInfoList[index].Cost = vm.Cost;
                            }
                            vm.OrderCount += 1;//订单数量+1
                            vm.AllOrderSysNoFormatString += string.Format("-{0}", item.ConsignToAccLogInfo.LogSysNo);
                            if (vm.AcquireReturnPointType.HasValue)
                            {
                                vm.ContractReturnPointSet = ResConsignNew.InfoMsg_ReturnPointSet;
                                if (vm.AcquireReturnPointType == 0)
                                {
                                    vm.ExpectGetPoint = vm.AcquireReturnPoint * vm.ConsignToAccLogInfo.ProductQuantity;
                                }
                                if (vm.AcquireReturnPointType == 1)
                                {
                                    vm.ExpectGetPoint = vm.AcquireReturnPoint / 100 * vm.ConsignToAccLogInfo.ProductQuantity * (vm.Cost ?? 0m);
                                }
                            }
                        }
                    }
                    index++;
                }
                // 重新计算总金额,毛利总额:
                foreach (var item in tmpmergedItemList)
                {
                    if (item.ContractReturnPointSet == ResConsignNew.InfoMsg_ReturnPointNotSet)
                    {
                        item.ExpectGetPoint = null;
                    }
                    else
                    {
                        if (item.AcquireReturnPointType == 0)
                        {
                            item.ExpectGetPoint = item.ConsignToAccLogInfo.ProductQuantity * item.AcquireReturnPoint;
                        }
                        else
                        {
                            item.ExpectGetPoint = item.ConsignToAccLogInfo.ProductQuantity * item.AcquireReturnPoint * item.Cost.ToDecimal() / 100;
                        }
                    }
                    item.ConsignToAccLogInfo.CountMany       = item.ConsignToAccLogInfo.ProductQuantity * item.Cost.ToDecimal();
                    item.ConsignToAccLogInfo.RateMarginTotal = item.ConsignToAccLogInfo.RateMargin * item.ConsignToAccLogInfo.ProductQuantity;
                }
            }

            this.mergedItemList = tmpmergedItemList;
        }