首页 技术 正文
技术 2022年11月15日
0 收藏 956 点赞 4,906 浏览 1920 个字

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

}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848