zoukankan      html  css  js  c++  java
  • C/S中的MVC(4) 荣

    using System;
    using System.Data;
    using System.Windows.Forms;

    using Business;

    namespace Business.Base
    {
     /// <summary>
     /// Description:窗体的基类。
     /// </summary>
     public class FormBase
     {
      /// <summary>
      /// 存储窗体所需数据的DataSet对象。
      /// </summary>
      protected DataSet dataSet;

      /// <summary>
      /// 取得数据的委托。
      /// </summary>
      protected delegate void SetDataHandler();

      /// <summary>
      /// 处理成功信息的委托。
      /// </summary>
      protected delegate void SucessFunctionHandler();

      /// <summary>
      /// 执行操作的委托。
      /// </summary>
      protected delegate void ActionHandler();

      /// <summary>
      /// 执行操作的委托。
      /// </summary>
      private delegate void ActionParHandler(System.Windows.Forms.Form form, object obj);

      /// <summary>
      /// 取得数据的事件。
      /// </summary>
      protected event SetDataHandler SetDataEvent;

      /// <summary>
      /// 处理成功信息的事件。
      /// </summary>
      protected event SucessFunctionHandler SucessFunctionEvent;

      /// <summary>
      /// 执行操作的事件。
      /// </summary>
      protected event ActionHandler ActionEvent;

      /// <summary>
      /// 执行操作的事件。
      /// </summary>
      private event ActionParHandler ActionParEvent;

      /// <summary>
      /// Description:执行操作。
      /// </summary>
      protected void DoAction()
      {
       try
       {
        //取得数据
        if (SetDataEvent != null)
        {
         SetDataEvent();
        }

        //执行操作
        if (ActionEvent != null)
        {
         ActionEvent();
        }

        //成功后的操作
        if (SucessFunctionEvent != null)
        {
         SucessFunctionEvent();
        }
       }
       catch(Exception ex)
       {
        CommonBN.DealError(ex, "");
       }
       finally
       {
        //清除事件
        SucessFunctionEvent = null;
        SetDataEvent = null;
        ActionEvent = null;
       }
      }

      /// <summary>
      /// Description:执行操作。
      /// </summary>
      private void DoAction(System.Windows.Forms.Form form, object obj)
      {
       try
       {
        //取得数据
        if (SetDataEvent != null)
        {
         SetDataEvent();
        }

        //执行操作
        if (ActionParEvent != null)
        {
         ActionParEvent(form, obj);
        }

        //成功后的操作
        if (SucessFunctionEvent != null)
        {
         SucessFunctionEvent();
        }
       }
       catch(Exception ex)
       {
        CommonBN.DealError(ex , "");
       }
       finally
       {
        //清除事件
        SucessFunctionEvent = null;
        SetDataEvent = null;
        ActionEvent = null;
       }
      }

      /// <summary>
      /// Description:取得窗体的初始数据。
      /// </summary>
      protected void GetInitialData(System.Windows.Forms.Form form, object obj)
      {
       FormFactoryBN bn = new FormFactoryBN();

       //取得初始数据
       bn.InitialData(dataSet, form, obj);
      }

      /// <summary>
      /// Description:初始化控件。
      /// </summary>
      protected virtual void InitialData()
      {
      }

      /// <summary>
      /// Description:窗体初始化执行的操作。
      /// </summary>
      protected void LoadData(System.Windows.Forms.Form form, object obj)
      {
       this.ActionParEvent += new ActionParHandler(GetInitialData);
       this.SucessFunctionEvent += new SucessFunctionHandler(InitialData);
       DoAction(form, obj);
      }
     }
    }

  • 相关阅读:
    回溯法 | 子集树:装载问题
    再谈01背包 | 使用【跳跃点集合】代替【求解矩阵】解题
    线性代数 | 行列式的计算
    慢,也是一种态度
    回溯法 | 图的m着色问题
    回溯法 | 旅行商问题(TSP问题)
    回溯法 | n皇后问题
    基数排序 RadixSort
    03.父工程pom、整合测试、SpringBootApplication注解
    02.自定义banner、全局配置文件、@Value获取自定义配置、@ConfigurationProperties、profiles配置
  • 原文地址:https://www.cnblogs.com/admin11/p/213599.html
Copyright © 2011-2022 走看看