Пример #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtsl_sort.Text))
            {
                strErr += "sl_sort格式错误!\\n";
            }
            if (this.txtsl_valid.Text.Trim().Length == 0)
            {
                strErr += "sl_valid不能为空!\\n";
            }
            if (this.txtsl_content.Text.Trim().Length == 0)
            {
                strErr += "sl_content不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtsl_pic_id.Text))
            {
                strErr += "sl_pic_id格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtsl_per_id.Text))
            {
                strErr += "sl_per_id格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtsl_per_type.Text))
            {
                strErr += "sl_per_type格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtsl_date.Text))
            {
                strErr += "sl_date格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      sl_sort     = int.Parse(this.txtsl_sort.Text);
            string   sl_valid    = this.txtsl_valid.Text;
            string   sl_content  = this.txtsl_content.Text;
            int      sl_pic_id   = int.Parse(this.txtsl_pic_id.Text);
            int      sl_per_id   = int.Parse(this.txtsl_per_id.Text);
            int      sl_per_type = int.Parse(this.txtsl_per_type.Text);
            DateTime sl_date     = DateTime.Parse(this.txtsl_date.Text);

            WalleProject.Model.t_systemleave model = new WalleProject.Model.t_systemleave();
            model.sl_sort     = sl_sort;
            model.sl_valid    = sl_valid;
            model.sl_content  = sl_content;
            model.sl_pic_id   = sl_pic_id;
            model.sl_per_id   = sl_per_id;
            model.sl_per_type = sl_per_type;
            model.sl_date     = sl_date;

            WalleProject.BLL.t_systemleave bll = new WalleProject.BLL.t_systemleave();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Пример #2
0
 private void ShowInfo(int sl_id)
 {
     WalleProject.BLL.t_systemleave   bll   = new WalleProject.BLL.t_systemleave();
     WalleProject.Model.t_systemleave model = bll.GetModel(sl_id);
     this.lblsl_sort.Text     = model.sl_sort.ToString();
     this.lblsl_valid.Text    = model.sl_valid;
     this.lblsl_content.Text  = model.sl_content;
     this.lblsl_pic_id.Text   = model.sl_pic_id.ToString();
     this.lblsl_per_id.Text   = model.sl_per_id.ToString();
     this.lblsl_id.Text       = model.sl_id.ToString();
     this.lblsl_per_type.Text = model.sl_per_type.ToString();
     this.lblsl_date.Text     = model.sl_date.ToString();
 }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WalleProject.Model.t_systemleave model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_systemleave set ");
            strSql.Append("sl_sort=@sl_sort,");
            strSql.Append("sl_valid=@sl_valid,");
            strSql.Append("sl_content=@sl_content,");
            strSql.Append("sl_pic_id=@sl_pic_id,");
            strSql.Append("sl_per_id=@sl_per_id,");
            strSql.Append("sl_per_type=@sl_per_type,");
            strSql.Append("sl_date=@sl_date");
            strSql.Append(" where sl_id=@sl_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@sl_sort",     MySqlDbType.Int32,     10),
                new MySqlParameter("@sl_valid",    MySqlDbType.VarChar,   20),
                new MySqlParameter("@sl_content",  MySqlDbType.Text),
                new MySqlParameter("@sl_pic_id",   MySqlDbType.Int32,     10),
                new MySqlParameter("@sl_per_id",   MySqlDbType.Int32,     10),
                new MySqlParameter("@sl_per_type", MySqlDbType.Int32,     10),
                new MySqlParameter("@sl_date",     MySqlDbType.DateTime),
                new MySqlParameter("@sl_id",       MySqlDbType.Int32, 10)
            };
            parameters[0].Value = model.sl_sort;
            parameters[1].Value = model.sl_valid;
            parameters[2].Value = model.sl_content;
            parameters[3].Value = model.sl_pic_id;
            parameters[4].Value = model.sl_per_id;
            parameters[5].Value = model.sl_per_type;
            parameters[6].Value = model.sl_date;
            parameters[7].Value = model.sl_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WalleProject.Model.t_systemleave DataRowToModel(DataRow row)
 {
     WalleProject.Model.t_systemleave model = new WalleProject.Model.t_systemleave();
     if (row != null)
     {
         if (row["sl_sort"] != null && row["sl_sort"].ToString() != "")
         {
             model.sl_sort = int.Parse(row["sl_sort"].ToString());
         }
         if (row["sl_valid"] != null)
         {
             model.sl_valid = row["sl_valid"].ToString();
         }
         if (row["sl_content"] != null)
         {
             model.sl_content = row["sl_content"].ToString();
         }
         if (row["sl_pic_id"] != null && row["sl_pic_id"].ToString() != "")
         {
             model.sl_pic_id = int.Parse(row["sl_pic_id"].ToString());
         }
         if (row["sl_per_id"] != null && row["sl_per_id"].ToString() != "")
         {
             model.sl_per_id = int.Parse(row["sl_per_id"].ToString());
         }
         if (row["sl_id"] != null && row["sl_id"].ToString() != "")
         {
             model.sl_id = int.Parse(row["sl_id"].ToString());
         }
         if (row["sl_per_type"] != null && row["sl_per_type"].ToString() != "")
         {
             model.sl_per_type = int.Parse(row["sl_per_type"].ToString());
         }
         if (row["sl_date"] != null && row["sl_date"].ToString() != "")
         {
             model.sl_date = DateTime.Parse(row["sl_date"].ToString());
         }
     }
     return(model);
 }
Пример #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WalleProject.Model.t_systemleave model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_systemleave(");
            strSql.Append("sl_sort,sl_valid,sl_content,sl_pic_id,sl_per_id,sl_per_type,sl_date)");
            strSql.Append(" values (");
            strSql.Append("@sl_sort,@sl_valid,@sl_content,@sl_pic_id,@sl_per_id,@sl_per_type,@sl_date)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@sl_sort",     MySqlDbType.Int32,   10),
                new MySqlParameter("@sl_valid",    MySqlDbType.VarChar, 20),
                new MySqlParameter("@sl_content",  MySqlDbType.Text),
                new MySqlParameter("@sl_pic_id",   MySqlDbType.Int32,   10),
                new MySqlParameter("@sl_per_id",   MySqlDbType.Int32,   10),
                new MySqlParameter("@sl_per_type", MySqlDbType.Int32,   10),
                new MySqlParameter("@sl_date",     MySqlDbType.DateTime)
            };
            parameters[0].Value = model.sl_sort;
            parameters[1].Value = model.sl_valid;
            parameters[2].Value = model.sl_content;
            parameters[3].Value = model.sl_pic_id;
            parameters[4].Value = model.sl_per_id;
            parameters[5].Value = model.sl_per_type;
            parameters[6].Value = model.sl_date;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WalleProject.Model.t_systemleave GetModel(int sl_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select sl_sort,sl_valid,sl_content,sl_pic_id,sl_per_id,sl_id,sl_per_type,sl_date from t_systemleave ");
            strSql.Append(" where sl_id=@sl_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@sl_id", MySqlDbType.Int32)
            };
            parameters[0].Value = sl_id;

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

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