自己構造公用程式(2)–訊息處理

來源:互聯網
上載者:User

//===========================================

//項目名稱:

//類名: MsgTool

//建立者: Applegreen

//修改時間:2004-7-22

//內容描述:訊息處理

//===========================================

using System;

using System.Collections;

using System.Web;

using System.Text;

namespace RoleCom

{

 /// <summary>

 /// MsgTool B/S系統中。

 /// </summary>

 public class MsgTool

 {

  private bool m_result=false;

  private string m_message="";

  private ICollection m_append=null;

  /// <summary>

  /// 用來設定和取得結果屬性

  /// </summary>

  public bool Result

  {

   get

   {

    return m_result;

   }

   set

   {

    m_result=value;

   }

  }

  /// <summary>

  /// 用來設定和取得資訊屬性

  /// </summary>

  public string Message

  {

   get

   {

    return m_message;

   }

   set

   {

    m_message=value;

   }

  }

  /// <summary>

  /// 用來設定和取得添加資訊

  /// </summary>

  public ICollection append

  {

   get

   {

    return m_append;

   }

   set

   {

    m_append=value;

   }

  }

  public MsgTool()

  {

  }

  /// <summary>

  ///  建立含結果和提示資訊,還有添加資訊的的訊息工具

  /// </summary>

  /// <param name="b_result">是否成功</param>

  /// <param name="s_message">提示資訊</param>

  /// <param name="append">添加資訊集合</param>

  public MsgTool(bool b_result,string s_message,ICollection append)

  {

   this.m_result=b_result;

   this.m_message=s_message;

   this.m_append=append;

  }

  /// <summary>

  /// 建立含結果和提示資訊的訊息工具

  /// </summary>

  /// <param name="b_result">是否成功</param>

  /// <param name="s_message">提示資訊</param>

  public MsgTool(bool b_result,string s_message)

  {

   this.m_result=b_result;

   this.m_message=s_message;

  }

  

  /// <summary>

  /// 彈出資訊提示

  /// </summary>

  /// <param name="response">封裝來自ASP.NET操作的HTTP響應資訊</param>

  public void MessageBox(HttpResponse response)

  {

   if (m_message!="")

   {

    String msgScript=GetAlertScript(m_message);

    response.Write(msgScript);

   }

  }  

  /// <summary>

  /// 彈出資訊提示

  /// </summary>

  /// <param name="response">封裝來自ASP.NET操作的HTTP響應資訊</param>

  public void MessageWindow(HttpResponse response)

  {

   if (m_message!="")

   {

    MessageBox(response);

   }

  }

  /// <summary>

  /// 返回帶含有提示資訊的指令碼

  /// </summary>

  /// <param name="strMessage">提示資訊</param>

  /// <returns></returns>

  public string  GetAlertScript(string strMessage)

  {   

   strMessage =strMessage.Replace("\n","");

   strMessage =strMessage.Replace("\t","");

   strMessage =strMessage.Replace("\r","");

   strMessage =strMessage.Replace("\"","\\\"");

   return "<script language=\"javascript\">alert(\""+strMessage  +"\");</script>";   

  }

 }

}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.