Ejemplo n.º 1
0
 private void ShowInfo(string id)
 {
     Topicsys.BLL.t_topic   bll   = new Topicsys.BLL.t_topic();
     Topicsys.Model.t_topic model = bll.GetModel(id);
     this.txtstudent_class_id.Text = model.topic_class_id;
     this.txttopic_name.Text       = model.topic_name;
     this.txttopic_note.Text       = model.topic_note;
     this.ddlStat.Text             = model.topic_stat.ToString();
     this.txttopic_num.Text        = model.topic_num.ToString();
 }
Ejemplo n.º 2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txttopic_name.Text.Trim().Length == 0)
            {
                strErr += "论文题目不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txttopic_num.Text))
            {
                strErr += "可选人数格式错误!\\n";
            }

            if (strErr != "")
            {
                BLL.Utils.ShowMessage(this, strErr);
                return;
            }

            string topic_class_id = this.txtstudent_class_id.Text;
            string topic_name     = this.txttopic_name.Text;
            string topic_note     = this.txttopic_note.Text;
            int    topic_stat     = int.Parse(this.ddlStat.Text);

            /// 判断是否为违规操作
            if (topic_stat != 0 && topic_stat != 9)
            {
                BLL.Utils.ShowMessage(this, "请勿尝试注入!您已被注销!");
                BLL.Utils.Log(this, "非法修改出题状态!题目UUID:" + Request.Params["topic_id"]);
                Response.End();
            }
            int topic_num = int.Parse(this.txttopic_num.Text);

            Topicsys.BLL.t_topic   bll   = new Topicsys.BLL.t_topic();
            Topicsys.Model.t_topic model = bll.GetModel(Request.Params["topic_id"]);
            model.topic_class_id = topic_class_id;
            model.topic_name     = topic_name;
            model.topic_note     = topic_note;
            model.topic_stat     = topic_stat;
            model.topic_num      = topic_num;


            /// 写入日志
            BLL.Utils.Log(this, "修改出题:" + model.topic_id);
            BLL.Utils.ShowMessage(this, bll.Update(model)? "保存成功!":"发生错误!");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Topicsys.Model.t_topic model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_topic set ");
            strSql.Append("topic_teacher_gh=@topic_teacher_gh,");
            strSql.Append("topic_class_id=@topic_class_id,");
            strSql.Append("topic_name=@topic_name,");
            strSql.Append("topic_note=@topic_note,");
            strSql.Append("topic_stat=@topic_stat,");
            strSql.Append("topic_num=@topic_num");
            strSql.Append("topic_type=@topic_type");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@topic_teacher_gh", MySqlDbType.VarChar,  20),
                new MySqlParameter("@topic_class_id",   MySqlDbType.VarChar,  40),
                new MySqlParameter("@topic_name",       MySqlDbType.VarChar,  64),
                new MySqlParameter("@topic_note",       MySqlDbType.VarChar, 255),
                new MySqlParameter("@topic_stat",       MySqlDbType.Int32,     1),
                new MySqlParameter("@topic_num",        MySqlDbType.Int32,     3),
                new MySqlParameter("@topic_type",       MySqlDbType.Int32,     1),
                new MySqlParameter("@id",               MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.topic_teacher_gh;
            parameters[1].Value = model.topic_class_id;
            parameters[2].Value = model.topic_name;
            parameters[3].Value = model.topic_note;
            parameters[4].Value = model.topic_stat;
            parameters[5].Value = model.topic_num;
            parameters[6].Value = model.topic_type;
            parameters[7].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtstudent_class_id.Text.Trim().Length == 0)
            {
                strErr += "可选班级不能为空!\\n";
            }
            if (this.txttopic_name.Text.Trim().Length == 0)
            {
                strErr += "论文题目不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txttopic_num.Text))
            {
                strErr += "可选人数上限格式错误!\\n";
            }

            if (strErr != "")
            {
                BLL.Utils.ShowMessage(this, strErr);
                return;
            }
            string topic_teacher_gh = Session["login_name"].ToString();
            string topic_name       = this.txttopic_name.Text;
            string topic_note       = this.txttopic_note.Text;
            int    topic_num        = int.Parse(this.txttopic_num.Text);

            if (topic_num > 200)
            {
                BLL.Utils.ShowMessage(this, "可选人数上限超过200!");
            }
            Topicsys.Model.t_topic model = new Topicsys.Model.t_topic();
            model.topic_teacher_gh = topic_teacher_gh;
            model.topic_name       = topic_name;
            model.topic_note       = topic_note;
            model.topic_num        = topic_num;
            model.topic_class_id   = txtstudent_class_id.SelectedValue;

            Topicsys.BLL.t_topic bll = new Topicsys.BLL.t_topic();
            /// 写入日志
            BLL.Utils.Log(this, "添加出题:" + topic_name);
            BLL.Utils.ShowMessage(this, bll.Add(model));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Topicsys.Model.t_topic DataRowToModel(DataRow row)
 {
     Topicsys.Model.t_topic model = new Topicsys.Model.t_topic();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["topic_id"] != null)
         {
             model.topic_id = row["topic_id"].ToString();
         }
         if (row["topic_teacher_gh"] != null)
         {
             model.topic_teacher_gh = row["topic_teacher_gh"].ToString();
         }
         if (row["topic_class_id"] != null)
         {
             model.topic_class_id = row["topic_class_id"].ToString();
         }
         if (row["topic_name"] != null)
         {
             model.topic_name = row["topic_name"].ToString();
         }
         if (row["topic_note"] != null)
         {
             model.topic_note = row["topic_note"].ToString();
         }
         if (row["topic_stat"] != null && row["topic_stat"].ToString() != "")
         {
             model.topic_stat = int.Parse(row["topic_stat"].ToString());
         }
         if (row["topic_num"] != null && row["topic_num"].ToString() != "")
         {
             model.topic_num = int.Parse(row["topic_num"].ToString());
         }
         model.topic_type = int.Parse(row["topic_type"].ToString());
     }
     return(model);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Topicsys.Model.t_topic model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_topic(");
            strSql.Append("topic_id,topic_teacher_gh,topic_class_id,topic_name,topic_note,topic_stat,topic_num)");
            strSql.Append(" values (");
            strSql.Append("@topic_id,@topic_teacher_gh,@topic_class_id,@topic_name,@topic_note,@topic_stat,@topic_num)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@topic_id",         MySqlDbType.VarChar,  40),
                new MySqlParameter("@topic_teacher_gh", MySqlDbType.VarChar,  20),
                new MySqlParameter("@topic_class_id",   MySqlDbType.VarChar,  40),
                new MySqlParameter("@topic_name",       MySqlDbType.VarChar,  64),
                new MySqlParameter("@topic_note",       MySqlDbType.VarChar, 255),
                new MySqlParameter("@topic_stat",       MySqlDbType.Int32,     1),
                new MySqlParameter("@topic_num",        MySqlDbType.Int32,     3),
                new MySqlParameter("@topic_type",       MySqlDbType.Int32, 1)
            };
            parameters[0].Value = model.topic_id;
            parameters[1].Value = model.topic_teacher_gh;
            parameters[2].Value = model.topic_class_id;
            parameters[3].Value = model.topic_name;
            parameters[4].Value = model.topic_note;
            parameters[5].Value = model.topic_stat;
            parameters[6].Value = model.topic_num;
            parameters[7].Value = model.topic_type;

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

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

            strSql.Append("select id,topic_id,topic_teacher_gh,topic_class_id,topic_name,topic_note,topic_stat,topic_num from t_topic ");
            strSql.Append(" where topic_id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.VarChar)
            };
            parameters[0].Value = id;

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

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