Beispiel #1
0
 private void PerformSave <T>(SheetProcessorBase <T> processor, SheetOperation operation) where T : class, ISheet <string>
 {
     if (CheckInput())
     {
         T             sheet = GetItemFromInput() as T;
         CommandResult ret   = processor.ProcessSheet(sheet, operation, Operator.Current.Name, Operator.Current.ID);
         if (ret.Result == ResultCode.Successful)
         {
             UpdatingItem = sheet;
             IsAdding     = false;
             ItemShowing();
             ShowButtonState();
             if (operation == SheetOperation.Create)
             {
                 this.OnItemAdded(new ItemAddedEventArgs(sheet));
             }
             if (operation != SheetOperation.Create)
             {
                 this.OnItemUpdated(new ItemUpdatedEventArgs(sheet));
             }
             MessageBox.Show(string.Format("{0} 成功", SheetOperationDescription.GetDescription(operation)), "确定");
         }
         else
         {
             MessageBox.Show(ret.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #2
0
 protected virtual void PerformOperation <T>(SheetProcessorBase <T> processor, SheetOperation operation) where T : class, ISheet <string>
 {
     if (operation == SheetOperation.Create || operation == SheetOperation.Modify)
     {
         PerformSave <T>(processor, operation);
     }
     else
     {
         if (UpdatingItem != null)
         {
             T sheet = null;
             if (operation == SheetOperation.Create || operation == SheetOperation.Modify)
             {
                 MessageBox.Show("保存请调用 " + "PerformCreateOrModify()");
                 return;
             }
             else
             {
                 sheet = UpdatingItem as T;
                 if (MessageBox.Show(string.Format("是否要进行 {0}?", SheetOperationDescription.GetDescription(operation)),
                                     "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
                 {
                     return;
                 }
             }
             CommandResult ret = processor.ProcessSheet(sheet, operation, Operator.Current.Name, Operator.Current.ID);
             if (ret.Result == ResultCode.Successful)
             {
                 ItemShowing();
                 ShowButtonState();
                 if (operation != SheetOperation.Create)
                 {
                     this.OnItemUpdated(new ItemUpdatedEventArgs(sheet));
                 }
                 MessageBox.Show(string.Format("{0} 成功", SheetOperationDescription.GetDescription(operation)), "确定");
             }
             else
             {
                 MessageBox.Show(ret.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }