Example #1
0
        /// <summary>
        /// 逻辑删除
        /// </summary>
        public OPResult DeleteOrder(OrderSearchEntity entity)
        {
            var lp    = VMGlobal.DistributionQuery.LinqOP;
            var order = lp.GetById <BillOrder>(entity.BillID);

            if (order == null)
            {
                return new OPResult {
                           IsSucceed = false, Message = "未找到相应单据."
                }
            }
            ;
            if (order.IsDeleted)
            {
                return new OPResult {
                           IsSucceed = false, Message = "订单已作废."
                }
            }
            ;
            BillOrderChange change = new BillOrderChange
            {
                BillID      = order.ID,
                CreateTime  = DateTime.Now,
                CreatorID   = VMGlobal.CurrentUser.ID,
                Description = "作废订单"
            };

            order.IsDeleted = true;
            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    lp.Update <BillOrder>(order);
                    lp.Add <BillOrderChange>(change);
                    result = new OPResult {
                        IsSucceed = true, Message = "作废成功!"
                    };
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "作废失败,失败原因:\n" + ex.Message
                    };
                }
            }
            if (result.IsSucceed)
            {
                entity.Changes.Insert(0, change);

                var users = GetIMUsers(order.OrganizationID);
                IMHelper.AsyncSendMessageTo(users, new IMessage
                {
                    Message = string.Format("订单{0}被作废.", order.Code)
                }, IMReceiveAccessEnum.订单变动);
            }
            return(result);
        }
Example #2
0
        public override OPResult Save()
        {
            BillRetailBO bo = this.GenerateRetailBO();

            OPResult result = null;

            try
            {
                result = BillWebApiInvoker.Instance.Invoke <OPResult <BillRetail>, BillRetailBO>(bo, "BillRetail/SaveBillRetail");
            }
            catch (Exception ex)
            {
                result = new OPResult {
                    IsSucceed = false, Message = ex.Message
                };
            }

            if (result.IsSucceed)
            {
                this.Master = ((OPResult <BillRetail>)result).Result;

                var users = IMHelper.OnlineUsers.Where(o => o.OrganizationID == OrganizationListVM.CurrentOrganization.ParentID).ToArray();
                IMHelper.AsyncSendMessageTo(users, new IMessage
                {
                    Message = string.Format("{2}销售{0}件,单号{1},金额{3:C}.", Details.Sum(o => o.Quantity), Master.Code, OrganizationListVM.CurrentOrganization.Name, Master.CostMoney)
                }, IMReceiveAccessEnum.零售单);
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// 取消剩余订单
        /// </summary>
        public OPResult CancelLeftOrderQuantity(OrderSearchEntity order)
        {
            var lp     = VMGlobal.DistributionQuery.LinqOP;
            var orders = lp.Search <BillOrderDetails>(o => o.BillID == order.BillID && o.QuaCancel != o.Quantity - o.QuaDelivered).ToList();

            if (orders.Count == 0)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "没有可取消的量."
                });
            }
            int quaCancel = 0;

            orders.ForEach(o =>
            {
                quaCancel  += o.Quantity - o.QuaDelivered - o.QuaCancel;
                o.QuaCancel = o.Quantity - o.QuaDelivered;
            });
            BillOrderChange change = new BillOrderChange
            {
                BillID      = order.BillID,
                CreateTime  = DateTime.Now,
                CreatorID   = VMGlobal.CurrentUser.ID,
                Description = string.Format("取消剩余订单量,取消量{0}件.", quaCancel)
            };
            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    lp.Update <BillOrderDetails>(orders);
                    lp.Add <BillOrderChange>(change);
                    result = new OPResult {
                        IsSucceed = true, Message = "取消成功!"
                    };
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "取消失败,失败原因:\n" + ex.Message
                    };
                }
            }
            if (result.IsSucceed)
            {
                foreach (var d in order.Details)
                {
                    d.QuaCancel = d.Quantity - d.QuaDelivered;
                }
                order.Changes.Insert(0, change);
                var users = GetIMUsers(order.OrganizationID);
                IMHelper.AsyncSendMessageTo(users, new IMessage
                {
                    Message = string.Format("订单{0}剩余量被取消,取消量{1}件.", order.BillCode, quaCancel)
                }, IMReceiveAccessEnum.订单变动);
            }
            return(result);
        }
        private void retailCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Parameter == null)
            {
                return;
            }
            switch (e.Parameter.ToString())
            {
            case "Cash":
                OPResult result = _dataContext.ValidateWhenCash();
                if (!result.IsSucceed)
                {
                    MessageBox.Show(result.Message);
                    return;
                }
                _dataContext.SetRetailData();
                BindingExpression be = txtRemark.GetBindingExpression(TextBox.TextProperty);
                be.UpdateTarget();    //备注可能更改,更新UI
                CashWin wincash = new CashWin(_dataContext);
                wincash.Owner            = View.Extension.UIHelper.GetAncestor <Window>(this);
                wincash.CashScceedEvent += delegate
                {
                    _dataContext.Init();
                    be.UpdateTarget();
                };
                wincash.ShowDialog();
                break;

            case "CashCoupon":
                List <int> brandIDs = new List <int>();
                SysProcessView.UIHelper.TraverseGridViewData <DistributionProductShow>(gvDatas, p => { brandIDs.Add(p.BrandID); });
                CashCouponWin couponwin = new CashCouponWin(brandIDs.Distinct().Select(o => VMGlobal.PoweredBrands.Find(b => b.ID == o)),
                                                            _dataContext.BeforeDiscountCoupon, _dataContext.AfterDiscountCoupon, _dataContext.CouponBrandIDs);
                couponwin.Owner           = View.Extension.UIHelper.GetAncestor <Window>(this);
                couponwin.CouponObtained += new Action <int, int, IEnumerable <int> >(win_CouponObtained);
                couponwin.ShowDialog();
                break;

            case "VIP":
                break;

            case "Back":
                RetailCodeInputWin win = new RetailCodeInputWin(_dataContext);
                win.Owner             = View.Extension.UIHelper.GetAncestor <Window>(this);
                win.SetRetailVMEvent += () =>
                {
                    foreach (var d in _dataContext.GridDataItems)
                    {
                        d.Quantity *= (-1);
                        d.CutMoney *= (-1);
                    }
                    _dataContext.Master.ReceiveTicket = 0;
                    _dataContext.Master.TicketKind    = null;
                    _dataContext.Master.TicketMoney   = 0;
                    //this.DataContext = _dataContext = vm;
                };
                win.ShowDialog();
                break;
            }
        }
Example #5
0
        private async Task <bool> AddLog(string logLevel, string logMessage, string attData, string stackInfo)
        {
            bool flag = false;

            var jsonObj = new
            {
                systemId   = option.SystemId,
                logLevel   = logLevel,
                logMessage = logMessage,
                attData    = attData,
                // stackInfo = stackInfo 如果是异常,消息里已经包含了堆栈了,不用再添加
            };
            string json = JsonHelper.ToJsonString(jsonObj);

            try
            {
                var res = await NetHelper.PostWithJson(option.Url, json);

                OPResult opRes = JsonHelper.FromJsonString <OPResult>(res);
                if (opRes.State == 1)
                {
                    flag = true;
                }
                else
                {
                    WriteOffLineLog(json);
                }
            }
            catch (Exception ex)
            {
                WriteOffLineLog(json, ex);
            }

            return(flag);
        }
Example #6
0
        public OPResult DeleteSKU(int pid, ProStyleChange change)
        {
            var distlp = _queryDistr.LinqOP;
            var manulp = _queryManu.LinqOP;
            var syslp  = _querySys.LinqOP;

            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    distlp.Delete <BillOrderDetails>(o => o.ProductID == pid);
                    manulp.Delete <BillProductExchangeDetails>(o => o.ProductID == pid);
                    manulp.Delete <BillProductPlanDetails>(o => o.ProductID == pid);
                    manulp.Delete <BillSubcontractDetails>(o => o.ProductID == pid);
                    syslp.Delete <ProductUniqueCodeMapping>(o => o.ProductID == pid);
                    syslp.Delete <Product>(o => o.ID == pid);
                    syslp.Add <ProStyleChange>(change);
                    result = new OPResult {
                        IsSucceed = true, Message = "删除成功!"
                    };
                    scope.Complete();
                }
                catch (Exception e)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "删除出错,出错原因:\n" + e.Message + "\n请告知系统管理员,防止出现冗余数据."
                    };
                }
            }
            return(result);
        }
        private OPResult Update(SysOrganizationBO organization)
        {
            var brandIDs = CurrentOrganization.Brands.Select(o => o.ID);
            List <OrganizationBrand> obs = new List <OrganizationBrand>();

            foreach (var b in organization.Brands)
            {
                OrganizationBrand ob = new OrganizationBrand
                {
                    OrganizationID = organization.ID,
                    BrandID        = b.ID,
                    CreatorID      = VMGlobal.CurrentUser.ID,
                    CreateTime     = DateTime.Now
                };
                obs.Add(ob);
            }
            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    LinqOP.Update <SysOrganization>(organization);
                    VMGlobal.SysProcessQuery.LinqOP.Delete <OrganizationBrand>(ob => brandIDs.Contains(ob.BrandID) && ob.OrganizationID == organization.ID);
                    VMGlobal.SysProcessQuery.LinqOP.Add <OrganizationBrand>(obs);
                    scope.Complete();
                    result = new OPResult {
                        IsSucceed = true, Message = "更新成功!"
                    };
                }
                catch (Exception e)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "更新失败,失败原因:\n" + e.Message
                    };
                }
            }
            if (result.IsSucceed)
            {
                int index = VMGlobal.ChildOrganizations.FindIndex(o => o.ID == organization.ID);
                if (organization.Flag)
                {
                    if (index == -1)
                    {
                        VMGlobal.ChildOrganizations.Add(organization);
                    }
                    else
                    {
                        VMGlobal.ChildOrganizations[index] = organization;
                    }
                }
                else if (index != -1)
                {
                    VMGlobal.ChildOrganizations.RemoveAt(index);
                }
                _currentAndChildrenOrganizations = null;
            }
            return(result);
        }
    // 本机号码认证获取 accesscode 成功后通过服务端  check_gateway 接口校验手机号
    public void checkGateWay(OPResult opResult)
    {
        log("checkGateWayThread start");
        //OPResult opResult = obj as OPResult;
        opResult.id_2_sign = Constants.APP_ID_OP;
        string param = JsonUtility.ToJson(opResult, false);

        olManager.Call("requestPost", Constants.CHECK_GATE_WAY, param, 8000, new RequestPostCallback(this, false));
    }
Example #9
0
        public override OPResult Save()
        {
            if (!IsDefectiveReturn && !OrganizationListVM.IsSelfRunShop(Master.OrganizationID))
            {
                var result = this.CheckGoodReturnRate(Master.OrganizationID);
                if (!result.IsSucceed)
                {
                    return(result);
                }
            }
            this.Master.TotalPrice = this.GridDataItems.Sum(o => o.Quantity * o.Price * o.Discount) / 100;//本单退货金额
            this.Master.Quantity   = this.GridDataItems.Sum(o => o.Quantity);
            this.Master.Status     = (int)BillGoodReturnStatusEnum.未审核;
            //this.Master.StorageID = (-1) * StorageID;//入库仓库ID以负数形式保存到数据库,用以后续审核入库
            var details = this.Details = new List <BillGoodReturnDetails>();

            TraverseGridDataItems(p =>
            {
                details.Add(new BillGoodReturnDetails {
                    ProductID = p.ProductID, Quantity = p.Quantity, Discount = p.Discount, Price = p.Price
                });
            });
            if (details.Count == 0)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "没有需要保存的数据"
                });
            }
            OPResult opresult = null;

            if (Master.StorageID == default(int))
            {
                opresult = base.Save();
            }
            else
            {
                opresult = BillWebApiInvoker.Instance.SaveBill <BillGoodReturn, BillGoodReturnDetails>(new BillBO <BillGoodReturn, BillGoodReturnDetails>()
                {
                    Bill    = this.Master,
                    Details = this.Details
                });
            }
            if (opresult.IsSucceed)
            {
                var users = IMHelper.OnlineUsers.Where(o => o.OrganizationID == OrganizationListVM.CurrentOrganization.ParentID).ToArray();
                IMHelper.AsyncSendMessageTo(users, new IMessage
                {
                    Message = string.Format("{2}退货{0}件,单号{1},请注意查收.", Details.Sum(o => o.Quantity), Master.Code, OrganizationListVM.CurrentOrganization.Name)
                }, IMReceiveAccessEnum.退货单);
                this.Init();
            }
            return(opresult);
        }
