Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Matisoft.Model.Affire model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Affire set ");
            strSql.Append("CustomerEmail=@CustomerEmail,");
            strSql.Append("TimeDate=@TimeDate,");
            strSql.Append("OperationID=@OperationID");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CustomerEmail", SqlDbType.NVarChar,  50),
                new SqlParameter("@TimeDate",      SqlDbType.DateTime),
                new SqlParameter("@OperationID",   SqlDbType.Int,        4),
                new SqlParameter("@id",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CustomerEmail;
            parameters[1].Value = model.TimeDate;
            parameters[2].Value = model.OperationID;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Matisoft.Model.Affire model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Affire(");
            strSql.Append("CustomerEmail,TimeDate,OperationID)");
            strSql.Append(" values (");
            strSql.Append("@CustomerEmail,@TimeDate,@OperationID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CustomerEmail", SqlDbType.NVarChar,  50),
                new SqlParameter("@TimeDate",      SqlDbType.DateTime),
                new SqlParameter("@OperationID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CustomerEmail;
            parameters[1].Value = model.TimeDate;
            parameters[2].Value = model.OperationID;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Matisoft.Model.Affire DataRowToModel(DataRow row)
 {
     Matisoft.Model.Affire model = new Matisoft.Model.Affire();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["CustomerEmail"] != null)
         {
             model.CustomerEmail = row["CustomerEmail"].ToString();
         }
         if (row["TimeDate"] != null && row["TimeDate"].ToString() != "")
         {
             model.TimeDate = DateTime.Parse(row["TimeDate"].ToString());
         }
         if (row["OperationID"] != null && row["OperationID"].ToString() != "")
         {
             model.OperationID = int.Parse(row["OperationID"].ToString());
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Matisoft.Model.Affire GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,CustomerEmail,TimeDate,OperationID from Affire ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Matisoft.Model.Affire DataRowToModel(DataRow row)
 {
     Matisoft.Model.Affire model=new Matisoft.Model.Affire();
     if (row != null)
     {
         if(row["id"]!=null && row["id"].ToString()!="")
         {
             model.id=int.Parse(row["id"].ToString());
         }
         if(row["CustomerEmail"]!=null)
         {
             model.CustomerEmail=row["CustomerEmail"].ToString();
         }
         if(row["TimeDate"]!=null && row["TimeDate"].ToString()!="")
         {
             model.TimeDate=DateTime.Parse(row["TimeDate"].ToString());
         }
         if(row["OperationID"]!=null && row["OperationID"].ToString()!="")
         {
             model.OperationID=int.Parse(row["OperationID"].ToString());
         }
     }
     return model;
 }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Matisoft.Model.Affire GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,CustomerEmail,TimeDate,OperationID from Affire ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

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