Example #1
0
 /// <summary>
 /// 绑定数据
 /// </summary>
 private void BindData()
 {
     //读取Config表的数据
     //页面填空
     oyxf.Model.Config config = bllConfig.GetModel(1);
     if (config != null)
     {
         ViewState["ConfigId"]     = config.ConfigId;
         txtCopyright.Text         = config.Copyright;
         imgAboutImgUrl.ImageUrl   = config.AboutImgUrl;
         txtAboutImgUrl.Text       = config.AboutImgUrl;
         txtAboutIntro.Text        = config.AboutIntro;
         txtAboutUrl.Text          = config.AboutUrl;
         txtNewsUrl.Text           = config.NewsUrl;
         imgContactImgUrl.ImageUrl = config.ContactImgUrl;
         txtContactImgUrl.Text     = config.ContactImgUrl;
         txtContactUrl.Text        = config.ContactUrl;
         txtCompanyName.Text       = config.CompanyName;
         txtAddress.Text           = config.Address;
         txtPostcode.Text          = config.Postcode.ToString();
         txtTelephone.Text         = config.Telephone;
         txtWebsite.Text           = config.Website;
         txtEmail.Text             = config.Email;
         txtProductUrl.Text        = config.ProductUrl;
     }
 }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(oyxf.Model.Config model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Config(");
            strSql.Append("Copyright,AboutImgUrl,AboutIntro,AboutUrl,NewsUrl,ContactImgUrl,ContactUrl,CompanyName,Address,Postcode,Telephone,Website,Email,ProductUrl)");
            strSql.Append(" values (");
            strSql.Append("@Copyright,@AboutImgUrl,@AboutIntro,@AboutUrl,@NewsUrl,@ContactImgUrl,@ContactUrl,@CompanyName,@Address,@Postcode,@Telephone,@Website,@Email,@ProductUrl)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Copyright",     SqlDbType.NVarChar, 100),
                new SqlParameter("@AboutImgUrl",   SqlDbType.VarChar,  100),
                new SqlParameter("@AboutIntro",    SqlDbType.NVarChar, 200),
                new SqlParameter("@AboutUrl",      SqlDbType.VarChar,   50),
                new SqlParameter("@NewsUrl",       SqlDbType.VarChar,   50),
                new SqlParameter("@ContactImgUrl", SqlDbType.VarChar,  100),
                new SqlParameter("@ContactUrl",    SqlDbType.VarChar,   50),
                new SqlParameter("@CompanyName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Address",       SqlDbType.NVarChar, 100),
                new SqlParameter("@Postcode",      SqlDbType.Int,        4),
                new SqlParameter("@Telephone",     SqlDbType.VarChar,   15),
                new SqlParameter("@Website",       SqlDbType.VarChar,   30),
                new SqlParameter("@Email",         SqlDbType.VarChar,   30),
                new SqlParameter("@ProductUrl",    SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.Copyright;
            parameters[1].Value  = model.AboutImgUrl;
            parameters[2].Value  = model.AboutIntro;
            parameters[3].Value  = model.AboutUrl;
            parameters[4].Value  = model.NewsUrl;
            parameters[5].Value  = model.ContactImgUrl;
            parameters[6].Value  = model.ContactUrl;
            parameters[7].Value  = model.CompanyName;
            parameters[8].Value  = model.Address;
            parameters[9].Value  = model.Postcode;
            parameters[10].Value = model.Telephone;
            parameters[11].Value = model.Website;
            parameters[12].Value = model.Email;
            parameters[13].Value = model.ProductUrl;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public oyxf.Model.Config GetModel(int ConfigId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ConfigId,Copyright,AboutImgUrl,AboutIntro,AboutUrl,NewsUrl,ContactImgUrl,ContactUrl,CompanyName,Address,Postcode,Telephone,Website,Email,ProductUrl from Config ");
            strSql.Append(" where ConfigId=@ConfigId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ConfigId", SqlDbType.Int, 4)
            };
            parameters[0].Value = ConfigId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public oyxf.Model.Config DataRowToModel(DataRow row)
 {
     oyxf.Model.Config model = new oyxf.Model.Config();
     if (row != null)
     {
         if (row["ConfigId"] != null && row["ConfigId"].ToString() != "")
         {
             model.ConfigId = int.Parse(row["ConfigId"].ToString());
         }
         if (row["Copyright"] != null)
         {
             model.Copyright = row["Copyright"].ToString();
         }
         if (row["AboutImgUrl"] != null)
         {
             model.AboutImgUrl = row["AboutImgUrl"].ToString();
         }
         if (row["AboutIntro"] != null)
         {
             model.AboutIntro = row["AboutIntro"].ToString();
         }
         if (row["AboutUrl"] != null)
         {
             model.AboutUrl = row["AboutUrl"].ToString();
         }
         if (row["NewsUrl"] != null)
         {
             model.NewsUrl = row["NewsUrl"].ToString();
         }
         if (row["ContactImgUrl"] != null)
         {
             model.ContactImgUrl = row["ContactImgUrl"].ToString();
         }
         if (row["ContactUrl"] != null)
         {
             model.ContactUrl = row["ContactUrl"].ToString();
         }
         if (row["CompanyName"] != null)
         {
             model.CompanyName = row["CompanyName"].ToString();
         }
         if (row["Address"] != null)
         {
             model.Address = row["Address"].ToString();
         }
         if (row["Postcode"] != null && row["Postcode"].ToString() != "")
         {
             model.Postcode = int.Parse(row["Postcode"].ToString());
         }
         if (row["Telephone"] != null)
         {
             model.Telephone = row["Telephone"].ToString();
         }
         if (row["Website"] != null)
         {
             model.Website = row["Website"].ToString();
         }
         if (row["Email"] != null)
         {
             model.Email = row["Email"].ToString();
         }
         if (row["ProductUrl"] != null)
         {
             model.ProductUrl = row["ProductUrl"].ToString();
         }
     }
     return(model);
 }
Example #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(oyxf.Model.Config model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Config set ");
            strSql.Append("Copyright=@Copyright,");
            strSql.Append("AboutImgUrl=@AboutImgUrl,");
            strSql.Append("AboutIntro=@AboutIntro,");
            strSql.Append("AboutUrl=@AboutUrl,");
            strSql.Append("NewsUrl=@NewsUrl,");
            strSql.Append("ContactImgUrl=@ContactImgUrl,");
            strSql.Append("ContactUrl=@ContactUrl,");
            strSql.Append("CompanyName=@CompanyName,");
            strSql.Append("Address=@Address,");
            strSql.Append("Postcode=@Postcode,");
            strSql.Append("Telephone=@Telephone,");
            strSql.Append("Website=@Website,");
            strSql.Append("Email=@Email,");
            strSql.Append("ProductUrl=@ProductUrl");
            strSql.Append(" where ConfigId=@ConfigId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Copyright",     SqlDbType.NVarChar, 100),
                new SqlParameter("@AboutImgUrl",   SqlDbType.VarChar,  100),
                new SqlParameter("@AboutIntro",    SqlDbType.NVarChar, 200),
                new SqlParameter("@AboutUrl",      SqlDbType.VarChar,   50),
                new SqlParameter("@NewsUrl",       SqlDbType.VarChar,   50),
                new SqlParameter("@ContactImgUrl", SqlDbType.VarChar,  100),
                new SqlParameter("@ContactUrl",    SqlDbType.VarChar,   50),
                new SqlParameter("@CompanyName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Address",       SqlDbType.NVarChar, 100),
                new SqlParameter("@Postcode",      SqlDbType.Int,        4),
                new SqlParameter("@Telephone",     SqlDbType.VarChar,   15),
                new SqlParameter("@Website",       SqlDbType.VarChar,   30),
                new SqlParameter("@Email",         SqlDbType.VarChar,   30),
                new SqlParameter("@ProductUrl",    SqlDbType.VarChar,   50),
                new SqlParameter("@ConfigId",      SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Copyright;
            parameters[1].Value  = model.AboutImgUrl;
            parameters[2].Value  = model.AboutIntro;
            parameters[3].Value  = model.AboutUrl;
            parameters[4].Value  = model.NewsUrl;
            parameters[5].Value  = model.ContactImgUrl;
            parameters[6].Value  = model.ContactUrl;
            parameters[7].Value  = model.CompanyName;
            parameters[8].Value  = model.Address;
            parameters[9].Value  = model.Postcode;
            parameters[10].Value = model.Telephone;
            parameters[11].Value = model.Website;
            parameters[12].Value = model.Email;
            parameters[13].Value = model.ProductUrl;
            parameters[14].Value = model.ConfigId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }