Esempio n. 1
0
 private void ShowInfo(int id)
 {
     BLL.DDL.DeptDLL(ddlDept_id);
     BLL.DDL.MajorDLL(ddlMajor_id);
     Topicsys.BLL.t_student   bll   = new Topicsys.BLL.t_student();
     Topicsys.Model.t_student model = bll.GetModel(id);
     this.txtstudent_xh.Text       = model.student_xh;
     this.txtstudent_name.Text     = model.student_name;
     this.txtstudent_class_id.Text = model.student_class_id;
     this.ddlStat.Text             = model.student_stat.ToString();
     this.txtstudent_note.Text     = model.student_note;
 }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtstudent_xh.Text.Trim().Length == 0)
            {
                strErr += "学号不能为空!\\n";
            }
            if (this.txtstudent_name.Text.Trim().Length == 0)
            {
                strErr += "姓名不能为空!\\n";
            }
            if (this.txtstudent_class_id.Text.Trim().Length == 0)
            {
                strErr += "班级不能为空!\\n";
            }

            if (strErr != "")
            {
                BLL.Utils.ShowMessage(this, strErr);
                return;
            }
            string student_xh       = this.txtstudent_xh.Text;
            string student_name     = this.txtstudent_name.Text;
            string student_class_id = this.txtstudent_class_id.Text;
            string pwd = this.txtpwd.Text.Trim();

            if (pwd.Length < 6)
            {
                BLL.Utils.ShowMessage(this, "密码长度应该大于等于6个字符!");
                return;
            }
            Topicsys.Model.t_student model = new Topicsys.Model.t_student();
            model.student_xh       = student_xh;
            model.student_pwd      = BLL.Utils.HashPasswd(pwd);
            model.student_name     = student_name;
            model.student_class_id = student_class_id;

            /// 写入日志

            BLL.Utils.Log(new Model.t_log
            {
                log_info  = "学生注册:" + student_xh,
                log_ip    = Request.UserHostAddress,
                user_name = student_xh
            });
            Topicsys.BLL.t_student bll = new Topicsys.BLL.t_student();
            BLL.Utils.ShowMessage(this, bll.Add(model));
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Topicsys.Model.t_student model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_student set ");
            strSql.Append("student_xh=@student_xh,");
            strSql.Append("student_name=@student_name,");
            strSql.Append("student_class_id=@student_class_id,");
            strSql.Append("student_pwd=@student_pwd,");
            strSql.Append("student_pwd_q=@student_pwd_q,");
            strSql.Append("student_pwd_a=@student_pwd_a,");
            strSql.Append("student_stat=@student_stat,");
            strSql.Append("student_note=@student_note");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@student_xh",       MySqlDbType.VarChar,  20),
                new MySqlParameter("@student_name",     MySqlDbType.VarChar,  10),
                new MySqlParameter("@student_class_id", MySqlDbType.VarChar,  40),
                new MySqlParameter("@student_pwd",      MySqlDbType.VarChar,  60),
                new MySqlParameter("@student_pwd_q",    MySqlDbType.VarChar,  64),
                new MySqlParameter("@student_pwd_a",    MySqlDbType.VarChar,  64),
                new MySqlParameter("@student_stat",     MySqlDbType.Int32,    11),
                new MySqlParameter("@student_note",     MySqlDbType.VarChar, 255),
                new MySqlParameter("@id",               MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.student_xh;
            parameters[1].Value = model.student_name;
            parameters[2].Value = model.student_class_id;
            parameters[3].Value = model.student_pwd;
            parameters[4].Value = model.student_pwd_q;
            parameters[5].Value = model.student_pwd_a;
            parameters[6].Value = model.student_stat;
            parameters[7].Value = model.student_note;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Topicsys.Model.t_student DataRowToModel(DataRow row)
 {
     Topicsys.Model.t_student model = new Topicsys.Model.t_student();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["student_xh"] != null)
         {
             model.student_xh = row["student_xh"].ToString();
         }
         if (row["student_name"] != null)
         {
             model.student_name = row["student_name"].ToString();
         }
         if (row["student_class_id"] != null)
         {
             model.student_class_id = row["student_class_id"].ToString();
         }
         if (row["student_pwd"] != null)
         {
             model.student_pwd = row["student_pwd"].ToString();
         }
         if (row["student_pwd_q"] != null)
         {
             model.student_pwd_q = row["student_pwd_q"].ToString();
         }
         if (row["student_pwd_a"] != null)
         {
             model.student_pwd_a = row["student_pwd_a"].ToString();
         }
         if (row["student_stat"] != null && row["student_stat"].ToString() != "")
         {
             model.student_stat = int.Parse(row["student_stat"].ToString());
         }
         if (row["student_note"] != null)
         {
             model.student_note = row["student_note"].ToString();
         }
     }
     return(model);
 }
