Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Light.Model.authenticationinfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into authenticationinfo(");
            strSql.Append("id,authenticationname,Introduction,createman,createtime");
            strSql.Append(") values (");
            strSql.Append("@id,@authenticationname,@Introduction,@createman,@createtime");
            strSql.Append(") ");

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id",                 MySqlDbType.Int32,    10),
                new MySqlParameter("@authenticationname", MySqlDbType.VarChar,  50),
                new MySqlParameter("@Introduction",       MySqlDbType.VarChar, 500),
                new MySqlParameter("@createman",          MySqlDbType.Int32,    10),
                new MySqlParameter("@createtime",         MySqlDbType.DateTime)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.authenticationname;
            parameters[2].Value = model.Introduction;
            parameters[3].Value = model.createman;
            parameters[4].Value = model.createtime;
            DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Light.Model.authenticationinfo GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, authenticationname, Introduction, createman, createtime  ");
            strSql.Append("  from authenticationinfo ");
            strSql.Append(" where id=@id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32, 10)
            };
            parameters[0].Value = id;


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

            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.authenticationname = ds.Tables[0].Rows[0]["authenticationname"].ToString();
                model.Introduction       = ds.Tables[0].Rows[0]["Introduction"].ToString();
                if (ds.Tables[0].Rows[0]["createman"].ToString() != "")
                {
                    model.createman = int.Parse(ds.Tables[0].Rows[0]["createman"].ToString());
                }
                if (ds.Tables[0].Rows[0]["createtime"].ToString() != "")
                {
                    model.createtime = DateTime.Parse(ds.Tables[0].Rows[0]["createtime"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Light.Model.authenticationinfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update authenticationinfo set ");

            strSql.Append(" id = @id , ");
            strSql.Append(" authenticationname = @authenticationname , ");
            strSql.Append(" Introduction = @Introduction , ");
            strSql.Append(" createman = @createman , ");
            strSql.Append(" createtime = @createtime  ");
            strSql.Append(" where id=@id  ");

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id",                 MySqlDbType.Int32,    10),
                new MySqlParameter("@authenticationname", MySqlDbType.VarChar,  50),
                new MySqlParameter("@Introduction",       MySqlDbType.VarChar, 500),
                new MySqlParameter("@createman",          MySqlDbType.Int32,    10),
                new MySqlParameter("@createtime",         MySqlDbType.DateTime)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.authenticationname;
            parameters[2].Value = model.Introduction;
            parameters[3].Value = model.createman;
            parameters[4].Value = model.createtime;
            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Light.Model.authenticationinfo GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select id, authenticationname, Introduction, createman, createtime  ");
            strSql.Append("  from authenticationinfo ");
            strSql.Append(" where id=@id ");
                        MySqlParameter[] parameters = {
                    new MySqlParameter("@id", MySqlDbType.Int32,10)			};
            parameters[0].Value = id;

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

            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.authenticationname= ds.Tables[0].Rows[0]["authenticationname"].ToString();
                                                                                                                                model.Introduction= ds.Tables[0].Rows[0]["Introduction"].ToString();
                                                                                                                if(ds.Tables[0].Rows[0]["createman"].ToString()!="")
                {
                    model.createman=int.Parse(ds.Tables[0].Rows[0]["createman"].ToString());
                }
                                                                                                                                if(ds.Tables[0].Rows[0]["createtime"].ToString()!="")
                {
                    model.createtime=DateTime.Parse(ds.Tables[0].Rows[0]["createtime"].ToString());
                }

                return model;
            }
            else
            {
                return null;
            }
        }