zoukankan      html  css  js  c++  java
  • VS2015按钮方法

    protected void btnRoleMemberAdd_Click(object sender ,EventArgs e)

    {

      txtEmpID.Text=Coeno.utility.string.CleanUpInput(textEmpID.Text.Trim());     --命名空间,类、方法名

      if(string.IsNullorEmpty(DropRoles.SelectedValue.Trim()))

      {

        LabMsg.Text= “无法新增至数据库:请选择一个角色进行新增" 

        LabMsg.ForeColor=System.Drawing.Color.Red;

        return;

      }

      //检查是否有输入员工工号

      if(txtEmpID.Text==" ")

      {

        LabMsg.Text= "请确认是否有输入员工工号!!!" ;

        LabMsg.ForeColor=System.Drawing.Color.Red;

      }

      //检查员工工号是否存在

      if(Coeno.Account.Users.IsEmpIDExist(txtEmpID.Text)==0)

      {

        LabMsg.Text= "员工工号不存在!!!" ;

        LabMsg.ForeColor=System.Drawing.Color.Red;

        return;

      }

      if(Coeno.Main.Roles.IsUserInRole(SystemID,txtEmpID.Text,DorpRoles.SelectedValue))

      {

        LabMsg.Text= "无法新增至数据库:可能您新增的数据已经存在" ;

        LabMsg.ForeColor=System.Drawing.Color.Red;

        Return;

      }

      try

      {

        Coeno.Main.Roles.AddUserInRole(SystemID,DropRoles.SelectedValue,txtEmpID.Text,LabCuser.Text);

        LabMsg.Text= "新增成功" ;

        LabMsg.ForeColor=System.Drawing.Color.Blue;

        return;

      }

      catch(Exception ex)

      {

        LabMsg.Text= "新增失败" ;

        LabMsg.ForeColor=System.Drawing.Color.Red;

        return;

      }

    }

    一、public static string CleanUpInput(string strInput)

    {

      strInput=strInput+" ";

      strInput=strInput.Replace("["," ");

      strInput=strInput.Replace("]" ," ");

      strInput=strInput.Replace("{"," ");

      strInput=strInput.Reaplace("}"," ");

      strInput=strInput.Reaplace(";"," ");

      strInput=strInput.Reaplace("&"," ");

      strInput=strInput.Reaplace("<"," ");

      strInput=strInput.Reaplace(">"," ");

      strInput=strInput.Reaplace(" ' "," ");

      strInput=Coeno.Tools.SDBC.ToDBC(strInput);

      strInput=strInput.Trim();

      return strInput;

    }

    ///全角转半角

    ///转半角的函数(DBC case)

    ///任意字符串

    ///半角字符串

    ///全角空格为12288,半角空格为32

    ///其他字符半角(32-126)与全角(65281-65374)的对应关系是:均相差65248

    public static string ToDBC(string input)

    {

      char[ ] c=input.ToCharArray();

      for(int i =0; i<c.length;i++)

      {

        if(c[i]==12288)

        {

          c[i]=(char)32;continue;

        }

        if(c[i]>65280&&c[i]<65375)

        c[i]=(char)(c[i]-65248);

      }

      return new string(c);

    }

  • 相关阅读:
    OAF 开发,给组件添加javascript事件
    SQL SERVER占用CPU过高优化
    Winform嵌入CEF(非正常用法)
    多线程——i++的坑
    20150819(i++与++i的思考)
    listView中,checkBox的显示和隐藏
    装箱和拆箱
    虚方法
    [转]关于struct的一些解释与class对比
    提取行政区边界经纬度坐标(高德+百度)
  • 原文地址:https://www.cnblogs.com/ximi07/p/10921962.html
Copyright © 2011-2022 走看看