Esempio n. 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtstudent_xh.Text.Trim().Length == 0)
            {
                strErr += "学号不能为空!\\n";
            }
            if (this.txtstudent_name.Text.Trim().Length == 0)
            {
                strErr += "姓名不能为空!\\n";
            }
            if (this.txtstudent_class_id.Text.Trim().Length == 0)
            {
                strErr += "班级不能为空!\\n";
            }

            if (strErr != "")
            {
                BLL.Utils.ShowMessage(this, strErr);
                return;
            }
            string student_xh       = this.txtstudent_xh.Text;
            string student_name     = this.txtstudent_name.Text;
            string student_class_id = this.txtstudent_class_id.Text;
            string student_note     = this.txtstudent_note.Text;

            Topicsys.Model.t_student model = new Topicsys.Model.t_student();
            model.student_xh       = student_xh;
            model.student_pwd      = BLL.Utils.HashPasswd("abc12345");
            model.student_name     = student_name;
            model.student_class_id = student_class_id;
            model.student_note     = student_note;

            Topicsys.BLL.t_student bll = new Topicsys.BLL.t_student();

            /// 写入日志
            BLL.Utils.Log(this, "添加学生:" + student_xh);
            BLL.Utils.ShowMessage(this, bll.Add(model));
        }
Esempio n. 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Topicsys.Model.t_student model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_student(");
            strSql.Append("student_xh,student_name,student_class_id,student_pwd,student_pwd_q,student_pwd_a,student_stat,student_note)");
            strSql.Append(" values (");
            strSql.Append("@student_xh,@student_name,@student_class_id,@student_pwd,@student_pwd_q,@student_pwd_a,@student_stat,@student_note)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@student_xh",       MySqlDbType.VarChar, 20),
                new MySqlParameter("@student_name",     MySqlDbType.VarChar, 10),
                new MySqlParameter("@student_class_id", MySqlDbType.VarChar, 40),
                new MySqlParameter("@student_pwd",      MySqlDbType.VarChar, 60),
                new MySqlParameter("@student_pwd_q",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@student_pwd_a",    MySqlDbType.VarChar, 64),
                new MySqlParameter("@student_stat",     MySqlDbType.Int32,   11),
                new MySqlParameter("@student_note",     MySqlDbType.VarChar, 255)
            };
            parameters[0].Value = model.student_xh;
            parameters[1].Value = model.student_name;
            parameters[2].Value = model.student_class_id;
            parameters[3].Value = model.student_pwd;
            parameters[4].Value = model.student_pwd_q;
            parameters[5].Value = model.student_pwd_a;
            parameters[6].Value = model.student_stat;
            parameters[7].Value = model.student_note;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Topicsys.Model.t_student GetModel(string xh)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,student_xh,student_name,student_class_id,student_pwd,student_pwd_q,student_pwd_a,student_stat,student_note from t_student ");
            strSql.Append(" where student_xh=@xh");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@xh", MySqlDbType.VarChar)
            };
            parameters[0].Value = xh;

            Topicsys.Model.t_student model = new Topicsys.Model.t_student();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

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