示例#1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SDAU.Model.YongHuPingLun DataRowToModel(DataRow row)
 {
     SDAU.Model.YongHuPingLun model = new SDAU.Model.YongHuPingLun();
     if (row != null)
     {
         if (row["PLBianHao"] != null && row["PLBianHao"].ToString() != "")
         {
             model.PLBianHao = int.Parse(row["PLBianHao"].ToString());
         }
         if (row["ZWBianHao"] != null && row["ZWBianHao"].ToString() != "")
         {
             model.ZWBianHao = int.Parse(row["ZWBianHao"].ToString());
         }
         if (row["YHBianHao"] != null && row["YHBianHao"].ToString() != "")
         {
             model.YHBianHao = int.Parse(row["YHBianHao"].ToString());
         }
         if (row["NeiRong"] != null)
         {
             model.NeiRong = row["NeiRong"].ToString();
         }
         if (row["PLShiJian"] != null && row["PLShiJian"].ToString() != "")
         {
             model.PLShiJian = DateTime.Parse(row["PLShiJian"].ToString());
         }
         if (row["BeiZhu"] != null)
         {
             model.BeiZhu = row["BeiZhu"].ToString();
         }
     }
     return(model);
 }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SDAU.Model.YongHuPingLun model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into YongHuPingLun(");
            strSql.Append("ZWBianHao,YHBianHao,NeiRong,PLShiJian,BeiZhu)");
            strSql.Append(" values (");
            strSql.Append("@ZWBianHao,@YHBianHao,@NeiRong,@PLShiJian,@BeiZhu)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ZWBianHao", SqlDbType.Int,        4),
                new SqlParameter("@YHBianHao", SqlDbType.Int,        4),
                new SqlParameter("@NeiRong",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@PLShiJian", SqlDbType.DateTime),
                new SqlParameter("@BeiZhu",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.ZWBianHao;
            parameters[1].Value = model.YHBianHao;
            parameters[2].Value = model.NeiRong;
            parameters[3].Value = model.PLShiJian;
            parameters[4].Value = model.BeiZhu;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SDAU.Model.YongHuPingLun model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update YongHuPingLun set ");
            strSql.Append("YHBianHao=@YHBianHao,");
            strSql.Append("NeiRong=@NeiRong,");
            strSql.Append("PLShiJian=@PLShiJian,");
            strSql.Append("BeiZhu=@BeiZhu");
            strSql.Append(" where PLBianHao=@PLBianHao");
            SqlParameter[] parameters =
            {
                new SqlParameter("@YHBianHao", SqlDbType.Int,        4),
                new SqlParameter("@NeiRong",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@PLShiJian", SqlDbType.DateTime),
                new SqlParameter("@BeiZhu",    SqlDbType.NVarChar,  50),
                new SqlParameter("@PLBianHao", SqlDbType.Int,        4),
                new SqlParameter("@ZWBianHao", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.YHBianHao;
            parameters[1].Value = model.NeiRong;
            parameters[2].Value = model.PLShiJian;
            parameters[3].Value = model.BeiZhu;
            parameters[4].Value = model.PLBianHao;
            parameters[5].Value = model.ZWBianHao;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SDAU.Model.YongHuPingLun GetModel(int PLBianHao)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 PLBianHao,ZWBianHao,YHBianHao,NeiRong,PLShiJian,BeiZhu from YongHuPingLun ");
            strSql.Append(" where PLBianHao=@PLBianHao");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PLBianHao", SqlDbType.Int, 4)
            };
            parameters[0].Value = PLBianHao;

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

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