Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SDAU.Model.YongHuXinXi model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update YongHuXinXi set ");
            strSql.Append("YongHuMing=@YongHuMing,");
            strSql.Append("YongHuMiMa=@YongHuMiMa,");
            strSql.Append("YouXiang=@YouXiang,");
            strSql.Append("ZhuCeShiJian=@ZhuCeShiJian,");
            strSql.Append("QuanXian=@QuanXian,");
            strSql.Append("TouXiang=@TouXiang,");
            strSql.Append("BeiZhu=@BeiZhu");
            strSql.Append(" where YHBianHao=@YHBianHao");
            SqlParameter[] parameters =
            {
                new SqlParameter("@YongHuMing",   SqlDbType.VarChar,    20),
                new SqlParameter("@YongHuMiMa",   SqlDbType.VarChar,    32),
                new SqlParameter("@YouXiang",     SqlDbType.NVarChar,   50),
                new SqlParameter("@ZhuCeShiJian", SqlDbType.DateTime),
                new SqlParameter("@QuanXian",     SqlDbType.Int,         4),
                new SqlParameter("@TouXiang",     SqlDbType.Image),
                new SqlParameter("@BeiZhu",       SqlDbType.NVarChar,  500),
                new SqlParameter("@YHBianHao",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.YongHuMing;
            parameters[1].Value = model.YongHuMiMa;
            parameters[2].Value = model.YouXiang;
            parameters[3].Value = model.ZhuCeShiJian;
            parameters[4].Value = model.QuanXian;
            parameters[5].Value = model.TouXiang;
            parameters[6].Value = model.BeiZhu;
            parameters[7].Value = model.YHBianHao;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SDAU.Model.YongHuXinXi DataRowToModel(DataRow row)
 {
     SDAU.Model.YongHuXinXi model = new SDAU.Model.YongHuXinXi();
     if (row != null)
     {
         if (row["YHBianHao"] != null && row["YHBianHao"].ToString() != "")
         {
             model.YHBianHao = int.Parse(row["YHBianHao"].ToString());
         }
         if (row["YongHuMing"] != null)
         {
             model.YongHuMing = row["YongHuMing"].ToString();
         }
         if (row["YongHuMiMa"] != null)
         {
             model.YongHuMiMa = row["YongHuMiMa"].ToString();
         }
         if (row["YouXiang"] != null)
         {
             model.YouXiang = row["YouXiang"].ToString();
         }
         if (row["ZhuCeShiJian"] != null && row["ZhuCeShiJian"].ToString() != "")
         {
             model.ZhuCeShiJian = DateTime.Parse(row["ZhuCeShiJian"].ToString());
         }
         if (row["QuanXian"] != null && row["QuanXian"].ToString() != "")
         {
             model.QuanXian = int.Parse(row["QuanXian"].ToString());
         }
         if (row["TouXiang"] != null && row["TouXiang"].ToString() != "")
         {
             model.TouXiang = (byte[])row["TouXiang"];
         }
         if (row["BeiZhu"] != null)
         {
             model.BeiZhu = row["BeiZhu"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SDAU.Model.YongHuXinXi model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into YongHuXinXi(");
            strSql.Append("YongHuMing,YongHuMiMa,YouXiang,ZhuCeShiJian,QuanXian,TouXiang,BeiZhu)");
            strSql.Append(" values (");
            strSql.Append("@YongHuMing,@YongHuMiMa,@YouXiang,@ZhuCeShiJian,@QuanXian,@TouXiang,@BeiZhu)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@YongHuMing",   SqlDbType.VarChar,   20),
                new SqlParameter("@YongHuMiMa",   SqlDbType.VarChar,   32),
                new SqlParameter("@YouXiang",     SqlDbType.NVarChar,  50),
                new SqlParameter("@ZhuCeShiJian", SqlDbType.DateTime),
                new SqlParameter("@QuanXian",     SqlDbType.Int,        4),
                new SqlParameter("@TouXiang",     SqlDbType.Image),
                new SqlParameter("@BeiZhu",       SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.YongHuMing;
            parameters[1].Value = model.YongHuMiMa;
            parameters[2].Value = model.YouXiang;
            parameters[3].Value = model.ZhuCeShiJian;
            parameters[4].Value = model.QuanXian;
            parameters[5].Value = model.TouXiang;
            parameters[6].Value = model.BeiZhu;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        public SDAU.Model.YongHuXinXi GetModel(string username)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 YHBianHao,YongHuMing,YongHuMiMa,YouXiang,ZhuCeShiJian,QuanXian,TouXiang,BeiZhu from YongHuXinXi ");
            strSql.Append(" where YongHuMing=@YongHuMing");
            SqlParameter[] parameters =
            {
                new SqlParameter("@YongHuMing", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = username;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(SDAU.Model.YongHuXinXi model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(SDAU.Model.YongHuXinXi model)
 {
     return(dal.Add(model));
 }