Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MultiColorPen.Model.b_msg GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, msgtypecode, msgtypename, msgcode, title, detail, url, isenable, sort, remark, createtime, createman, updatetime, updateman  ");
            strSql.Append("  from b_msg ");
            strSql.Append(" where id=" + id);


            MultiColorPen.Model.b_msg model = new MultiColorPen.Model.b_msg();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.msgtypecode = ds.Tables[0].Rows[0]["msgtypecode"].ToString();
                model.msgtypename = ds.Tables[0].Rows[0]["msgtypename"].ToString();
                model.msgcode     = ds.Tables[0].Rows[0]["msgcode"].ToString();
                model.title       = ds.Tables[0].Rows[0]["title"].ToString();
                model.detail      = ds.Tables[0].Rows[0]["detail"].ToString();
                model.url         = ds.Tables[0].Rows[0]["url"].ToString();
                if (ds.Tables[0].Rows[0]["isenable"].ToString() != "")
                {
                    model.isenable = int.Parse(ds.Tables[0].Rows[0]["isenable"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sort"].ToString() != "")
                {
                    model.sort = int.Parse(ds.Tables[0].Rows[0]["sort"].ToString());
                }
                model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                if (ds.Tables[0].Rows[0]["createtime"].ToString() != "")
                {
                    model.createtime = DateTime.Parse(ds.Tables[0].Rows[0]["createtime"].ToString());
                }
                model.createman = ds.Tables[0].Rows[0]["createman"].ToString();
                if (ds.Tables[0].Rows[0]["updatetime"].ToString() != "")
                {
                    model.updatetime = DateTime.Parse(ds.Tables[0].Rows[0]["updatetime"].ToString());
                }
                model.updateman = ds.Tables[0].Rows[0]["updateman"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MultiColorPen.Model.b_msg model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into b_msg(");
            strSql.Append("id,msgtypecode,msgtypename,msgcode,title,detail,url,isenable,sort,remark,createtime,createman,updatetime,updateman)");
            strSql.Append(" values (");
            strSql.Append("?id,?msgtypecode,?msgtypename,?msgcode,?title,?detail,?url,?isenable,?sort,?remark,?createtime,?createman,?updatetime,?updateman)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("?id",          MySqlDbType.Int32,      11),
                new MySqlParameter("?msgtypecode", MySqlDbType.VarChar,    10),
                new MySqlParameter("?msgtypename", MySqlDbType.VarChar,    30),
                new MySqlParameter("?msgcode",     MySqlDbType.VarChar,    10),
                new MySqlParameter("?title",       MySqlDbType.VarChar,   200),
                new MySqlParameter("?detail",      MySqlDbType.Text),
                new MySqlParameter("?url",         MySqlDbType.Text),
                new MySqlParameter("?isenable",    MySqlDbType.Int32,      11),
                new MySqlParameter("?sort",        MySqlDbType.Int32,      11),
                new MySqlParameter("?remark",      MySqlDbType.VarChar,   200),
                new MySqlParameter("?createtime",  MySqlDbType.DateTime),
                new MySqlParameter("?createman",   MySqlDbType.VarChar,    36),
                new MySqlParameter("?updatetime",  MySqlDbType.DateTime),
                new MySqlParameter("?updateman",   MySqlDbType.VarChar, 36)
            };
            parameters[0].Value  = model.id;
            parameters[1].Value  = model.msgtypecode;
            parameters[2].Value  = model.msgtypename;
            parameters[3].Value  = model.msgcode;
            parameters[4].Value  = model.title;
            parameters[5].Value  = model.detail;
            parameters[6].Value  = model.url;
            parameters[7].Value  = model.isenable;
            parameters[8].Value  = model.sort;
            parameters[9].Value  = model.remark;
            parameters[10].Value = model.createtime;
            parameters[11].Value = model.createman;
            parameters[12].Value = model.updatetime;
            parameters[13].Value = model.updateman;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MultiColorPen.Model.b_msg GetModel(string msgcode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,msgtypecode,msgtypename,msgcode,title,detail,url,isenable,sort,remark,createtime,createman,updatetime,updateman from b_msg ");
            strSql.Append(" where msgcode=?msgcode ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("?msgcode", MySqlDbType.VarChar, 10)
            };
            parameters[0].Value = msgcode;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MultiColorPen.Model.b_msg model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update b_msg set ");
            strSql.Append("id=?id,");
            strSql.Append("msgtypecode=?msgtypecode,");
            strSql.Append("msgtypename=?msgtypename,");
            strSql.Append("title=?title,");
            strSql.Append("detail=?detail,");
            strSql.Append("url=?url,");
            strSql.Append("isenable=?isenable,");
            strSql.Append("sort=?sort,");
            strSql.Append("remark=?remark,");
            strSql.Append("createtime=?createtime,");
            strSql.Append("createman=?createman,");
            strSql.Append("updatetime=?updatetime,");
            strSql.Append("updateman=?updateman");
            strSql.Append(" where msgcode=?msgcode ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("?id",          MySqlDbType.Int32,      11),
                new MySqlParameter("?msgtypecode", MySqlDbType.VarChar,    10),
                new MySqlParameter("?msgtypename", MySqlDbType.VarChar,    30),
                new MySqlParameter("?title",       MySqlDbType.VarChar,   200),
                new MySqlParameter("?detail",      MySqlDbType.Text),
                new MySqlParameter("?url",         MySqlDbType.Text),
                new MySqlParameter("?isenable",    MySqlDbType.Int32,      11),
                new MySqlParameter("?sort",        MySqlDbType.Int32,      11),
                new MySqlParameter("?remark",      MySqlDbType.VarChar,   200),
                new MySqlParameter("?createtime",  MySqlDbType.DateTime),
                new MySqlParameter("?createman",   MySqlDbType.VarChar,    36),
                new MySqlParameter("?updatetime",  MySqlDbType.DateTime),
                new MySqlParameter("?updateman",   MySqlDbType.VarChar,    36),
                new MySqlParameter("?msgcode",     MySqlDbType.VarChar, 10)
            };
            parameters[0].Value  = model.id;
            parameters[1].Value  = model.msgtypecode;
            parameters[2].Value  = model.msgtypename;
            parameters[3].Value  = model.title;
            parameters[4].Value  = model.detail;
            parameters[5].Value  = model.url;
            parameters[6].Value  = model.isenable;
            parameters[7].Value  = model.sort;
            parameters[8].Value  = model.remark;
            parameters[9].Value  = model.createtime;
            parameters[10].Value = model.createman;
            parameters[11].Value = model.updatetime;
            parameters[12].Value = model.updateman;
            parameters[13].Value = model.msgcode;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MultiColorPen.Model.b_msg DataRowToModel(DataRow row)
 {
     MultiColorPen.Model.b_msg model = new MultiColorPen.Model.b_msg();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["msgtypecode"] != null)
         {
             model.msgtypecode = row["msgtypecode"].ToString();
         }
         if (row["msgtypename"] != null)
         {
             model.msgtypename = row["msgtypename"].ToString();
         }
         if (row["msgcode"] != null)
         {
             model.msgcode = row["msgcode"].ToString();
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["detail"] != null)
         {
             model.detail = row["detail"].ToString();
         }
         if (row["url"] != null)
         {
             model.url = row["url"].ToString();
         }
         if (row["isenable"] != null && row["isenable"].ToString() != "")
         {
             model.isenable = int.Parse(row["isenable"].ToString());
         }
         if (row["sort"] != null && row["sort"].ToString() != "")
         {
             model.sort = int.Parse(row["sort"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["createtime"] != null && row["createtime"].ToString() != "")
         {
             model.createtime = DateTime.Parse(row["createtime"].ToString());
         }
         if (row["createman"] != null)
         {
             model.createman = row["createman"].ToString();
         }
         if (row["updatetime"] != null && row["updatetime"].ToString() != "")
         {
             model.updatetime = DateTime.Parse(row["updatetime"].ToString());
         }
         if (row["updateman"] != null)
         {
             model.updateman = row["updateman"].ToString();
         }
     }
     return(model);
 }