Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(DtCms.Model.Products model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Products set ");
            strSql.Append("Title=@Title,");
            strSql.Append("ClassId=@ClassId,");
            strSql.Append("Guige=@Guige,");
            strSql.Append("Xinghao=@Xinghao,");
            strSql.Append("Price=@Price,");
            strSql.Append("ImgUrl=@ImgUrl,");
            strSql.Append("Content=@Content,");
            strSql.Append("Click=@Click,");
            strSql.Append("IsMsg=@IsMsg,");
            strSql.Append("IsTop=@IsTop,");
            strSql.Append("IsRed=@IsRed,");
            strSql.Append("IsHot=@IsHot,");
            strSql.Append("IsSlide=@IsSlide,");
            strSql.Append("IsLock=@IsLock,");
            strSql.Append("AddTime=@AddTime");
            strSql.Append(" where Id=@Id ");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@Title",   OleDbType.VarWChar,  100),
                new OleDbParameter("@ClassId", OleDbType.Integer,     4),
                new OleDbParameter("@Guige",   OleDbType.VarWChar,   50),
                new OleDbParameter("@Xinghao", OleDbType.VarWChar,   50),
                new OleDbParameter("@Price",   OleDbType.Decimal,     9),
                new OleDbParameter("@ImgUrl",  OleDbType.VarWChar,  250),
                new OleDbParameter("@Content", OleDbType.VarWChar),
                new OleDbParameter("@Click",   OleDbType.Integer,     4),
                new OleDbParameter("@IsMsg",   OleDbType.Integer,     4),
                new OleDbParameter("@IsTop",   OleDbType.Integer,     4),
                new OleDbParameter("@IsRed",   OleDbType.Integer,     4),
                new OleDbParameter("@IsHot",   OleDbType.Integer,     4),
                new OleDbParameter("@IsSlide", OleDbType.Integer,     4),
                new OleDbParameter("@IsLock",  OleDbType.Integer,     4),
                new OleDbParameter("@AddTime", OleDbType.Date),
                new OleDbParameter("@Id",      OleDbType.Integer, 4)
            };
            parameters[0].Value  = model.Title;
            parameters[1].Value  = model.ClassId;
            parameters[2].Value  = model.Guige;
            parameters[3].Value  = model.Xinghao;
            parameters[4].Value  = model.Price;
            parameters[5].Value  = model.ImgUrl;
            parameters[6].Value  = model.Content;
            parameters[7].Value  = model.Click;
            parameters[8].Value  = model.IsMsg;
            parameters[9].Value  = model.IsTop;
            parameters[10].Value = model.IsRed;
            parameters[11].Value = model.IsHot;
            parameters[12].Value = model.IsSlide;
            parameters[13].Value = model.IsLock;
            parameters[14].Value = model.AddTime;
            parameters[15].Value = model.Id;

            DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DtCms.BLL.Products bll = new DtCms.BLL.Products();
            //查询分页绑定数据

            if (!string.IsNullOrEmpty(Request.QueryString["Id"] + ""))
            {
                pro = new DtCms.BLL.Products().GetModel(int.Parse(Request.QueryString["Id"].ToString()));

                DataTable dt2 = DtCms.DBUtility.DbHelperOleDb.Query("select * from Channel where ClassList like '%,77,%' and ID not in(77)").Tables[0];
                this.Repeater2.DataSource = dt2;
                this.Repeater2.DataBind();
            }
        }
