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

            strSql.Append("insert into OrgCustomer(");
            strSql.Append("OrgId,Name,Sex,Birthday,HomeAddress,SelfCard,AddTime,Status,UId,UserName,Password,Mobile)");

            strSql.Append(" values (");
            strSql.Append("@OrgId,@Name,@Sex,@Birthday,@HomeAddress,@SelfCard,@AddTime,@Status,@UId,@UserName,@Password,@Mobile)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "OrgId", DbType.Int64, model.OrgId);
            db.AddInParameter(dbCommand, "Name", DbType.String, model.Name);
            db.AddInParameter(dbCommand, "Sex", DbType.String, model.Sex);
            db.AddInParameter(dbCommand, "Birthday", DbType.DateTime, model.Birthday);
            db.AddInParameter(dbCommand, "HomeAddress", DbType.String, model.HomeAddress);
            db.AddInParameter(dbCommand, "SelfCard", DbType.AnsiString, model.SelfCard);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, model.UId);
            db.AddInParameter(dbCommand, "UserName", DbType.AnsiString, model.UserName);
            db.AddInParameter(dbCommand, "Password", DbType.AnsiString, model.Password);
            db.AddInParameter(dbCommand, "Mobile", DbType.AnsiString, model.Mobile);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.OrgCustomer DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.OrgCustomer model = new ECommerce.Admin.Model.OrgCustomer();
     if (row != null)
     {
         if (row["CId"] != null && row["CId"].ToString() != "")
         {
             model.CId = Convert.ToInt32(row["CId"].ToString());
         }
         if (row["OrgId"] != null && row["OrgId"].ToString() != "")
         {
             model.OrgId = Convert.ToInt64(row["OrgId"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Sex"] != null)
         {
             model.Sex = row["Sex"].ToString();
         }
         if (row["Birthday"] != null && row["Birthday"].ToString() != "")
         {
             model.Birthday = Convert.ToDateTime(row["Birthday"].ToString());
         }
         if (row["HomeAddress"] != null)
         {
             model.HomeAddress = row["HomeAddress"].ToString();
         }
         if (row["SelfCard"] != null)
         {
             model.SelfCard = row["SelfCard"].ToString();
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = Convert.ToDateTime(row["AddTime"].ToString());
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = Convert.ToInt32(row["Status"].ToString());
         }
         if (row["UId"] != null && row["UId"].ToString() != "")
         {
             model.UId = Convert.ToInt32(row["UId"].ToString());
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["Password"] != null)
         {
             model.Password = row["Password"].ToString();
         }
         if (row["Mobile"] != null)
         {
             model.Mobile = row["Mobile"].ToString();
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ECommerce.Admin.Model.OrgCustomer model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OrgCustomer set ");
            strSql.Append("OrgId=@OrgId,");
            strSql.Append("Name=@Name,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("Birthday=@Birthday,");
            strSql.Append("HomeAddress=@HomeAddress,");
            strSql.Append("SelfCard=@SelfCard,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("Status=@Status,");
            strSql.Append("UId=@UId,");
            strSql.Append("UserName=@UserName,");
            strSql.Append("Password=@Password,");
            strSql.Append("Mobile=@Mobile");
            strSql.Append(" where CId=@CId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "CId", DbType.Int32, model.CId);
            db.AddInParameter(dbCommand, "OrgId", DbType.Int64, model.OrgId);
            db.AddInParameter(dbCommand, "Name", DbType.String, model.Name);
            db.AddInParameter(dbCommand, "Sex", DbType.String, model.Sex);
            db.AddInParameter(dbCommand, "Birthday", DbType.DateTime, model.Birthday);
            db.AddInParameter(dbCommand, "HomeAddress", DbType.String, model.HomeAddress);
            db.AddInParameter(dbCommand, "SelfCard", DbType.AnsiString, model.SelfCard);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, model.UId);
            db.AddInParameter(dbCommand, "UserName", DbType.AnsiString, model.UserName);
            db.AddInParameter(dbCommand, "Password", DbType.AnsiString, model.Password);
            db.AddInParameter(dbCommand, "Mobile", DbType.AnsiString, model.Mobile);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ECommerce.Admin.Model.OrgCustomer ReaderBind(IDataReader dataReader)
        {
            ECommerce.Admin.Model.OrgCustomer model = new ECommerce.Admin.Model.OrgCustomer();
            object ojb;

            ojb = dataReader["CId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CId = Convert.ToInt32(ojb);
            }
            ojb = dataReader["OrgId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OrgId = Convert.ToInt64(ojb);
            }
            model.Name = dataReader["Name"].ToString();
            model.Sex  = dataReader["Sex"].ToString();
            ojb        = dataReader["Birthday"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Birthday = Convert.ToDateTime(ojb);
            }
            model.HomeAddress = dataReader["HomeAddress"].ToString();
            model.SelfCard    = dataReader["SelfCard"].ToString();
            ojb = dataReader["AddTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AddTime = Convert.ToDateTime(ojb);
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = Convert.ToInt32(ojb);
            }
            ojb = dataReader["UId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UId = Convert.ToInt32(ojb);
            }
            model.UserName = dataReader["UserName"].ToString();
            model.Password = dataReader["Password"].ToString();
            model.Mobile   = dataReader["Mobile"].ToString();
            return(model);
        }
예제 #5
0
        /// <summary>
        /// 根据用户名获取用户ID
        /// </summary>
        public ECommerce.Admin.Model.OrgCustomer GetModelByUserName(string UserName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select CId,OrgId,Name,Sex,Birthday,HomeAddress,SelfCard,AddTime,Status,UId,UserName,Password,Mobile,Des,Age,Nickname,WineAge,ProductLike,Point,RecName from OrgCustomer ");
            strSql.Append(" where UserName=@UserName ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "UserName", DbType.String, UserName);
            ECommerce.Admin.Model.OrgCustomer model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ECommerce.Admin.Model.OrgCustomer GetModel(int CId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select CId,OrgId,Name,Sex,Birthday,HomeAddress,SelfCard,AddTime,Status,UId,UserName,Password,Mobile from OrgCustomer ");
            strSql.Append(" where CId=@CId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "CId", DbType.Int32, CId);
            ECommerce.Admin.Model.OrgCustomer model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
예제 #7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.OrgCustomer DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.OrgCustomer model = new ECommerce.Admin.Model.OrgCustomer();
     if (row != null)
     {
         if (row["CId"] != null && row["CId"].ToString() != "")
         {
             model.CId = Convert.ToInt32(row["CId"].ToString());
         }
         if (row["OrgId"] != null && row["OrgId"].ToString() != "")
         {
             model.OrgId = Convert.ToInt64(row["OrgId"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Sex"] != null)
         {
             model.Sex = row["Sex"].ToString();
         }
         if (row["Birthday"] != null && row["Birthday"].ToString() != "")
         {
             model.Birthday = Convert.ToDateTime(row["Birthday"].ToString());
         }
         if (row["HomeAddress"] != null)
         {
             model.HomeAddress = row["HomeAddress"].ToString();
         }
         if (row["SelfCard"] != null)
         {
             model.SelfCard = row["SelfCard"].ToString();
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = Convert.ToDateTime(row["AddTime"].ToString());
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = Convert.ToInt32(row["Status"].ToString());
         }
         if (row["UId"] != null && row["UId"].ToString() != "")
         {
             model.UId = Convert.ToInt32(row["UId"].ToString());
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["Password"] != null)
         {
             model.Password = row["Password"].ToString();
         }
         if (row["Mobile"] != null)
         {
             model.Mobile = row["Mobile"].ToString();
         }
     }
     return model;
 }
예제 #8
0
 /// <summary>
 /// 对象实体绑定数据
 /// </summary>
 public ECommerce.Admin.Model.OrgCustomer ReaderBind(IDataReader dataReader)
 {
     ECommerce.Admin.Model.OrgCustomer model = new ECommerce.Admin.Model.OrgCustomer();
     object ojb;
     ojb = dataReader["CId"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.CId = Convert.ToInt32(ojb);
     }
     ojb = dataReader["OrgId"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.OrgId = Convert.ToInt64(ojb);
     }
     model.Name = dataReader["Name"].ToString();
     model.Sex = dataReader["Sex"].ToString();
     ojb = dataReader["Birthday"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.Birthday = Convert.ToDateTime(ojb);
     }
     model.HomeAddress = dataReader["HomeAddress"].ToString();
     model.SelfCard = dataReader["SelfCard"].ToString();
     ojb = dataReader["AddTime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.AddTime = Convert.ToDateTime(ojb);
     }
     ojb = dataReader["Status"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.Status = Convert.ToInt32(ojb);
     }
     ojb = dataReader["UId"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.UId = Convert.ToInt32(ojb);
     }
     model.UserName = dataReader["UserName"].ToString();
     model.Password = dataReader["Password"].ToString();
     model.Mobile = dataReader["Mobile"].ToString();
     return model;
 }