Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtTitle.Text.Trim().Length == 0)
            {
                strErr += "广告位名称不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtWidth.Text))
            {
                strErr += "宽度必须为数字!\\n";
            }
            if (!PageValidate.IsNumber(txtHeight.Text))
            {
                strErr += "高度必须为数字!\\n";
            }
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            hm.Model.ad_pos model = new hm.Model.ad_pos();
            model.title  = this.txtTitle.Text;
            model.types  = int.Parse(ddlTypes.SelectedValue);
            model.width  = int.Parse(txtWidth.Text);
            model.height = int.Parse(txtHeight.Text);
            model.click  = 0;

            hm.BLL.ad_pos bll = new hm.BLL.ad_pos();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(hm.Model.ad_pos model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ad_pos(");
            strSql.Append("title,types,width,height,click)");
            strSql.Append(" values (");
            strSql.Append("@title,@types,@width,@height,@click)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@title",  OleDbType.VarChar, 255),
                new OleDbParameter("@types",  OleDbType.Integer,   4),
                new OleDbParameter("@width",  OleDbType.Integer,   4),
                new OleDbParameter("@height", OleDbType.Integer,   4),
                new OleDbParameter("@click",  OleDbType.Integer, 4)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.types;
            parameters[2].Value = model.width;
            parameters[3].Value = model.height;
            parameters[4].Value = model.click;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 private void ShowInfo(int siId)
 {
     hm.BLL.ad_pos   bll   = new hm.BLL.ad_pos();
     hm.Model.ad_pos model = bll.GetModel(siId);
     lblId.Text             = model.id.ToString();
     txtTitle.Text          = model.title;
     txtWidth.Text          = model.width.ToString();
     txtHeight.Text         = model.height.ToString();
     ddlTypes.SelectedValue = model.types.ToString();
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public hm.Model.ad_pos GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,title,types,width,height,click from ad_pos ");
            strSql.Append(" where id=@id");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@id", OleDbType.Integer, 4)
            };
            parameters[0].Value = id;

            hm.Model.ad_pos model = new hm.Model.ad_pos();
            DataSet         ds    = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["types"] != null && ds.Tables[0].Rows[0]["types"].ToString() != "")
                {
                    model.types = int.Parse(ds.Tables[0].Rows[0]["types"].ToString());
                }
                if (ds.Tables[0].Rows[0]["width"] != null && ds.Tables[0].Rows[0]["width"].ToString() != "")
                {
                    model.width = int.Parse(ds.Tables[0].Rows[0]["width"].ToString());
                }
                if (ds.Tables[0].Rows[0]["height"] != null && ds.Tables[0].Rows[0]["height"].ToString() != "")
                {
                    model.height = int.Parse(ds.Tables[0].Rows[0]["height"].ToString());
                }
                if (ds.Tables[0].Rows[0]["click"] != null && ds.Tables[0].Rows[0]["click"].ToString() != "")
                {
                    model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(hm.Model.ad_pos model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ad_pos set ");
            strSql.Append("title=@title,");
            strSql.Append("types=@types,");
            strSql.Append("width=@width,");
            strSql.Append("height=@height,");
            strSql.Append("click=@click");
            strSql.Append(" where id=@id");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@title",  OleDbType.VarChar, 255),
                new OleDbParameter("@types",  OleDbType.Integer,   4),
                new OleDbParameter("@width",  OleDbType.Integer,   4),
                new OleDbParameter("@height", OleDbType.Integer,   4),
                new OleDbParameter("@click",  OleDbType.Integer,   4),
                new OleDbParameter("@id",     OleDbType.Integer, 4)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.types;
            parameters[2].Value = model.width;
            parameters[3].Value = model.height;
            parameters[4].Value = model.click;
            parameters[5].Value = model.id;

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

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