Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WSS.Model.Users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Users set ");
            strSql.Append("F_UserName=@F_UserName,");
            strSql.Append("F_PassWord=@F_PassWord,");
            strSql.Append("F_DepartID=@F_DepartID,");
            strSql.Append("F_RoleID=@F_RoleID,");
            strSql.Append("F_Sex=@F_Sex,");
            strSql.Append("F_Birthday=@F_Birthday,");
            strSql.Append("F_Email=@F_Email,");
            strSql.Append("F_MobilePhone=@F_MobilePhone,");
            strSql.Append("F_RegTime=@F_RegTime,");
            strSql.Append("F_LastInTime=@F_LastInTime,");
            strSql.Append("F_IsUsed=@F_IsUsed");
            strSql.Append(" where F_UserID=@F_UserID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_UserName",    SqlDbType.NChar,          16),
                new SqlParameter("@F_PassWord",    SqlDbType.Char,           32),
                new SqlParameter("@F_DepartID",    SqlDbType.Int,             4),
                new SqlParameter("@F_RoleID",      SqlDbType.Int,             4),
                new SqlParameter("@F_Sex",         SqlDbType.Bit,             1),
                new SqlParameter("@F_Birthday",    SqlDbType.SmallDateTime),
                new SqlParameter("@F_Email",       SqlDbType.NChar,          50),
                new SqlParameter("@F_MobilePhone", SqlDbType.Char,           13),
                new SqlParameter("@F_RegTime",     SqlDbType.SmallDateTime),
                new SqlParameter("@F_LastInTime",  SqlDbType.SmallDateTime),
                new SqlParameter("@F_IsUsed",      SqlDbType.Bit,             1),
                new SqlParameter("@F_UserID",      SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.F_UserName;
            parameters[1].Value  = model.F_PassWord;
            parameters[2].Value  = model.F_DepartID;
            parameters[3].Value  = model.F_RoleID;
            parameters[4].Value  = model.F_Sex;
            parameters[5].Value  = model.F_Birthday;
            parameters[6].Value  = model.F_Email;
            parameters[7].Value  = model.F_MobilePhone;
            parameters[8].Value  = model.F_RegTime;
            parameters[9].Value  = model.F_LastInTime;
            parameters[10].Value = model.F_IsUsed;
            parameters[11].Value = model.F_UserID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 private void ShowInfo(int F_UserID)
 {
     WSS.BLL.Users   bll   = new WSS.BLL.Users();
     WSS.Model.Users model = bll.GetModel(F_UserID);
     this.lblF_UserID.Text      = model.F_UserID.ToString();
     this.lblF_UserName.Text    = model.F_UserName;
     this.lblF_PassWord.Text    = model.F_PassWord;
     this.lblF_DepartID.Text    = model.F_DepartID.ToString();
     this.lblF_RoleID.Text      = model.F_RoleID.ToString();
     this.lblF_Sex.Text         = model.F_Sex?"ÊÇ":"·ñ";
     this.lblF_Birthday.Text    = model.F_Birthday.ToString();
     this.lblF_Email.Text       = model.F_Email;
     this.lblF_MobilePhone.Text = model.F_MobilePhone;
     this.lblF_RegTime.Text     = model.F_RegTime.ToString();
     this.lblF_LastInTime.Text  = model.F_LastInTime.ToString();
     this.lblF_IsUsed.Text      = model.F_IsUsed?"ÊÇ":"·ñ";
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WSS.Model.Users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Users(");
            strSql.Append("F_UserName,F_PassWord,F_DepartID,F_RoleID,F_Sex,F_Birthday,F_Email,F_MobilePhone,F_RegTime,F_LastInTime,F_IsUsed)");
            strSql.Append(" values (");
            strSql.Append("@F_UserName,@F_PassWord,@F_DepartID,@F_RoleID,@F_Sex,@F_Birthday,@F_Email,@F_MobilePhone,@F_RegTime,@F_LastInTime,@F_IsUsed)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_UserName",    SqlDbType.NChar,          16),
                new SqlParameter("@F_PassWord",    SqlDbType.Char,           32),
                new SqlParameter("@F_DepartID",    SqlDbType.Int,             4),
                new SqlParameter("@F_RoleID",      SqlDbType.Int,             4),
                new SqlParameter("@F_Sex",         SqlDbType.Bit,             1),
                new SqlParameter("@F_Birthday",    SqlDbType.SmallDateTime),
                new SqlParameter("@F_Email",       SqlDbType.NChar,          50),
                new SqlParameter("@F_MobilePhone", SqlDbType.Char,           13),
                new SqlParameter("@F_RegTime",     SqlDbType.SmallDateTime),
                new SqlParameter("@F_LastInTime",  SqlDbType.SmallDateTime),
                new SqlParameter("@F_IsUsed",      SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.F_UserName;
            parameters[1].Value  = model.F_PassWord;
            parameters[2].Value  = model.F_DepartID;
            parameters[3].Value  = model.F_RoleID;
            parameters[4].Value  = model.F_Sex;
            parameters[5].Value  = model.F_Birthday;
            parameters[6].Value  = model.F_Email;
            parameters[7].Value  = model.F_MobilePhone;
            parameters[8].Value  = model.F_RegTime;
            parameters[9].Value  = model.F_LastInTime;
            parameters[10].Value = model.F_IsUsed;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WSS.Model.Users GetModel(int F_UserID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 F_UserID,F_UserName,F_PassWord,F_DepartID,F_RoleID,F_Sex,F_Birthday,F_Email,F_MobilePhone,F_RegTime,F_LastInTime,F_IsUsed from T_Users ");
            strSql.Append(" where F_UserID=@F_UserID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_UserID", SqlDbType.Int, 4)
            };
            parameters[0].Value = F_UserID;

            WSS.Model.Users model = new WSS.Model.Users();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["F_UserID"].ToString() != "")
                {
                    model.F_UserID = int.Parse(ds.Tables[0].Rows[0]["F_UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_UserName"] != null)
                {
                    model.F_UserName = ds.Tables[0].Rows[0]["F_UserName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_PassWord"] != null)
                {
                    model.F_PassWord = ds.Tables[0].Rows[0]["F_PassWord"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_DepartID"].ToString() != "")
                {
                    model.F_DepartID = int.Parse(ds.Tables[0].Rows[0]["F_DepartID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RoleID"].ToString() != "")
                {
                    model.F_RoleID = int.Parse(ds.Tables[0].Rows[0]["F_RoleID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_Sex"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["F_Sex"].ToString() == "1") || (ds.Tables[0].Rows[0]["F_Sex"].ToString().ToLower() == "true"))
                    {
                        model.F_Sex = true;
                    }
                    else
                    {
                        model.F_Sex = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["F_Birthday"].ToString() != "")
                {
                    model.F_Birthday = DateTime.Parse(ds.Tables[0].Rows[0]["F_Birthday"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_Email"] != null)
                {
                    model.F_Email = ds.Tables[0].Rows[0]["F_Email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_MobilePhone"] != null)
                {
                    model.F_MobilePhone = ds.Tables[0].Rows[0]["F_MobilePhone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_RegTime"].ToString() != "")
                {
                    model.F_RegTime = DateTime.Parse(ds.Tables[0].Rows[0]["F_RegTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_LastInTime"].ToString() != "")
                {
                    model.F_LastInTime = DateTime.Parse(ds.Tables[0].Rows[0]["F_LastInTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_IsUsed"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["F_IsUsed"].ToString() == "1") || (ds.Tables[0].Rows[0]["F_IsUsed"].ToString().ToLower() == "true"))
                    {
                        model.F_IsUsed = true;
                    }
                    else
                    {
                        model.F_IsUsed = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(WSS.Model.Users model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(WSS.Model.Users model)
 {
     return(dal.Add(model));
 }
Пример #7
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <WSS.Model.Users> DataTableToList(DataTable dt)
        {
            List <WSS.Model.Users> modelList = new List <WSS.Model.Users>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                WSS.Model.Users model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new WSS.Model.Users();
                    if (dt.Rows[n]["F_UserID"].ToString() != "")
                    {
                        model.F_UserID = int.Parse(dt.Rows[n]["F_UserID"].ToString());
                    }
                    model.F_UserName = dt.Rows[n]["F_UserName"].ToString();
                    model.F_PassWord = dt.Rows[n]["F_PassWord"].ToString();
                    if (dt.Rows[n]["F_DepartID"].ToString() != "")
                    {
                        model.F_DepartID = int.Parse(dt.Rows[n]["F_DepartID"].ToString());
                    }
                    if (dt.Rows[n]["F_RoleID"].ToString() != "")
                    {
                        model.F_RoleID = int.Parse(dt.Rows[n]["F_RoleID"].ToString());
                    }
                    if (dt.Rows[n]["F_Sex"].ToString() != "")
                    {
                        if ((dt.Rows[n]["F_Sex"].ToString() == "1") || (dt.Rows[n]["F_Sex"].ToString().ToLower() == "true"))
                        {
                            model.F_Sex = true;
                        }
                        else
                        {
                            model.F_Sex = false;
                        }
                    }
                    if (dt.Rows[n]["F_Birthday"].ToString() != "")
                    {
                        model.F_Birthday = DateTime.Parse(dt.Rows[n]["F_Birthday"].ToString());
                    }
                    model.F_Email       = dt.Rows[n]["F_Email"].ToString();
                    model.F_MobilePhone = dt.Rows[n]["F_MobilePhone"].ToString();
                    if (dt.Rows[n]["F_RegTime"].ToString() != "")
                    {
                        model.F_RegTime = DateTime.Parse(dt.Rows[n]["F_RegTime"].ToString());
                    }
                    if (dt.Rows[n]["F_LastInTime"].ToString() != "")
                    {
                        model.F_LastInTime = DateTime.Parse(dt.Rows[n]["F_LastInTime"].ToString());
                    }
                    if (dt.Rows[n]["F_IsUsed"].ToString() != "")
                    {
                        if ((dt.Rows[n]["F_IsUsed"].ToString() == "1") || (dt.Rows[n]["F_IsUsed"].ToString().ToLower() == "true"))
                        {
                            model.F_IsUsed = true;
                        }
                        else
                        {
                            model.F_IsUsed = false;
                        }
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtF_UserName.Text.Trim().Length == 0)
            {
                strErr += "用户名不能为空!\\n";
            }
            if (this.txtF_PassWord.Text.Trim().Length == 0)
            {
                strErr += "密码不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtF_DepartID.Text))
            {
                strErr += "所属部门格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtF_RoleID.Text))
            {
                strErr += "角色名格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtF_Birthday.Text))
            {
                strErr += "生日格式错误!\\n";
            }
            if (this.txtF_Email.Text.Trim().Length == 0)
            {
                strErr += "邮箱不能为空!\\n";
            }
            if (this.txtF_MobilePhone.Text.Trim().Length == 0)
            {
                strErr += "移动电话不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtF_RegTime.Text))
            {
                strErr += "注册时间格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtF_LastInTime.Text))
            {
                strErr += "最后登录时间格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   F_UserName    = this.txtF_UserName.Text;
            string   F_PassWord    = this.txtF_PassWord.Text;
            int      F_DepartID    = int.Parse(this.txtF_DepartID.Text);
            int      F_RoleID      = int.Parse(this.txtF_RoleID.Text);
            bool     F_Sex         = this.chkF_Sex.Checked;
            DateTime F_Birthday    = DateTime.Parse(this.txtF_Birthday.Text);
            string   F_Email       = this.txtF_Email.Text;
            string   F_MobilePhone = this.txtF_MobilePhone.Text;
            DateTime F_RegTime     = DateTime.Parse(this.txtF_RegTime.Text);
            DateTime F_LastInTime  = DateTime.Parse(this.txtF_LastInTime.Text);
            bool     F_IsUsed      = this.chkF_IsUsed.Checked;

            WSS.Model.Users model = new WSS.Model.Users();
            model.F_UserName    = F_UserName;
            model.F_PassWord    = F_PassWord;
            model.F_DepartID    = F_DepartID;
            model.F_RoleID      = F_RoleID;
            model.F_Sex         = F_Sex;
            model.F_Birthday    = F_Birthday;
            model.F_Email       = F_Email;
            model.F_MobilePhone = F_MobilePhone;
            model.F_RegTime     = F_RegTime;
            model.F_LastInTime  = F_LastInTime;
            model.F_IsUsed      = F_IsUsed;

            WSS.BLL.Users bll = new WSS.BLL.Users();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }