Beispiel #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtadminName.Text.Trim().Length == 0)
            {
                strErr += "adminName不能为空!\\n";
            }
            if (this.txtadminPassword.Text.Trim().Length == 0)
            {
                strErr += "adminPassword不能为空!\\n";
            }
            if (this.txtdepartment.Text.Trim().Length == 0)
            {
                strErr += "department不能为空!\\n";
            }
            if (this.txtjob.Text.Trim().Length == 0)
            {
                strErr += "job不能为空!\\n";
            }
            if (this.txtpermission.Text.Trim().Length == 0)
            {
                strErr += "permission不能为空!\\n";
            }
            if (this.txtremark.Text.Trim().Length == 0)
            {
                strErr += "remark不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    adminID       = int.Parse(this.lbladminID.Text);
            string adminName     = this.txtadminName.Text;
            string adminPassword = this.txtadminPassword.Text;
            string department    = this.txtdepartment.Text;
            string job           = this.txtjob.Text;
            string permission    = this.txtpermission.Text;
            string remark        = this.txtremark.Text;


            UserFB.Model.Admin model = new UserFB.Model.Admin();
            model.adminID       = adminID;
            model.adminName     = adminName;
            model.adminPassword = adminPassword;
            model.department    = department;
            model.job           = job;
            model.permission    = permission;
            model.remark        = remark;

            UserFB.BLL.AdminManager bll = new UserFB.BLL.AdminManager();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Beispiel #2
0
 private void ShowInfo(int adminID)
 {
     UserFB.BLL.AdminManager bll   = new UserFB.BLL.AdminManager();
     UserFB.Model.Admin      model = bll.GetModel(adminID);
     this.lbladminID.Text       = model.adminID.ToString();
     this.lbladminName.Text     = model.adminName;
     this.lbladminPassword.Text = model.adminPassword;
     this.lbldepartment.Text    = model.department;
     this.lbljob.Text           = model.job;
     this.lblpermission.Text    = model.permission;
     this.lblremark.Text        = model.remark;
 }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(UserFB.Model.Admin model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Admin set ");
            strSql.Append("adminName=@adminName,");
            strSql.Append("adminPassword=@adminPassword,");
            strSql.Append("department=@department,");
            strSql.Append("job=@job,");
            strSql.Append("permission=@permission,");
            strSql.Append("remark=@remark");
            strSql.Append(" where adminID=@adminID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminName",     SqlDbType.VarChar, 64),
                new SqlParameter("@adminPassword", SqlDbType.VarChar, 64),
                new SqlParameter("@department",    SqlDbType.VarChar, 64),
                new SqlParameter("@job",           SqlDbType.VarChar, 64),
                new SqlParameter("@permission",    SqlDbType.VarChar, 16),
                new SqlParameter("@remark",        SqlDbType.VarChar, 64),
                new SqlParameter("@adminID",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.adminName;
            parameters[1].Value = model.adminPassword;
            parameters[2].Value = model.department;
            parameters[3].Value = model.job;
            parameters[4].Value = model.permission;
            parameters[5].Value = model.remark;
            parameters[6].Value = model.adminID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool  Add(UserFB.Model.Admin model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Admin(");
            strSql.Append("adminName,adminPassword,department,job,permission,remark)");
            strSql.Append(" values (");
            strSql.Append("@adminName,@adminPassword,@department,@job,@permission,@remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminName",     SqlDbType.VarChar, 64),
                new SqlParameter("@adminPassword", SqlDbType.VarChar, 64),
                new SqlParameter("@department",    SqlDbType.VarChar, 64),
                new SqlParameter("@job",           SqlDbType.VarChar, 64),
                new SqlParameter("@permission",    SqlDbType.VarChar, 16),
                new SqlParameter("@remark",        SqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.adminName;
            parameters[1].Value = model.adminPassword;
            parameters[2].Value = model.department;
            parameters[3].Value = model.job;
            parameters[4].Value = model.permission;
            parameters[5].Value = model.remark;

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

            if (obj == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public UserFB.Model.Admin DataRowToModel(DataRow row)
 {
     UserFB.Model.Admin model = new UserFB.Model.Admin();
     if (row != null)
     {
         if (row["adminID"] != null && row["adminID"].ToString() != "")
         {
             model.adminID = int.Parse(row["adminID"].ToString());
         }
         if (row["adminName"] != null)
         {
             model.adminName = row["adminName"].ToString();
         }
         if (row["adminPassword"] != null)
         {
             model.adminPassword = row["adminPassword"].ToString();
         }
         if (row["department"] != null)
         {
             model.department = row["department"].ToString();
         }
         if (row["job"] != null)
         {
             model.job = row["job"].ToString();
         }
         if (row["permission"] != null)
         {
             model.permission = row["permission"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
Beispiel #6
0
        public UserFB.Model.Admin GetModel1(string adminID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 adminID,adminName,adminPassword,department,job,permission,remark from Admin ");
            strSql.Append(" where adminID=@adminID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@adminID", SqlDbType.Int, 4)
            };
            parameters[0].Value = adminID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }