Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ECommerce.Admin.Model.ProfType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProfType(");
            strSql.Append("Name,UId,Status,CreateDate,UpdateDate)");

            strSql.Append(" values (");
            strSql.Append("@Name,@UId,@Status,@CreateDate,@UpdateDate)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "Name", DbType.String, model.Name);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, model.UId);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, model.CreateDate);
            db.AddInParameter(dbCommand, "UpdateDate", DbType.DateTime, model.UpdateDate);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.ProfType DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.ProfType model=new ECommerce.Admin.Model.ProfType();
     if (row != null)
     {
         if(row["PTID"]!=null && row["PTID"].ToString()!="")
         {
             model.PTID=Convert.ToInt32(row["PTID"].ToString());
         }
         if(row["Name"]!=null)
         {
             model.Name=row["Name"].ToString();
         }
         if(row["UId"]!=null && row["UId"].ToString()!="")
         {
             model.UId=Convert.ToInt32(row["UId"].ToString());
         }
         if(row["Status"]!=null && row["Status"].ToString()!="")
         {
             model.Status=Convert.ToInt32(row["Status"].ToString());
         }
         if(row["CreateDate"]!=null && row["CreateDate"].ToString()!="")
         {
             model.CreateDate=Convert.ToDateTime(row["CreateDate"].ToString());
         }
         if(row["UpdateDate"]!=null && row["UpdateDate"].ToString()!="")
         {
             model.UpdateDate=Convert.ToDateTime(row["UpdateDate"].ToString());
         }
     }
     return model;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ECommerce.Admin.Model.ProfType ReaderBind(IDataReader dataReader)
        {
            ECommerce.Admin.Model.ProfType model = new ECommerce.Admin.Model.ProfType();
            object ojb;

            ojb = dataReader["PTID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.PTID = Convert.ToInt32(ojb);
            }
            model.Name = dataReader["Name"].ToString();
            ojb        = dataReader["UId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UId = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = Convert.ToInt32(ojb);
            }
            ojb = dataReader["CreateDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateDate = Convert.ToDateTime(ojb);
            }
            ojb = dataReader["UpdateDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UpdateDate = Convert.ToDateTime(ojb);
            }
            return(model);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.ProfType DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.ProfType model = new ECommerce.Admin.Model.ProfType();
     if (row != null)
     {
         if (row["PTID"] != null && row["PTID"].ToString() != "")
         {
             model.PTID = Convert.ToInt32(row["PTID"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["UId"] != null && row["UId"].ToString() != "")
         {
             model.UId = Convert.ToInt32(row["UId"].ToString());
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = Convert.ToInt32(row["Status"].ToString());
         }
         if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
         {
             model.CreateDate = Convert.ToDateTime(row["CreateDate"].ToString());
         }
         if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "")
         {
             model.UpdateDate = Convert.ToDateTime(row["UpdateDate"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ECommerce.Admin.Model.ProfType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProfType set ");
            strSql.Append("Name=@Name,");
            strSql.Append("UId=@UId,");
            strSql.Append("Status=@Status,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("UpdateDate=@UpdateDate");
            strSql.Append(" where PTID=@PTID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "PTID", DbType.Int32, model.PTID);
            db.AddInParameter(dbCommand, "Name", DbType.String, model.Name);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, model.UId);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, model.CreateDate);
            db.AddInParameter(dbCommand, "UpdateDate", DbType.DateTime, model.UpdateDate);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ECommerce.Admin.Model.ProfType GetModel(int PTID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select PTID,Name,UId,Status,CreateDate,UpdateDate from ProfType ");
            strSql.Append(" where PTID=@PTID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "PTID", DbType.Int32, PTID);
            ECommerce.Admin.Model.ProfType model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 对象实体绑定数据
 /// </summary>
 public ECommerce.Admin.Model.ProfType ReaderBind(IDataReader dataReader)
 {
     ECommerce.Admin.Model.ProfType model=new ECommerce.Admin.Model.ProfType();
     object ojb;
     ojb = dataReader["PTID"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.PTID=Convert.ToInt32(ojb);
     }
     model.Name=dataReader["Name"].ToString();
     ojb = dataReader["UId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.UId=Convert.ToInt32(ojb);
     }
     ojb = dataReader["Status"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.Status=Convert.ToInt32(ojb);
     }
     ojb = dataReader["CreateDate"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.CreateDate=Convert.ToDateTime(ojb);
     }
     ojb = dataReader["UpdateDate"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.UpdateDate=Convert.ToDateTime(ojb);
     }
     return model;
 }