public override void OnPageLoad(object sender, EventArgs e) { base.OnPageLoad(sender, e); _facade = new SaleGiftFacade(this); int tempsysNo = -1; if (this.Request.QueryString != null && this.Request.QueryString.ContainsKey("sysno") && int.TryParse(this.Request.QueryString["sysno"].ToString().Trim(), out tempsysNo)) { currentSysNo = tempsysNo; if (this.Request.QueryString.ContainsKey("operation") && !string.IsNullOrEmpty(this.Request.QueryString["operation"].ToString().Trim())) { _operationType = this.Request.QueryString["operation"].ToString().ToLower(); } } if (_operationType == "edit") { //TODO:判断是否有编辑的权限,如果没有,则将自动变为view权限 } else if (_operationType == "mgt") { } else { } _saleGiftInfoVM.BeginDate = DateTime.Now; _saleGiftInfoVM.EndDate = DateTime.Now.AddDays(1); _facade.Load(currentSysNo, _saleGiftInfoVM, (obj, args) => { _saleGiftInfoVM = args.Result; this.DataContext = _saleGiftInfoVM; SetControlByOperation(); SetCanelAuditByRequest(); _discountBelongSnap = _saleGiftInfoVM.DisCountType; }); }
private void btnSaveBasic_Click(object sender, RoutedEventArgs e) { CPApplication.Current.CurrentPage.Context.Window.MessageBox.Clear(); ValidationManager.Validate(this.ucBasic.gridBasic); if (_saleGiftInfoVM.HasValidationErrors) { return; } if (_saleGiftInfoVM.Type != SaleGiftType.Vendor) { if (string.IsNullOrEmpty(_saleGiftInfoVM.Title)) { _saleGiftInfoVM.ValidationErrors.Add(new ValidationResult(ResSaleGiftMaitain.Msg_RequireTitle, new List <string> { "Title" })); } } if (_saleGiftInfoVM.Type == SaleGiftType.Full) //|| _saleGiftInfoVM.Type == SaleGiftType.FirstOrder || _saleGiftInfoVM.Type == SaleGiftType.Additional) { if (string.IsNullOrEmpty(_saleGiftInfoVM.Description)) { _saleGiftInfoVM.ValidationErrors.Add(new ValidationResult(ResSaleGiftMaitain.Msg_RequireDescription, new List <string> { "Description" })); } if (string.IsNullOrEmpty(_saleGiftInfoVM.OrderCondition.OrderMinAmount)) { _saleGiftInfoVM.ValidationErrors.Add(new ValidationResult(ResSaleGiftMaitain.Msg_RequireOrderMinAmount, new List <string> { "OrderMinAmount" })); } } if (_saleGiftInfoVM.HasValidationErrors) { return; } _saleGiftInfoVM.ValidationErrors.Clear(); bool needReload = false; if (_saleGiftInfoVM.SysNo.HasValue && _saleGiftInfoVM.DisCountType != _discountBelongSnap) { needReload = true; } _facade.SaveMaster(_saleGiftInfoVM, (obj, args) => { _saleGiftInfoVM = args.Result; if (needReload) { _facade.Load(_saleGiftInfoVM.SysNo, _saleGiftInfoVM, (obj1, args1) => { _saleGiftInfoVM = args1.Result; this.DataContext = _saleGiftInfoVM; if (_saleGiftInfoVM.ProductOnlyList != null && _saleGiftInfoVM.ProductOnlyList.Count > 0) { this.ucProductRange.ucLimitProduct.dgProductOnly.ItemsSource = _saleGiftInfoVM.ProductOnlyList; } if (_saleGiftInfoVM.GiftItemList != null && _saleGiftInfoVM.GiftItemList.Count > 0) { this.ucGiftRule.dgGiftProduct.ItemsSource = _saleGiftInfoVM.GiftItemList; } _discountBelongSnap = _saleGiftInfoVM.DisCountType; //Window.Alert("保存成功!"); Window.Alert(ResSaleGiftMaitain.Msg_SaveSuccess); }); } else { _operationType = "edit"; SetControlByOperation(); //Window.Alert("保存成功!"); Window.Alert(ResSaleGiftMaitain.Msg_SaveSuccess); } }); }