⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commop.cs

📁 asp.net 2.0的教务管理软件源码
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
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>
/// Common 的摘要说明
/// </summary>
public static class CommOp
{
    /// <summary>
    /// 判断是否是数字
    /// </summary>
    /// <param name="str">字符串</param>
    /// <returns></returns>
    public static bool IsNumeric(string str)
    {
        if (str == null || str.Length == 0)
            return false;
        System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
        byte[] bytestr = ascii.GetBytes(str);
        foreach (byte c in bytestr)
        {
            if (c < 48 || c > 57)
            {
                return false;
            }
        }
        return true;
    }

    public static int ToInt(object s)
    {
        int i = 0;
        if (s == null) return 0;
        if (int.TryParse(s.ToString(),out i)) return i;
        else return 0;
    }

    public static string ToStr(object s)
    {
        if (s == null) return "";
        return s.ToString().Trim();
    }

    public static string ToDateStr(object s)
    {
        if (s == null) return "";
        DateTime d;
        if (DateTime.TryParse(s.ToString(), out d)) return d.ToShortDateString();
        else return "";
    }

    public static void ShowError(string errType)
    {
        string errs ;
        switch (errType)
        {
            case "Delete_Department_Error": errs = "您不能删除该部门.<br />因为该部门非空或者还有下级部门."; 
                throw new Exception(errs); 
            case "Delete_Employee_Error": errs = "您不能删除该员工.<br />因为该员工是某部门的领导."; 
                throw new Exception(errs); 
            case "Delete_KeyWord_Error": errs = "您不能删除该关键字. <br />该关键字可能正在使用中或者还有下级分类.";
                throw new Exception(errs); 
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -