Ejemplo n.º 1
0
        //保存
        private void Btn_Save_Click(object sender, EventArgs e)
        {
            D_User UsersItem = new D_User();
            UsersItem.Code = this.Tb_Code.Text.Trim();
            UsersItem.Name = this.Tb_Name.Text.Trim();
            UsersItem.Uid = this.Tb_Uid.Text.Trim();
            UsersItem.Pwd = this.Tb_Pwd.Text.Trim();
            UsersItem.Role = this.Cmb_Role.SelectedValue.ToString();
            UsersItem.Used = this.Cb_Used.Checked;

            if (UsersItem.Code == "" || UsersItem.Name == "" || UsersItem.Uid == "" || UsersItem.Pwd == "")
            {
                Function.MessageWarning("请把数据填写完整!");
                return;
            }
            if (UsersItem.Role == "0")
            {
                Function.MessageWarning("请选择用户角色!");
                return;
            }
            if (!Function.IsRegEx("^[a-zA-Z0-9]{2,12}$", UsersItem.Uid))
            {
                Function.MessageWarning("用户名必须是2-12位的字母或数字!");
                return;
            }
            if (!Function.IsRegEx("^[a-zA-Z0-9]{3,32}$", UsersItem.Pwd))
            {
                Function.MessageWarning("用户密码格式不正确,应是3-12位的字母或数字!");
                return;
            }
            if (Function.CheckKey("D_User", "Code", UsersItem.Code, Id))
            {
                Function.MessageWarning("该编号已存在!");
                return;
            }
            if (Function.CheckKey("D_User", "Uid", UsersItem.Uid, Id))
            {
                Function.MessageWarning("该用户名已存在!");
                return;
            }
            UsersItem.Pwd = BaseClass.Function.Md5(UsersItem.Pwd);
            if (Id== 0)
            {
                if (UsersBLL.Insert(UsersItem))
                {
                    Function.Message("添加成功!");
                    ResetData();
                    DataBind();
                }
            }
            else
            {
                UsersItem.Id = Id;
                if (UsersBLL.Update(UsersItem))
                {
                    Function.Message("修改成功!");
                    DataBind();
                }
            }
        }
Ejemplo n.º 2
0
 //保存
 private void Btn_Save_Click(object sender, EventArgs e)
 {
     D_User UsersItem = new D_User();
     UsersItem.Id = LUser.Id;
     UsersItem.OldPwd = this.Tb_OldPwd.Text.Trim().Replace("'", "");
     UsersItem.Pwd = this.Tb_Pwd.Text.Trim().Replace("'", "");
     UsersItem.CheckPwd = this.Tb_CheckPwd.Text.Trim().Replace("'", "");
     if (UsersItem.OldPwd == "" || UsersItem.Pwd == "" || UsersItem.CheckPwd == "")
     {
         Function.MessageWarning("请把信息填写完整!");
         return;
     }
     if (!UsersBLL.CheckPwd(Function.Md5(UsersItem.OldPwd)))
     {
         Function.MessageWarning("原始密码不正确!");
         return;
     }
     if (!Function.IsRegEx("^[a-zA-Z0-9]{3,32}$", UsersItem.Pwd))
     {
         Function.MessageWarning("用户密码格式不正确,应是3-12位的字母或数字!");
         return;
     }
     if (UsersItem.Pwd != UsersItem.CheckPwd)
     {
         Function.MessageWarning("两次输入密码不一致!");
         return;
     }
     UsersItem.Pwd = Function.Md5(UsersItem.Pwd);
     if (UsersBLL.RePwd(UsersItem)) { Function.Message("密码修改成功!"); this.Close(); }
 }