Esempio n. 3
0
        //保存
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DtCms.BLL.Products   bll   = new DtCms.BLL.Products();
            DtCms.Model.Products model = bll.GetModel(this.Id);

            model.Title   = txtTitle.Text.Trim();
            model.Guige   = txtGuige.Text.Trim();
            model.Xinghao = txtXinghao.Text.Trim();
            model.Price   = decimal.Parse(txtPrice.Text.Trim());
            model.ClassId = int.Parse(ddlClassId.SelectedValue);
            model.ImgUrl  = txtImgUrl.Text.Trim();
            model.Content = FCKeditor.Value;
            model.Click   = int.Parse(txtClick.Text.Trim());

            model.IsMsg   = 0;
            model.IsTop   = 0;
            model.IsRed   = 0;
            model.IsHot   = 0;
            model.IsSlide = 0;
            model.IsLock  = 0;
            if (cblItem.Items[0].Selected == true)
            {
                model.IsMsg = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.IsTop = 1;
            }
            if (cblItem.Items[2].Selected == true)
            {
                model.IsRed = 1;
            }
            if (cblItem.Items[3].Selected == true)
            {
                model.IsHot = 1;
            }
            if (cblItem.Items[4].Selected == true)
            {
                model.IsSlide = 1;
            }
            if (cblItem.Items[5].Selected == true)
            {
                model.IsLock = 1;
            }
            bll.Update(model);
            JscriptPrint("编辑成功啦!", "List.aspx", "Success");
        }
Esempio n. 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(DtCms.Model.Products model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Products(");
            strSql.Append("Title,ClassId,Guige,Xinghao,Price,ImgUrl,Content,Click,IsMsg,IsTop,IsRed,IsHot,IsSlide,IsLock,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@Title,@ClassId,@Guige,@Xinghao,@Price,@ImgUrl,@Content,@Click,@IsMsg,@IsTop,@IsRed,@IsHot,@IsSlide,@IsLock,@AddTime)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@Title",   OleDbType.VarWChar,  100),
                new OleDbParameter("@ClassId", OleDbType.Integer,     4),
                new OleDbParameter("@Guige",   OleDbType.VarWChar,   50),
                new OleDbParameter("@Xinghao", OleDbType.VarWChar,   50),
                new OleDbParameter("@Price",   OleDbType.Decimal,     9),
                new OleDbParameter("@ImgUrl",  OleDbType.VarWChar,  250),
                new OleDbParameter("@Content", OleDbType.VarWChar),
                new OleDbParameter("@Click",   OleDbType.Integer,     4),
                new OleDbParameter("@IsMsg",   OleDbType.Integer,     4),
                new OleDbParameter("@IsTop",   OleDbType.Integer,     4),
                new OleDbParameter("@IsRed",   OleDbType.Integer,     4),
                new OleDbParameter("@IsHot",   OleDbType.Integer,     4),
                new OleDbParameter("@IsSlide", OleDbType.Integer,     4),
                new OleDbParameter("@IsLock",  OleDbType.Integer,     4),
                new OleDbParameter("@AddTime", OleDbType.Date)
            };
            parameters[0].Value  = model.Title;
            parameters[1].Value  = model.ClassId;
            parameters[2].Value  = model.Guige;
            parameters[3].Value  = model.Xinghao;
            parameters[4].Value  = model.Price;
            parameters[5].Value  = model.ImgUrl;
            parameters[6].Value  = model.Content;
            parameters[7].Value  = model.Click;
            parameters[8].Value  = model.IsMsg;
            parameters[9].Value  = model.IsTop;
            parameters[10].Value = model.IsRed;
            parameters[11].Value = model.IsHot;
            parameters[12].Value = model.IsSlide;
            parameters[13].Value = model.IsLock;
            parameters[14].Value = model.AddTime;

            DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
        }
Esempio n. 5
0
        //赋值操作
        private void ShowInfo(int _id)
        {
            DtCms.BLL.Products   bll   = new DtCms.BLL.Products();
            DtCms.Model.Products model = bll.GetModel(_id);

            txtTitle.Text            = model.Title;
            txtGuige.Text            = model.Guige;
            txtXinghao.Text          = model.Xinghao;
            txtPrice.Text            = model.Price.ToString();
            ddlClassId.SelectedValue = model.ClassId.ToString();
            txtImgUrl.Text           = model.ImgUrl;
            FCKeditor.Value          = model.Content;
            txtClick.Text            = model.Click.ToString();
            if (model.IsMsg == 1)
            {
                cblItem.Items[0].Selected = true;
            }
            if (model.IsTop == 1)
            {
                cblItem.Items[1].Selected = true;
            }
            if (model.IsRed == 1)
            {
                cblItem.Items[2].Selected = true;
            }
            if (model.IsHot == 1)
            {
                cblItem.Items[3].Selected = true;
            }
            if (model.IsSlide == 1)
            {
                cblItem.Items[4].Selected = true;
            }
            if (model.IsLock == 1)
            {
                cblItem.Items[5].Selected = true;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DtCms.Model.Products GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Title,ClassId,Guige,Xinghao,Price,ImgUrl,Content,Click,IsMsg,IsTop,IsRed,IsHot,IsSlide,IsLock,AddTime from Products ");
            strSql.Append(" where Id=@Id ");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@Id", OleDbType.Integer, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                if (ds.Tables[0].Rows[0]["ClassId"].ToString() != "")
                {
                    model.ClassId = int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString());
                }
                model.Guige   = ds.Tables[0].Rows[0]["Guige"].ToString();
                model.Xinghao = ds.Tables[0].Rows[0]["Xinghao"].ToString();
                if (ds.Tables[0].Rows[0]["Price"].ToString() != "")
                {
                    model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
                }
                model.ImgUrl  = ds.Tables[0].Rows[0]["ImgUrl"].ToString();
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["Click"].ToString() != "")
                {
                    model.Click = int.Parse(ds.Tables[0].Rows[0]["Click"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsMsg"].ToString() != "")
                {
                    model.IsMsg = int.Parse(ds.Tables[0].Rows[0]["IsMsg"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsTop"].ToString() != "")
                {
                    model.IsTop = int.Parse(ds.Tables[0].Rows[0]["IsTop"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsRed"].ToString() != "")
                {
                    model.IsRed = int.Parse(ds.Tables[0].Rows[0]["IsRed"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsHot"].ToString() != "")
                {
                    model.IsHot = int.Parse(ds.Tables[0].Rows[0]["IsHot"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsSlide"].ToString() != "")
                {
                    model.IsSlide = int.Parse(ds.Tables[0].Rows[0]["IsSlide"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsLock"].ToString() != "")
                {
                    model.IsLock = int.Parse(ds.Tables[0].Rows[0]["IsLock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        //设置操作
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = Convert.ToInt32(((Label)e.Item.FindControl("lb_id")).Text);

            DtCms.BLL.Products   bll   = new DtCms.BLL.Products();
            DtCms.Model.Products model = bll.GetModel(id);
            switch (e.CommandName.ToLower())
            {
            case "ibtnmsg":
                if (model.IsMsg == 1)
                {
                    bll.UpdateField(id, "IsMsg=0");
                }
                else
                {
                    bll.UpdateField(id, "IsMsg=1");
                }
                break;

            case "ibtntop":
                if (model.IsTop == 1)
                {
                    bll.UpdateField(id, "IsTop=0");
                }
                else
                {
                    bll.UpdateField(id, "IsTop=1");
                }
                break;

            case "ibtnred":
                if (model.IsRed == 1)
                {
                    bll.UpdateField(id, "IsRed=0");
                }
                else
                {
                    bll.UpdateField(id, "IsRed=1");
                }
                break;

            case "ibtnhot":
                if (model.IsHot == 1)
                {
                    bll.UpdateField(id, "IsHot=0");
                }
                else
                {
                    bll.UpdateField(id, "IsHot=1");
                }
                break;

            case "ibtnslide":
                if (model.IsSlide == 1)
                {
                    bll.UpdateField(id, "IsSlide=0");
                }
                else
                {
                    bll.UpdateField(id, "IsSlide=1");
                }
                break;
            }
            this.RptBind("Id>0" + CombSqlTxt(this.classId, this.keywords, this.property), "AddTime desc");
        }