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);
      }
     }
    }

  • 相关阅读:
    多元隐函数组求导快速判断自变量和因变量
    jQuery通过ajax方法获取json数据不执行success的原因及解决方法
    JS对于字符串的切割截取
    PHPStorm 解决报错:com.mysql.cj.exceptions.InvalidConnectionAttributeException
    点击checkbox后,$(this).attr('checked')得到的值不会发生改变
    phpstudy等php本地环境运行缓慢的问题解决方法
    HTML5跳转页面并传值以及localStorage的用法
    Js与jQuery的相互转换
    PhpStorm代码编辑区竖线的用途以及如何去掉
    PhpStorm 运行出现502 Bad Gateway
  • 原文地址:https://www.cnblogs.com/admin11/p/213599.html
Copyright © 2011-2022 走看看