Ejemplo n.º 3
0
 //��½
 private void Btn_Login_Click(object sender, EventArgs e)
 {
     D_User UsersItem = new D_User();
     UsersItem.Uid = this.Tb_Uid.Text.Trim();
     UsersItem.Pwd = this.Tb_Pwd.Text.Trim();
     if (UsersItem.Uid == "" || UsersItem.Pwd == "")
     {
         Function.MessageWarning("�û��������벻����Ϊ�գ�");
         return;
     }
     UsersItem.Pwd = Function.Md5(UsersItem.Pwd);
     if (UsersBLL.UserLogin(UsersItem))
     {
         BLL.PublicFun.IniFile Ini = new BLL.PublicFun.IniFile(WSV.Model.FilePath.Config);
         if (Ini.ExistIniFile())
         {
             Ini.IniWriteValue("systemload", "username", Tb_Uid.Text);
         }
         this.DialogResult = DialogResult.OK;
     }
     else
     {
         Function.MessageWarning("�û��������벻��ȷ��");
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 用户登陆
        /// </summary>
        /// <param name="Item">model</param>
        /// <returns></returns>
        public static bool UserLogin(D_User Item)
        {
            DataBase db = new DataBase();
            DataBaseVisitor visitor = new UsersDAL();
            bool Flag = false;
            SqlParameter[] prams ={
                db.MakeInParam("@Uid",SqlDbType.VarChar,50,Item.Uid),
                db.MakeInParam("@Pwd",SqlDbType.VarChar,50,Item.Pwd)
            };
            try
            {
                DataSet ds = new DataSet();
                ds = db.ReturnDataSet(visitor, prams, "UserLogin");
                DataRowCollection drc = ds.Tables[0].Rows;
                if (drc.Count > 0)
                {
                    DataRow dr = drc[0];
                    CUser.Id = Convert.ToInt64(dr["Id"]);
                    CUser.Code = dr["Code"].ToString();
                    CUser.Uid = dr["Uid"].ToString();
                    CUser.Name = dr["Name"].ToString();
                    CUser.Role = dr["Role"].ToString();
                    //PublicFun.IniFile Ini = new PublicFun.IniFile(WSV.Model.FilePath.Config);
                    //if (Ini.ExistIniFile())
                    //{
                    //    LUser.TableNum = Ini.IniReadValue("LoadoMeter", "TableNum");
                    //}
                    //ds = WSV.BLL.SysInfo.LoadoMeterBLL.SelectAll(" where TableNum='" + LUser.TableNum + "'");
                    //drc = ds.Tables[0].Rows;
                    //if (drc.Count > 0)
                    //{
                    //    dr = drc[0];
                    //    LUser.TableName = dr["Name"].ToString();
                    //    LUser.Ip = dr["Ip"].ToString();
                    //    LUser.Port = dr["Port"].ToString();
                    //}
                    //else
                    //{
                    //    LUser.TableNum = "";
                    //}
                    Flag = true;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.Dispose();
            }
            return Flag;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="Item">model</param>
 /// <returns></returns>
 public static bool Update(D_User Item)
 {
     DataBase db = new DataBase();
     DataBaseVisitor visitor = new UsersDAL();
     bool Flag= false,ReFlag=false;
     int N= 0;
     SqlParameter[] prams ={
         db.MakeInParam("@Code", SqlDbType.VarChar,50, Item.Code),
         db.MakeInParam("@Name", SqlDbType.VarChar,50, Item.Name),
         db.MakeInParam("@Uid", SqlDbType.VarChar,50, Item.Uid),
         db.MakeInParam("@Pwd", SqlDbType.VarChar,50, Item.Pwd),
         db.MakeInParam("@Role", SqlDbType.VarChar,50, Item.Role),
         db.MakeInParam("@Used", SqlDbType.Bit,0, Item.Used),
         db.MakeInParam("@Id", SqlDbType.BigInt,0,Item.Id)
     };
     try
     {
         ReFlag= db.TransactSql(visitor, "Update", prams, out N);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         db.Dispose();
     }
     if (ReFlag && N > 0)
     {
         Flag = true;
     }
     return Flag;
 }