Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Matisoft.Model.Administrator model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Administrator(");
            strSql.Append("Admin,Password,AdminiEmail,AdminState,AuthorityID)");
            strSql.Append(" values (");
            strSql.Append("@Admin,@Password,@AdminiEmail,@AdminState,@AuthorityID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Admin",       SqlDbType.NVarChar, 100),
                new SqlParameter("@Password",    SqlDbType.NVarChar,  50),
                new SqlParameter("@AdminiEmail", SqlDbType.NVarChar,  50),
                new SqlParameter("@AdminState",  SqlDbType.Int,        4),
                new SqlParameter("@AuthorityID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Admin;
            parameters[1].Value = model.Password;
            parameters[2].Value = model.AdminiEmail;
            parameters[3].Value = model.AdminState;
            parameters[4].Value = model.AuthorityID;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Matisoft.Model.Administrator DataRowToModel(DataRow row)
 {
     Matisoft.Model.Administrator model = new Matisoft.Model.Administrator();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["Admin"] != null)
         {
             model.Admin = row["Admin"].ToString();
         }
         if (row["Password"] != null)
         {
             model.Password = row["Password"].ToString();
         }
         if (row["AdminiEmail"] != null)
         {
             model.AdminiEmail = row["AdminiEmail"].ToString();
         }
         if (row["AdminState"] != null && row["AdminState"].ToString() != "")
         {
             model.AdminState = int.Parse(row["AdminState"].ToString());
         }
         if (row["AuthorityID"] != null && row["AuthorityID"].ToString() != "")
         {
             model.AuthorityID = int.Parse(row["AuthorityID"].ToString());
         }
     }
     return(model);
 }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Matisoft.Model.Administrator DataRowToModel(DataRow row)
 {
     Matisoft.Model.Administrator model=new Matisoft.Model.Administrator();
     if (row != null)
     {
         if(row["id"]!=null && row["id"].ToString()!="")
         {
             model.id=int.Parse(row["id"].ToString());
         }
         if(row["Admin"]!=null)
         {
             model.Admin=row["Admin"].ToString();
         }
         if(row["Password"]!=null)
         {
             model.Password=row["Password"].ToString();
         }
         if(row["AdminiEmail"]!=null)
         {
             model.AdminiEmail=row["AdminiEmail"].ToString();
         }
         if(row["AdminState"]!=null && row["AdminState"].ToString()!="")
         {
             model.AdminState=int.Parse(row["AdminState"].ToString());
         }
         if(row["AuthorityID"]!=null && row["AuthorityID"].ToString()!="")
         {
             model.AuthorityID=int.Parse(row["AuthorityID"].ToString());
         }
     }
     return model;
 }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Matisoft.Model.Administrator model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Administrator set ");
            strSql.Append("Admin=@Admin,");
            strSql.Append("Password=@Password,");
            strSql.Append("AdminiEmail=@AdminiEmail,");
            strSql.Append("AdminState=@AdminState,");
            strSql.Append("AuthorityID=@AuthorityID");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Admin",       SqlDbType.NVarChar, 100),
                new SqlParameter("@Password",    SqlDbType.NVarChar,  50),
                new SqlParameter("@AdminiEmail", SqlDbType.NVarChar,  50),
                new SqlParameter("@AdminState",  SqlDbType.Int,        4),
                new SqlParameter("@AuthorityID", SqlDbType.Int,        4),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Admin;
            parameters[1].Value = model.Password;
            parameters[2].Value = model.AdminiEmail;
            parameters[3].Value = model.AdminState;
            parameters[4].Value = model.AuthorityID;
            parameters[5].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Matisoft.Model.Administrator GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,Admin,Password,AdminiEmail,AdminState,AuthorityID from Administrator ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Matisoft.Model.Administrator model = new Matisoft.Model.Administrator();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Matisoft.Model.Administrator GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,Admin,Password,AdminiEmail,AdminState,AuthorityID from Administrator ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            Matisoft.Model.Administrator model=new Matisoft.Model.Administrator();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }