CommonClass.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:3k
源码类别:
Email客户端
开发平台:
Visual C++
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- /// <summary>
- /// CommonClass 的摘要说明
- /// </summary>
- public class CommonClass
- {
- public CommonClass()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- /// <summary>
- /// 返回一个字符串,方便弹出提示框
- /// </summary>
- /// <param name="str">自定义信息</param>
- /// <returns></returns>
- public static string MessageBox(string str)
- {
- string str1 = "<script language=javascript>alert('" + str + "');</script>";
- return str1;
- }
- /// <summary>
- /// 记录操作日志
- /// </summary>
- /// <param name="Content">操作关键字</param>
- /// <param name="Operate">操作类型控制:0为添加、1为修改、2为删除</param>
- /// <param name="SessionName">操作人员帐号</param>
- public static void WriteNote(string Content,int Operate,string SessionName)
- {
- SqlData da = new SqlData();
- switch (Operate)
- {
- case 0:
- string Insertcmdtxt = "INSERT INTO tb_WorkDo(UserName,OperationTime,OperationClass,OperationContent)";
- Insertcmdtxt += " VALUES('" + SessionName + "','" + DateTime.Now + "','添加','" + Content + "')";
- da.ExceSQL(Insertcmdtxt);
- break;
- case 1:
- string Updatecmdtxt = "INSERT INTO tb_WorkDo(UserName,OperationTime,OperationClass,OperationContent)";
- Updatecmdtxt += " VALUES('" + SessionName + "','" + DateTime.Now + "','修改','" + Content + "')";
- da.ExceSQL(Updatecmdtxt);
- break;
- case 2:
- string Deletecmdtxt = "INSERT INTO tb_WorkDo(UserName,OperationTime,OperationClass,OperationContent)";
- Deletecmdtxt += " VALUES('" + SessionName + "','" + DateTime.Now + "','删除','" + Content + "')";
- da.ExceSQL(Deletecmdtxt);
- break;
- }
- }
- /// <summary>
- /// 过滤文本中的非法字符串
- /// </summary>
- /// <param name="str">要输入的文本</param>
- /// <returns></returns>
- public static string HtmlEncode(string str)
- {
- str = str.Replace("&", "&");
- str = str.Replace("<", "<");
- str = str.Replace(">", ">");
- str = str.Replace("'", "''");
- str = str.Replace("*", "");
- str = str.Replace("n", "<br/>");
- str = str.Replace("rn", "<br/>");
- str = str.Replace("select", "");
- str = str.Replace("insert", "");
- str = str.Replace("update", "");
- str = str.Replace("delete", "");
- str = str.Replace("create", "");
- str = str.Replace("drop", "");
- str = str.Replace("delcare", "");
- if (str.Trim().ToString() == "") { str = "无"; }
- return str.Trim();
- }
- }