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

            strSql.Append("insert into ApplyList(");
            strSql.Append("Name,Addr,Tel,Contact,Email,Descr,UId,AType,Status,CreateDate,UpdateDate)");

            strSql.Append(" values (");
            strSql.Append("@Name,@Addr,@Tel,@Contact,@Email,@Descr,@UId,@AType,@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, "Addr", DbType.String, model.Addr);
            db.AddInParameter(dbCommand, "Tel", DbType.String, model.Tel);
            db.AddInParameter(dbCommand, "Contact", DbType.String, model.Contact);
            db.AddInParameter(dbCommand, "Email", DbType.String, model.Email);
            db.AddInParameter(dbCommand, "Descr", DbType.String, model.Descr);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, model.UId);
            db.AddInParameter(dbCommand, "AType", DbType.Byte, model.AType);
            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);
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.ApplyList DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.ApplyList model = new ECommerce.Admin.Model.ApplyList();
     if (row != null)
     {
         if (row["ALID"] != null && row["ALID"].ToString() != "")
         {
             model.ALID = Convert.ToInt32(row["ALID"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Addr"] != null)
         {
             model.Addr = row["Addr"].ToString();
         }
         if (row["Tel"] != null)
         {
             model.Tel = row["Tel"].ToString();
         }
         if (row["Contact"] != null)
         {
             model.Contact = row["Contact"].ToString();
         }
         if (row["Email"] != null)
         {
             model.Email = row["Email"].ToString();
         }
         if (row["Descr"] != null)
         {
             model.Descr = row["Descr"].ToString();
         }
         if (row["UId"] != null && row["UId"].ToString() != "")
         {
             model.UId = Convert.ToInt32(row["UId"].ToString());
         }
         if (row["AType"] != null && row["AType"].ToString() != "")
         {
             model.AType = Convert.ToInt32(row["AType"].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);
 }
예제 #3
0
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            var name    = txtname.Value.Trim();
            var addr    = txtAddr.Value.Trim();
            var tel     = txtTel.Value.Trim();
            var contact = txtContact.Value.Trim();

            if (string.IsNullOrEmpty(name))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写企业名称!');</script>");
                return;
            }
            if (string.IsNullOrEmpty(addr))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写企业地址!');</script>");
                return;
            }
            if (string.IsNullOrEmpty(contact))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写联系人!');</script>");
                return;
            }
            if (string.IsNullOrEmpty(tel))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写联系电话!');</script>");
                return;
            }
            var model = new ECommerce.Admin.Model.ApplyList {
                Addr       = addr,
                CreateDate = DateTime.Now,
                Tel        = tel,
                Contact    = contact,
                Name       = name,
                Status     = 0,
                AType      = 2
            };
            var exists = _applyListDal.GetModel(" Name='" + name + "' and AType=2 and Status = 0 ", new List <SqlParameter>());

            if (null != exists)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('企业已提交过申请!');</script>");
                return;
            }
            var resAdd = _applyListDal.Add(model);

            if (resAdd > 0)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('申请成功!');</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('申请失败!');</script>");
            }
        }
예제 #4
0
 protected void Unnamed1_Click(object sender, EventArgs e)
 {
     var name = txtname.Value.Trim();
     var addr = txtAddr.Value.Trim();
     var tel = txtTel.Value.Trim();
     var contact = txtContact.Value.Trim();
     if (string.IsNullOrEmpty(name)) {
         Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写企业名称!');</script>");
         return;
     }
     if (string.IsNullOrEmpty(addr)) {
         Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写企业地址!');</script>");
         return;
     }
     if (string.IsNullOrEmpty(contact)) {
         Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写联系人!');</script>");
         return;
     }
     if (string.IsNullOrEmpty(tel)) {
         Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写联系电话!');</script>");
         return;
     }
     var model = new ECommerce.Admin.Model.ApplyList {
         Addr = addr,
         CreateDate = DateTime.Now,
         Tel = tel,
         Contact = contact,
         Name = name,
         Status = 0,
         AType = 1
     };
     var exists = _applyListDal.GetModel(" Name='" + name + "' and AType=1 and Status = 0 ", new List<SqlParameter>());
     if (null != exists) {
         Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('企业已提交过申请!');</script>");
         return;
     }
     var resAdd = _applyListDal.Add(model);
     if (resAdd > 0) {
         Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('申请成功!');</script>");
     }
     else {
         Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('申请失败!');</script>");
     }
 }
예제 #5
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ECommerce.Admin.Model.ApplyList ReaderBind(IDataReader dataReader)
        {
            ECommerce.Admin.Model.ApplyList model = new ECommerce.Admin.Model.ApplyList();
            object ojb;

            ojb = dataReader["ALID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ALID = Convert.ToInt32(ojb);
            }
            model.Name    = dataReader["Name"].ToString();
            model.Addr    = dataReader["Addr"].ToString();
            model.Tel     = dataReader["Tel"].ToString();
            model.Contact = dataReader["Contact"].ToString();
            model.Email   = dataReader["Email"].ToString();
            model.Descr   = dataReader["Descr"].ToString();
            ojb           = dataReader["UId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UId = Convert.ToInt32(ojb);
            }
            ojb = dataReader["AType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AType = 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);
        }
예제 #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ECommerce.Admin.Model.ApplyList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ApplyList set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Addr=@Addr,");
            strSql.Append("Tel=@Tel,");
            strSql.Append("Contact=@Contact,");
            strSql.Append("Email=@Email,");
            strSql.Append("Descr=@Descr,");
            strSql.Append("UId=@UId,");
            strSql.Append("AType=@AType,");
            strSql.Append("Status=@Status,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("UpdateDate=@UpdateDate");
            strSql.Append(" where ALID=@ALID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ALID", DbType.Int32, model.ALID);
            db.AddInParameter(dbCommand, "Name", DbType.String, model.Name);
            db.AddInParameter(dbCommand, "Addr", DbType.String, model.Addr);
            db.AddInParameter(dbCommand, "Tel", DbType.String, model.Tel);
            db.AddInParameter(dbCommand, "Contact", DbType.String, model.Contact);
            db.AddInParameter(dbCommand, "Email", DbType.String, model.Email);
            db.AddInParameter(dbCommand, "Descr", DbType.String, model.Descr);
            db.AddInParameter(dbCommand, "UId", DbType.Int32, model.UId);
            db.AddInParameter(dbCommand, "AType", DbType.Byte, model.AType);
            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);
            }
        }
예제 #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ECommerce.Admin.Model.ApplyList GetModel(int ALID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ALID,Name,Addr,Tel,Contact,Email,Descr,UId,AType,Status,CreateDate,UpdateDate from ApplyList ");
            strSql.Append(" where ALID=@ALID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ALID", DbType.Int32, ALID);
            ECommerce.Admin.Model.ApplyList model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
예제 #8
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.ApplyList DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.ApplyList model=new ECommerce.Admin.Model.ApplyList();
     if (row != null)
     {
         if(row["ALID"]!=null && row["ALID"].ToString()!="")
         {
             model.ALID=Convert.ToInt32(row["ALID"].ToString());
         }
         if(row["Name"]!=null)
         {
             model.Name=row["Name"].ToString();
         }
         if(row["Addr"]!=null)
         {
             model.Addr=row["Addr"].ToString();
         }
         if(row["Tel"]!=null)
         {
             model.Tel=row["Tel"].ToString();
         }
         if(row["Contact"]!=null)
         {
             model.Contact=row["Contact"].ToString();
         }
         if(row["Email"]!=null)
         {
             model.Email=row["Email"].ToString();
         }
         if(row["Descr"]!=null)
         {
             model.Descr=row["Descr"].ToString();
         }
         if(row["UId"]!=null && row["UId"].ToString()!="")
         {
             model.UId=Convert.ToInt32(row["UId"].ToString());
         }
         if(row["AType"]!=null && row["AType"].ToString()!="")
         {
             model.AType=Convert.ToInt32(row["AType"].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;
 }
예제 #9
0
 /// <summary>
 /// 对象实体绑定数据
 /// </summary>
 public ECommerce.Admin.Model.ApplyList ReaderBind(IDataReader dataReader)
 {
     ECommerce.Admin.Model.ApplyList model=new ECommerce.Admin.Model.ApplyList();
     object ojb;
     ojb = dataReader["ALID"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.ALID=Convert.ToInt32(ojb);
     }
     model.Name=dataReader["Name"].ToString();
     model.Addr=dataReader["Addr"].ToString();
     model.Tel=dataReader["Tel"].ToString();
     model.Contact=dataReader["Contact"].ToString();
     model.Email=dataReader["Email"].ToString();
     model.Descr=dataReader["Descr"].ToString();
     ojb = dataReader["UId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.UId=Convert.ToInt32(ojb);
     }
     ojb = dataReader["AType"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.AType=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;
 }