Example #10
0
        public OPResult Delete(ViewProduct product)
        {
            var distlp = VMGlobal.DistributionQuery.LinqOP;
            var manulp = VMGlobal.ManufacturingQuery.LinqOP;
            var syslp  = VMGlobal.SysProcessQuery.LinqOP;
            var pid    = product.ProductID;

            if (distlp.Any <BillStoringDetails>(o => o.ProductID == pid))
            {
                return new OPResult {
                           IsSucceed = false, Message = "删除失败,该SKU已有入库记录."
                }
            }
            ;
            if (distlp.Any <BillStocktakeDetails>(o => o.ProductID == pid))
            {
                return new OPResult {
                           IsSucceed = false, Message = "删除失败,该SKU已有盘点记录."
                }
            }
            ;

            string         changeMsg = string.Format("SKU码{0}被删除.", product.ProductCode);
            ProStyleChange change    = new ProStyleChange
            {
                CreateTime  = DateTime.Now,
                CreatorID   = VMGlobal.CurrentUser.ID,
                Description = changeMsg,
                StyleID     = product.StyleID
            };
            OPResult result = new OPResult {
                IsSucceed = false, Message = "删除失败!"
            };

            using (ChannelFactory <IBillService> channelFactory = new ChannelFactory <IBillService>("BillSVC"))
            {
                IBillService service = channelFactory.CreateChannel();

                result = service.DeleteSKU(product.ProductID, change);
            }
            if (result.IsSucceed)
            {
                ObservableCollection <ViewProduct> products = (ObservableCollection <ViewProduct>)Entities;
                products.Remove(product);
                IMHelper.AsyncSendMessageTo(IMHelper.OnlineUsers, new IMessage
                {
                    Message = changeMsg
                }, IMReceiveAccessEnum.成品资料变动);
            }
            return(result);
        }
    }
}
Example #11
0
        public OPResult UpdateDetailsCancelQuantity(int did, int quaNew, string skuCode, OrderSearchEntity order)
        {
            var lp      = VMGlobal.DistributionQuery.LinqOP;
            var details = lp.GetById <BillOrderDetails>(did);

            if (quaNew == details.QuaCancel)
            {
                return(new OPResult {
                    IsSucceed = true
                });
            }
            string des = string.Format("SKU[{2}]取消量从{0}件改动为{1}件", details.QuaCancel, quaNew, skuCode);

            details.QuaCancel = quaNew;
            BillOrderChange change = new BillOrderChange
            {
                BillID      = details.BillID,
                CreateTime  = DateTime.Now,
                CreatorID   = VMGlobal.CurrentUser.ID,
                Description = des
            };
            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    lp.Update <BillOrderDetails>(details);
                    lp.Add <BillOrderChange>(change);
                    result = new OPResult {
                        IsSucceed = true, Message = "改动成功!"
                    };
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "改动失败,失败原因:\n" + ex.Message
                    };
                }
            }
            if (result.IsSucceed)
            {
                order.Changes.Insert(0, change);
                var users = GetIMUsers(order.OrganizationID);
                IMHelper.AsyncSendMessageTo(users, new IMessage
                {
                    Message = string.Format("订单{0}" + des, order.BillCode)
                }, IMReceiveAccessEnum.订单变动);
            }
            return(result);
        }
        /// <summary>
        /// 获取token失败回调
        /// </summary>
        /// <param name="result">json 格式返回结果</param>
        public void onTokenSuccess(string result)
        {
            owner.log("OnePassPluginCallback onTokenSuccess, result=" + result);
            OPResult opResult = JsonUtility.FromJson <OPResult>(result);

            owner.log("OnePassPluginCallback onTokenSuccess, opResult=" + opResult);
            owner.log("本机号认证取号成功: process_id=" + opResult.process_id +
                      ", accesscode=" + opResult.accesscode +
                      ", phone=" + owner.inputField.text +
                      ", id_2_sign=" + Constants.APP_ID_OP +
                      ", timestamp=" + DateTime.Now.Ticks);
            // 获取 Token 成功后用以上五个参数请求服务端 check_gateway 接口校验手机号,当前 demo 略
            owner.checkGateWay(opResult);
        }
Example #13
0
        public OPResult Auditing(BillGoodReturnForSearch bill)
        {
            var lp = VMGlobal.DistributionQuery.LinqOP;
            var gr = lp.GetById <BillGoodReturn>(bill.ID);

            if (gr.Status != (int)BillGoodReturnStatusEnum.未审核)
            {
                return new OPResult {
                           IsSucceed = false, Message = "该单据已审核"
                }
            }
            ;
            gr.Status = (int)BillGoodReturnStatusEnum.在途中;

            OPResult result = null;

            try
            {
                lp.Update <BillGoodReturn>(gr);

                result = new OPResult {
                    IsSucceed = true, Message = "审核成功!"
                };
            }
            catch (Exception ex)
            {
                result = new OPResult {
                    IsSucceed = false, Message = ex.Message
                };
            }
            if (result.IsSucceed)
            {
                ObservableCollection <BillGoodReturnForSearch> entities = this.Entities as ObservableCollection <BillGoodReturnForSearch>;
                if (entities != null)
                {
                    entities.Remove(bill);
                }
            }
            return(result);
        }
Example #14
0
        public OPResult Login(string userCode, string password)
        {
            OPResult result = new OPResult {
                IsSucceed = false, Message = "登录失败."
            };
            var user = UserLogic.GetUserWhenLogin(userCode, password);

            if (user != null)
            {
                VMGlobal.CurrentUser = new SysUserBO(user);
                IMHelper.RegisterToIM();
                //IMHelper.StartService();
                WelcomeMessage = string.Format("当前登录用户: [{0}]{1}", user.Code, user.Name);
                OnPropertyChanged("WelcomeMessage");
                _menuTreeVM = new MenuTreeVM();
                OnPropertyChanged("MenuTreeVM");
                result.IsSucceed = true;
            }
            if (CustomerInfo == null || !CustomerInfo.Name.Contains("tx"))
            {
                throw new Exception("非授权客户");
            }
            return(result);
        }
        public override OPResult Save()
        {
            Master.OrganizationID = VMGlobal.CurrentUser.OrganizationID;
            Details = new List <BillProductExchangeDetails>();
            TraverseGridDataItems(p =>
            {
                Details.Add(new BillProductExchangeDetails {
                    ProductID = p.ProductID, Quantity = p.Quantity
                });
            });
            if (Details.Count == 0)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "没有需要保存的数据"
                });
            }
            OPResult opresult = new OPResult {
                IsSucceed = false, Message = "保存失败!"
            };

#if UniqueCode
            Master.CreateTime = DateTime.Now;
            Master.CreatorID  = VMGlobal.CurrentUser.ID;
            Master.Code       = this.GenerateBillCode();
            BillSnapshot snapshot = new BillSnapshot
            {
                CreateTime       = Master.CreateTime,
                CreatorName      = VMGlobal.CurrentUser.Name,
                OrganizationName = OrganizationListVM.CurrentOrganization.Name,
                BillCode         = Master.Code,
                Remark           = Master.Remark
            };
            var typeField    = typeof(BillTypeEnum).GetField(typeof(BillProductExchange).Name);
            var displayNames = typeField.GetCustomAttributes(typeof(EnumDescriptionAttribute), false);
            snapshot.BillTypeName = ((EnumDescriptionAttribute)displayNames[0]).Description;
            var snapshotDetails = this.GetUniqueCodes();

            using (ChannelFactory <IBillService> channelFactory = new ChannelFactory <IBillService>("BillSVC"))
            {
                IBillService service = channelFactory.CreateChannel();
                opresult = service.SaveProductExchangeBill(((BillProductExchangeBO)Master).ConvertToBase(), Details, snapshot, snapshotDetails);
            }
#else
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    base.SaveWithNoTran();
                    foreach (var d in Details)
                    {
                        this.UpdateSubcontractWhenExchange(Master.OuterFactoryID, d.ProductID, d.Quantity);
                    }
                    scope.Complete();
                }
                catch (Exception e)
                {
                    opresult = new OPResult {
                        IsSucceed = false, Message = e.Message
                    };
                }
            }
            opresult = new OPResult {
                IsSucceed = true, Message = "保存成功."
            };
#endif
            return(opresult);

            //using (TransactionScope scope = new TransactionScope())
            //{
            //    try
            //    {
            //        base.SaveWithNoTran();
            //        Details.ForEach(d => this.UpdateSubcontractWhenExchange(Master.OuterFactoryID, d.ProductID, d.Quantity));
            //        scope.Complete();
            //    }
            //    catch (Exception e)
            //    {
            //        return new OPResult { IsSucceed = false, Message = e.Message };
            //    }
            //}
            //return new OPResult { IsSucceed = true, Message = "保存成功." };
        }
Example #16
0
        private OPResult Update(ProStyleBO style)
        {
            SetStyleBYQ(style);
            ProStyle       orginStyle    = LinqOP.GetById <ProStyle>(style.ID);
            List <Product> productsExist = LinqOP.Search <Product>(p => p.StyleID == style.ID).ToList();
            List <Product> products      = new List <Product>();

            foreach (var color in style.Colors)
            {
                foreach (var size in style.Sizes)
                {
                    var     pcode   = style.Code + color.Code + size.Code;
                    Product product = productsExist.FirstOrDefault(p => p.ColorID == color.ID && p.SizeID == size.ID);
                    if (product != null)
                    {
                        if (orginStyle.Code != style.Code)
                        {
                            product.Code = pcode;
                            products.Add(product);
                        }
                    }
                    else
                    {
                        product = new Product
                        {
                            Code      = pcode,
                            StyleID   = style.ID,
                            ColorID   = color.ID,
                            SizeID    = size.ID,
                            CreatorID = VMGlobal.CurrentUser.ID
                        };
                        products.Add(product);
                    }
                }
            }

            string changeMsg = "";

            if (orginStyle.Price != style.Price)
            {
                changeMsg += string.Format("单价从{0}变动为{1},", orginStyle.Price, style.Price);
            }
            if (orginStyle.Code != style.Code)
            {
                changeMsg += string.Format("款号从{0}变动为{1},", orginStyle.Code, style.Code);
            }
            if (products.Count > 0)
            {
                changeMsg += "增加了SKU码:";
                products.ForEach(o =>
                {
                    changeMsg += (o.Code + ",");
                });
            }
            changeMsg = changeMsg.TrimEnd(',');

            OPResult result = null;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    LinqOP.Update <ProStyle>(style);
                    LinqOP.AddOrUpdate <Product>(products);
                    if (!string.IsNullOrEmpty(changeMsg))
                    {
                        ProStyleChange change = new ProStyleChange
                        {
                            CreateTime  = DateTime.Now,
                            CreatorID   = VMGlobal.CurrentUser.ID,
                            Description = changeMsg,
                            StyleID     = style.ID
                        };
                        LinqOP.Add <ProStyleChange>(change);
                        style.Changes.Insert(0, change);
                    }
                    result = new OPResult {
                        IsSucceed = true, Message = "更新成功!"
                    };
                    scope.Complete();
                }
                catch (Exception e)
                {
                    result = new OPResult {
                        IsSucceed = false, Message = "更新失败,失败原因:\n" + e.Message
                    };
                }
            }
            if (result.IsSucceed && !string.IsNullOrEmpty(changeMsg))
            {
                IMHelper.AsyncSendMessageTo(IMHelper.OnlineUsers, new IMessage
                {
                    Message = changeMsg
                }, IMReceiveAccessEnum.成品资料变动);
            }
            return(result);
        }
