Exemplo n.º 1
0
        /// <summary>
        /// 更新礼品卡子项,对应礼品卡具体金额
        /// </summary>
        /// <param name="item"></param>
        public void UpdateGiftCardFabricationItem(GiftCardFabrication item)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("GiftCard_UpdateGiftCardFabricationItem");

            cmd.SetParameterValue <GiftCardFabrication>(item);
            cmd.ExecuteNonQuery();
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidationManager.Validate(this.LayoutRoot))
            {
                return;
            }
            GiftCardFabricationMaster  item = new GiftCardFabricationMaster();
            List <GiftCardFabrication> list = new List <GiftCardFabrication>();

            item             = VM.ConvertVM <GiftCardFabricationVM, GiftCardFabricationMaster>();
            item.CompanyCode = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.CompanyCode;
            bool checkQuantity = false;

            foreach (GiftCardFabricationItemVM gift in gridVM)
            {
                GiftCardFabrication g = new GiftCardFabrication();
                g.Product           = new ProductInfo();
                g.Product.ProductID = gift.ProductID;
                g.Quantity          = gift.Quantity;
                g.Product.SysNo     = gift.ProductSysNo.Value;
                g.MasterSysNo       = VM.SysNo.Value;
                g.SysNo             = gift.SysNo.Value;
                list.Add(g);
                if (gift.Quantity < 0)
                {
                    checkQuantity = false;
                    break;
                }
                if (gift.Quantity > 0)
                {
                    checkQuantity = true;
                }
            }
            if (!checkQuantity)
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert("每种面值的礼品卡数量都不能小于0,并且礼品卡总数量必须大于0!", MessageType.Error);
                return;
            }
            item.GiftCardFabricationList = list;
            facade.UpdateGiftCardFabrications(item, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }
                CPApplication.Current.CurrentPage.Context.Window.Alert(ResGiftCardInfo.Information_OperateSuccessful, MessageType.Information);
                if (Dialog != null)
                {
                    Dialog.ResultArgs.Data         = null;
                    Dialog.ResultArgs.DialogResult = DialogResultType.OK;
                    Dialog.Close();
                }
            });
        }
        /// <summary>
        /// 生成采购单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreatePO_Click(object sender, RoutedEventArgs e)
        {
            GiftCardFabricationMaster  item = new GiftCardFabricationMaster();
            List <GiftCardFabrication> list = new List <GiftCardFabrication>();

            item = VM.ConvertVM <GiftCardFabricationVM, GiftCardFabricationMaster>();

            item.CompanyCode = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.CompanyCode;
            foreach (GiftCardFabricationItemVM gift in gridVM)
            {
                if (gift.Quantity.HasValue && gift.Quantity.Value > 0)
                {
                    GiftCardFabrication g = new GiftCardFabrication();
                    g.Product           = new ProductInfo();
                    g.Product.ProductID = gift.ProductID;
                    g.Quantity          = gift.Quantity;
                    g.Product.SysNo     = gift.ProductSysNo.Value;
                    g.MasterSysNo       = VM.SysNo.Value;
                    g.PMUserSysNo       = gift.PMUserSysNo;
                    list.Add(g);
                }
            }

            if (list.Count > 0)
            {
                item.GiftCardFabricationList = list;
                facade.CreatePOGiftCardFabrication(item, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }

                    if (args.Result != 0)
                    {
                        VM.POSysNo        = args.Result.ToString();
                        hlPOSysNo.Content = VM.POSysNo;
                        CPApplication.Current.CurrentPage.Context.Window.Alert(ResGiftCardInfo.Information_OperateSuccessful, MessageType.Information);
                        if (Dialog != null)
                        {
                            Dialog.ResultArgs.Data         = null;
                            Dialog.ResultArgs.DialogResult = DialogResultType.OK;
                            Dialog.Close();
                        }
                    }
                });
            }
            else
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert(ResGiftCardInfo.Information_NeedGiftQuantity, MessageType.Warning);
            }
        }