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

            strSql.Append("insert into CustomerService(");
            strSql.Append("ComID,UId,CS1,INN4,HF22,CS2,CS4,NLD,CreateDate,UpdateDate)");

            strSql.Append(" values (");
            strSql.Append("@ComID,@UId,@CS1,@INN4,@HF22,@CS2,@CS4,@NLD,@CreateDate,@UpdateDate)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ComID", DbType.String, model.ComID);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, model.UId);
            db.AddInParameter(dbCommand, "CS1", DbType.String, model.CS1);
            db.AddInParameter(dbCommand, "INN4", DbType.String, model.INN4);
            db.AddInParameter(dbCommand, "HF22", DbType.String, model.HF22);
            db.AddInParameter(dbCommand, "CS2", DbType.String, model.CS2);
            db.AddInParameter(dbCommand, "CS4", DbType.String, model.CS4);
            db.AddInParameter(dbCommand, "NLD", DbType.String, model.NLD);
            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);
        }
Esempio n. 2
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ECommerce.Admin.Model.CustomerService ReaderBind(IDataReader dataReader)
        {
            ECommerce.Admin.Model.CustomerService model = new ECommerce.Admin.Model.CustomerService();
            object ojb;

            ojb = dataReader["ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ID = Convert.ToInt32(ojb);
            }
            model.ComID = dataReader["ComID"].ToString();
            ojb         = dataReader["UId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UId = Convert.ToInt32(ojb);
            }
            model.CS1  = dataReader["CS1"].ToString();
            model.INN4 = dataReader["INN4"].ToString();
            model.HF22 = dataReader["HF22"].ToString();
            model.CS2  = dataReader["CS2"].ToString();
            model.CS4  = dataReader["CS4"].ToString();
            model.NLD  = dataReader["NLD"].ToString();
            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);
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.CustomerService DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.CustomerService model = new ECommerce.Admin.Model.CustomerService();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = Convert.ToInt32(row["ID"].ToString());
         }
         if (row["ComID"] != null)
         {
             model.ComID = row["ComID"].ToString();
         }
         if (row["UId"] != null && row["UId"].ToString() != "")
         {
             model.UId = Convert.ToInt32(row["UId"].ToString());
         }
         if (row["CS1"] != null)
         {
             model.CS1 = row["CS1"].ToString();
         }
         if (row["INN4"] != null)
         {
             model.INN4 = row["INN4"].ToString();
         }
         if (row["HF22"] != null)
         {
             model.HF22 = row["HF22"].ToString();
         }
         if (row["CS2"] != null)
         {
             model.CS2 = row["CS2"].ToString();
         }
         if (row["CS4"] != null)
         {
             model.CS4 = row["CS4"].ToString();
         }
         if (row["NLD"] != null)
         {
             model.NLD = row["NLD"].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);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ECommerce.Admin.Model.CustomerService GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,ComID,UId,CS1,INN4,HF22,CS2,CS4,NLD,CreateDate,UpdateDate from CustomerService ");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);
            ECommerce.Admin.Model.CustomerService model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Esempio n. 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ECommerce.Admin.Model.CustomerService model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CustomerService set ");
            strSql.Append("ComID=@ComID,");
            strSql.Append("UId=@UId,");
            strSql.Append("CS1=@CS1,");
            strSql.Append("INN4=@INN4,");
            strSql.Append("HF22=@HF22,");
            strSql.Append("CS2=@CS2,");
            strSql.Append("CS4=@CS4,");
            strSql.Append("NLD=@NLD,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("UpdateDate=@UpdateDate");
            strSql.Append(" where ID=@ID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.Int32, model.ID);
            db.AddInParameter(dbCommand, "ComID", DbType.String, model.ComID);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, model.UId);
            db.AddInParameter(dbCommand, "CS1", DbType.String, model.CS1);
            db.AddInParameter(dbCommand, "INN4", DbType.String, model.INN4);
            db.AddInParameter(dbCommand, "HF22", DbType.String, model.HF22);
            db.AddInParameter(dbCommand, "CS2", DbType.String, model.CS2);
            db.AddInParameter(dbCommand, "CS4", DbType.String, model.CS4);
            db.AddInParameter(dbCommand, "NLD", DbType.String, model.NLD);
            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);
            }
        }