Example #17
0
        private void retailCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Parameter == null)
            {
                return;
            }
            switch (e.Parameter.ToString())
            {
            case "Cash":
                OPResult result = _dataContext.ValidateWhenCash();
                if (!result.IsSucceed)
                {
                    MessageBox.Show(result.Message);
                    return;
                }
                result = _dataContext.ValidateVIPBirthdayConsumption();
                if (!result.IsSucceed)
                {
                    var diaResult = MessageBox.Show(result.Message + "\n确认继续吗?\n(注意:点击确认将以正常VIP折扣消费,取消可返回修改单据明细.)", "提示", MessageBoxButton.OKCancel);
                    if (diaResult == MessageBoxResult.OK)
                    {
                        _dataContext.ClearVIPBirthdayDiscount();
                    }
                    else
                    {
                        return;
                    }
                }
                _dataContext.SetRetailData();
                BindingExpression be = txtRemark.GetBindingExpression(TextBox.TextProperty);
                be.UpdateTarget();    //备注可能更改,更新UI
                CashWin wincash = new CashWin(_dataContext);
                wincash.Owner            = View.Extension.UIHelper.GetAncestor <Window>(this);
                wincash.CashScceedEvent += delegate
                {
                    _dataContext.Init();
                    be.UpdateTarget();
                };
                wincash.ShowDialog();
                break;

            case "CashCoupon":
                List <int> brandIDs = new List <int>();
                SysProcessView.UIHelper.TraverseGridViewData <DistributionProductShow>(gvDatas, p => { brandIDs.Add(p.BrandID); });
                CashCouponWin couponwin = new CashCouponWin(brandIDs.Distinct().Select(o => VMGlobal.PoweredBrands.Find(b => b.ID == o)),
                                                            _dataContext.BeforeDiscountCoupon, _dataContext.AfterDiscountCoupon, _dataContext.CouponBrandIDs);
                couponwin.Owner           = View.Extension.UIHelper.GetAncestor <Window>(this);
                couponwin.CouponObtained += new Action <int, int, IEnumerable <int> >(win_CouponObtained);
                couponwin.ShowDialog();
                break;

            case "VIP":
                this.SetVIPInfo();
                break;

            case "Hold":
                if (_holdRetails == null)
                {
                    _holdRetails = new ObservableCollection <HoldRetailEntity>();
                }
                _holdRetails.Add(new HoldRetailEntity {
                    CreateTime = DateTime.Now, HoldRetail = _dataContext, Code = this.GenerateHoldRetailCode()
                });
                this.DataContext = _dataContext = new BillRetailVM();
                break;

            case "Fetch":
                if (_holdRetails == null || _holdRetails.Count == 0)
                {
                    MessageBox.Show("没有挂单.");
                    return;
                }
                FetchRetailBillWin winFetch = new FetchRetailBillWin();
                winFetch.DataContext       = _holdRetails;
                winFetch.Owner             = View.Extension.UIHelper.GetAncestor <Window>(this);
                winFetch.FetchRetailEvent += hr => { this.DataContext = _dataContext = (BillRetailVM)hr.HoldRetail; };
                winFetch.ShowDialog();
                break;

            case "Back":
                RetailCodeInputWin win = new RetailCodeInputWin();
                win.Owner             = View.Extension.UIHelper.GetAncestor <Window>(this);
                win.GetRetailVMEvent += vm =>
                {
                    foreach (var d in vm.GridDataItems)
                    {
                        d.Quantity *= (-1);
                        d.CutMoney *= (-1);
                    }
                    vm.Master.ReceiveTicket = 0;
                    vm.Master.TicketKind    = null;
                    vm.Master.TicketMoney   = 0;
                    this.DataContext        = _dataContext = vm;
                };
                win.ShowDialog();
                break;
            }
        }