Ejemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SDAU.ZHCZ.Model.LiuYanBan DataRowToModel(DataRow row)
 {
     SDAU.ZHCZ.Model.LiuYanBan model = new SDAU.ZHCZ.Model.LiuYanBan();
     if (row != null)
     {
         if (row["BianHao"] != null && row["BianHao"].ToString() != "")
         {
             model.BianHao = int.Parse(row["BianHao"].ToString());
         }
         if (row["BiaoTi"] != null)
         {
             model.BiaoTi = row["BiaoTi"].ToString();
         }
         if (row["NeiRong"] != null)
         {
             model.NeiRong = row["NeiRong"].ToString();
         }
         if (row["LiuYanRen"] != null)
         {
             model.LiuYanRen = row["LiuYanRen"].ToString();
         }
         if (row["EMail"] != null)
         {
             model.EMail = row["EMail"].ToString();
         }
         if (row["DianHua"] != null)
         {
             model.DianHua = row["DianHua"].ToString();
         }
         if (row["BiaoQing"] != null && row["BiaoQing"].ToString() != "")
         {
             model.BiaoQing = (byte[])row["BiaoQing"];
         }
         if (row["LiuYanShiJian"] != null && row["LiuYanShiJian"].ToString() != "")
         {
             model.LiuYanShiJian = DateTime.Parse(row["LiuYanShiJian"].ToString());
         }
         if (row["HuiFuZhuangTai"] != null)
         {
             model.HuiFuZhuangTai = row["HuiFuZhuangTai"].ToString();
         }
         if (row["HuiFuNeiRong"] != null)
         {
             model.HuiFuNeiRong = row["HuiFuNeiRong"].ToString();
         }
         if (row["HuiFuShiJian"] != null && row["HuiFuShiJian"].ToString() != "")
         {
             model.HuiFuShiJian = DateTime.Parse(row["HuiFuShiJian"].ToString());
         }
         if (row["HuiFuRen"] != null)
         {
             model.HuiFuRen = row["HuiFuRen"].ToString();
         }
         if (row["BeiZhu"] != null)
         {
             model.BeiZhu = row["BeiZhu"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SDAU.ZHCZ.Model.LiuYanBan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update LiuYanBan set ");
            strSql.Append("NeiRong=@NeiRong,");
            strSql.Append("LiuYanRen=@LiuYanRen,");
            strSql.Append("EMail=@EMail,");
            strSql.Append("DianHua=@DianHua,");
            strSql.Append("BiaoQing=@BiaoQing,");
            strSql.Append("LiuYanShiJian=@LiuYanShiJian,");
            strSql.Append("HuiFuZhuangTai=@HuiFuZhuangTai,");
            strSql.Append("HuiFuNeiRong=@HuiFuNeiRong,");
            strSql.Append("HuiFuShiJian=@HuiFuShiJian,");
            strSql.Append("HuiFuRen=@HuiFuRen,");
            strSql.Append("BeiZhu=@BeiZhu");
            strSql.Append(" where BianHao=@BianHao");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NeiRong",        SqlDbType.NVarChar,  1000),
                new SqlParameter("@LiuYanRen",      SqlDbType.NVarChar,    12),
                new SqlParameter("@EMail",          SqlDbType.NVarChar,    20),
                new SqlParameter("@DianHua",        SqlDbType.NVarChar,    12),
                new SqlParameter("@BiaoQing",       SqlDbType.VarBinary,   -1),
                new SqlParameter("@LiuYanShiJian",  SqlDbType.DateTime),
                new SqlParameter("@HuiFuZhuangTai", SqlDbType.NVarChar,    10),
                new SqlParameter("@HuiFuNeiRong",   SqlDbType.NVarChar,   200),
                new SqlParameter("@HuiFuShiJian",   SqlDbType.DateTime),
                new SqlParameter("@HuiFuRen",       SqlDbType.NVarChar,    12),
                new SqlParameter("@BeiZhu",         SqlDbType.NVarChar,   200),
                new SqlParameter("@BianHao",        SqlDbType.Int,          4),
                new SqlParameter("@BiaoTi",         SqlDbType.NChar, 20)
            };
            parameters[0].Value  = model.NeiRong;
            parameters[1].Value  = model.LiuYanRen;
            parameters[2].Value  = model.EMail;
            parameters[3].Value  = model.DianHua;
            parameters[4].Value  = model.BiaoQing;
            parameters[5].Value  = model.LiuYanShiJian;
            parameters[6].Value  = model.HuiFuZhuangTai;
            parameters[7].Value  = model.HuiFuNeiRong;
            parameters[8].Value  = model.HuiFuShiJian;
            parameters[9].Value  = model.HuiFuRen;
            parameters[10].Value = model.BeiZhu;
            parameters[11].Value = model.BianHao;
            parameters[12].Value = model.BiaoTi;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SDAU.ZHCZ.Model.LiuYanBan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into LiuYanBan(");
            strSql.Append("BiaoTi,NeiRong,LiuYanRen,EMail,DianHua,BiaoQing,LiuYanShiJian,HuiFuZhuangTai,HuiFuNeiRong,HuiFuShiJian,HuiFuRen,BeiZhu)");
            strSql.Append(" values (");
            strSql.Append("@BiaoTi,@NeiRong,@LiuYanRen,@EMail,@DianHua,@BiaoQing,@LiuYanShiJian,@HuiFuZhuangTai,@HuiFuNeiRong,@HuiFuShiJian,@HuiFuRen,@BeiZhu)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BiaoTi",         SqlDbType.NChar,       20),
                new SqlParameter("@NeiRong",        SqlDbType.NVarChar,  1000),
                new SqlParameter("@LiuYanRen",      SqlDbType.NVarChar,    12),
                new SqlParameter("@EMail",          SqlDbType.NVarChar,    20),
                new SqlParameter("@DianHua",        SqlDbType.NVarChar,    12),
                new SqlParameter("@BiaoQing",       SqlDbType.VarBinary,   -1),
                new SqlParameter("@LiuYanShiJian",  SqlDbType.DateTime),
                new SqlParameter("@HuiFuZhuangTai", SqlDbType.NVarChar,    10),
                new SqlParameter("@HuiFuNeiRong",   SqlDbType.NVarChar,   200),
                new SqlParameter("@HuiFuShiJian",   SqlDbType.DateTime),
                new SqlParameter("@HuiFuRen",       SqlDbType.NVarChar,    12),
                new SqlParameter("@BeiZhu",         SqlDbType.NVarChar, 200)
            };
            parameters[0].Value  = model.BiaoTi;
            parameters[1].Value  = model.NeiRong;
            parameters[2].Value  = model.LiuYanRen;
            parameters[3].Value  = model.EMail;
            parameters[4].Value  = model.DianHua;
            parameters[5].Value  = model.BiaoQing;
            parameters[6].Value  = model.LiuYanShiJian;
            parameters[7].Value  = model.HuiFuZhuangTai;
            parameters[8].Value  = model.HuiFuNeiRong;
            parameters[9].Value  = model.HuiFuShiJian;
            parameters[10].Value = model.HuiFuRen;
            parameters[11].Value = model.BeiZhu;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SDAU.ZHCZ.Model.LiuYanBan GetModel(int BianHao)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 BianHao,BiaoTi,NeiRong,LiuYanRen,EMail,DianHua,BiaoQing,LiuYanShiJian,HuiFuZhuangTai,HuiFuNeiRong,HuiFuShiJian,HuiFuRen,BeiZhu from LiuYanBan ");
            strSql.Append(" where BianHao=@BianHao");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BianHao", SqlDbType.Int, 4)
            };
            parameters[0].Value = BianHao;

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

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