/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Leadin.Model.DesignTemplateType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_DesignTemplateType set ");

            strSql.Append(" Title = @Title , ");
            strSql.Append(" SubTitle = @SubTitle , ");
            strSql.Append(" SortNum = @SortNum , ");
            strSql.Append(" ParentId = @ParentId , ");
            strSql.Append(" StateInfo = @StateInfo , ");
            strSql.Append(" Price = @Price , ");
            strSql.Append(" Cycle = @Cycle , ");
            strSql.Append(" ImgUrl = @ImgUrl , ");
            strSql.Append(" DetailRemark = @DetailRemark , ");
            strSql.Append(" Remark = @Remark , ");
            strSql.Append(" AddTime = @AddTime ,Typekey=@Typekey ");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",           SqlDbType.Int,        4),
                new SqlParameter("@Title",        SqlDbType.NVarChar, 100),
                new SqlParameter("@SubTitle",     SqlDbType.NVarChar, 200),
                new SqlParameter("@SortNum",      SqlDbType.Int,        4),
                new SqlParameter("@ParentId",     SqlDbType.Int,        4),
                new SqlParameter("@StateInfo",    SqlDbType.Int,        4),
                new SqlParameter("@Price",        SqlDbType.NVarChar, 200),
                new SqlParameter("@Cycle",        SqlDbType.NVarChar, 200),
                new SqlParameter("@ImgUrl",       SqlDbType.NVarChar, 200),
                new SqlParameter("@DetailRemark", SqlDbType.NText),
                new SqlParameter("@Remark",       SqlDbType.NVarChar, 500),
                new SqlParameter("@Typekey",      SqlDbType.NVarChar, 100),
                new SqlParameter("@AddTime",      SqlDbType.DateTime)
            };

            parameters[0].Value  = model.Id;
            parameters[1].Value  = model.Title;
            parameters[2].Value  = model.SubTitle;
            parameters[3].Value  = model.SortNum;
            parameters[4].Value  = model.ParentId;
            parameters[5].Value  = model.StateInfo;
            parameters[6].Value  = model.Price;
            parameters[7].Value  = model.Cycle;
            parameters[8].Value  = model.ImgUrl;
            parameters[9].Value  = model.DetailRemark;
            parameters[10].Value = model.Remark;
            parameters[11].Value = model.Typekey;
            parameters[12].Value = model.AddTime;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Leadin.Model.DesignTemplateType GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, Title, SubTitle, SortNum, ParentId, StateInfo, Price, Cycle, ImgUrl, DetailRemark, Remark, AddTime,Typekey  ");
            strSql.Append("  from tb_DesignTemplateType ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;


            Leadin.Model.DesignTemplateType model = new Leadin.Model.DesignTemplateType();
            DataSet ds = DbHelperSQL.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();
                model.SubTitle = ds.Tables[0].Rows[0]["SubTitle"].ToString();
                model.Typekey  = ds.Tables[0].Rows[0]["Typekey"].ToString();

                if (ds.Tables[0].Rows[0]["SortNum"].ToString() != "")
                {
                    model.SortNum = int.Parse(ds.Tables[0].Rows[0]["SortNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ParentId"].ToString() != "")
                {
                    model.ParentId = int.Parse(ds.Tables[0].Rows[0]["ParentId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StateInfo"].ToString() != "")
                {
                    model.StateInfo = int.Parse(ds.Tables[0].Rows[0]["StateInfo"].ToString());
                }
                model.Price        = ds.Tables[0].Rows[0]["Price"].ToString();
                model.Cycle        = ds.Tables[0].Rows[0]["Cycle"].ToString();
                model.ImgUrl       = ds.Tables[0].Rows[0]["ImgUrl"].ToString();
                model.DetailRemark = ds.Tables[0].Rows[0]["DetailRemark"].ToString();
                model.Remark       = ds.Tables[0].Rows[0]["Remark"].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);
            }
        }
Exemple #3
0
        /// <summary>
        /// 确认提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOk_Click(object sender, EventArgs e)
        {
            Leadin.Model.DesignTemplateType model = new Leadin.Model.DesignTemplateType();

            bool isEdit = string.IsNullOrWhiteSpace(Request.Params["id"]);

            if (!isEdit)
            {
                model = bll.GetModel(int.Parse(Request.Params["id"]));
            }


            model.Remark       = txtfileico1.Text + "," + txtfileico2.Text;
            model.DetailRemark = ckHot.Checked ? "1" : "0";
            model.Title        = txtTypeName.Text;
            model.ParentId     = 0;
            model.SortNum      = int.Parse(txtSortNum.Text);
            model.StateInfo    = ckState.Checked ? 1 : 0;
            model.SubTitle     = txtSubTitle.Text;
            model.Price        = txtPrice.Text;
            model.ImgUrl       = txtfileico3.Text;
            model.Cycle        = txtCycle.Text;
            model.Typekey      = txtKey.Text.ToUpper();


            if (isEdit)
            {
                model.AddTime = DateTime.Now;

                if (bll.Add(model) > 0)
                {
                    JsMessage("success", "模版类别添加成功!", 1000, "List.aspx");
                }
                else
                {
                    JsMessage("error", "模版类别添加失败,请检查您的输入!", 1000, "back");
                }
            }
            else
            {
                if (bll.Update(model))
                {
                    JsMessage("success", "模版类别编辑成功!", 1000, "List.aspx?page=" + Request.Params["page"] + (string.IsNullOrWhiteSpace(Request.Params["key"]) ? "" : "&key=" + Request.Params["key"]));
                }
                else
                {
                    JsMessage("error", "模版类别编辑失败,请检查您的输入!", 1000, "back");
                }
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Leadin.Model.DesignTemplateType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_DesignTemplateType(");
            strSql.Append("Title,SubTitle,SortNum,ParentId,StateInfo,Price,Cycle,ImgUrl,DetailRemark,Remark,AddTime,Typekey");
            strSql.Append(") values (");
            strSql.Append("@Title,@SubTitle,@SortNum,@ParentId,@StateInfo,@Price,@Cycle,@ImgUrl,@DetailRemark,@Remark,@AddTime,@Typekey");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",        SqlDbType.NVarChar,  100),
                new SqlParameter("@SubTitle",     SqlDbType.NVarChar,  200),
                new SqlParameter("@SortNum",      SqlDbType.Int,         4),
                new SqlParameter("@ParentId",     SqlDbType.Int,         4),
                new SqlParameter("@StateInfo",    SqlDbType.Int,         4),
                new SqlParameter("@Price",        SqlDbType.NVarChar,  200),
                new SqlParameter("@Cycle",        SqlDbType.NVarChar,  200),
                new SqlParameter("@ImgUrl",       SqlDbType.NVarChar,  200),
                new SqlParameter("@DetailRemark", SqlDbType.NText),
                new SqlParameter("@Remark",       SqlDbType.NVarChar,  500),
                new SqlParameter("@AddTime",      SqlDbType.DateTime),
                new SqlParameter("@Typekey",      SqlDbType.NVarChar, 100)
            };

            parameters[0].Value  = model.Title;
            parameters[1].Value  = model.SubTitle;
            parameters[2].Value  = model.SortNum;
            parameters[3].Value  = model.ParentId;
            parameters[4].Value  = model.StateInfo;
            parameters[5].Value  = model.Price;
            parameters[6].Value  = model.Cycle;
            parameters[7].Value  = model.ImgUrl;
            parameters[8].Value  = model.DetailRemark;
            parameters[9].Value  = model.Remark;
            parameters[10].Value = model.AddTime;
            parameters[11].Value = model.Typekey;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            Leadin.BLL.DesignTemplateType bll = new Leadin.BLL.DesignTemplateType();

            string typeid = context.Request["typeid"].ToString();

            JsonData jd = new JsonData();

            Leadin.Model.DesignTemplateType model = bll.GetModel(int.Parse(typeid));

            jd["cycle"] = model.Cycle;
            jd["price"] = model.Price;

            context.Response.Write(jd.ToJson());
        }
Exemple #6
0
        /// <summary>
        /// 绑定模版类别详情
        /// </summary>
        void BindTemplateTypeDetail()
        {
            string cid;

            if (string.IsNullOrWhiteSpace(Request.Params["type"]))
            {
                cid = dsTemplateType.Tables[0].Rows[0]["Id"].ToString();
            }
            else
            {
                cid = Request.Params["type"];
            }

            model = bllTemplateType.GetModel(int.Parse(cid));
        }
Exemple #7
0
        /// <summary>
        /// 绑定顶级类别
        /// </summary>
        //void BindType()
        //{
        //    DataSet ds = bll.GetList(0, "ParentId=0", "SortNum desc");
        //    ddlType.Items.Add(new ListItem("顶级类别", "0"));
        //    foreach (DataRow item in ds.Tables[0].Rows)
        //    {
        //        ddlType.Items.Add(new ListItem(item["Title"].ToString(), item["Id"].ToString()));
        //    }
        //}


        /// <summary>
        /// 绑定模版类别详细信息
        /// </summary>
        /// <param name="id"></param>
        void BindDetail(int id)
        {
            Leadin.Model.DesignTemplateType model = bll.GetModel(id);

            txtCycle.Text    = model.Cycle;
            txtfileico1.Text = model.Remark.Split(',')[0];
            txtfileico2.Text = model.Remark.Split(',')[1];
            txtfileico3.Text = model.ImgUrl;
            txtPrice.Text    = model.Price;
            ckHot.Checked    = model.DetailRemark == "1"?true:false;
            txtSortNum.Text  = model.SortNum.ToString();
            txtSubTitle.Text = model.SubTitle;
            txtTypeName.Text = model.Title;
            ckState.Checked  = model.StateInfo == 1 ? true : false;
            txtKey.Text      = model.Typekey;
        }
Exemple #8
0
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void repList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            //修改状态
            if (e.CommandName == "lbtnState")
            {
                Label lbid = e.Item.FindControl("lbid") as Label;

                Leadin.Model.DesignTemplateType model = bll.GetModel(int.Parse(lbid.Text));

                if (model.StateInfo == 1)
                {
                    model.StateInfo = 0;
                }
                else
                {
                    model.StateInfo = 1;
                }

                bll.Update(model);
            }
            //修改热门
            if (e.CommandName == "lbtnHot")
            {
                Label lbid = e.Item.FindControl("lbid") as Label;

                Leadin.Model.DesignTemplateType model = bll.GetModel(int.Parse(lbid.Text));

                if (model.DetailRemark == "1")
                {
                    model.DetailRemark = "0";
                }
                else
                {
                    model.DetailRemark = "1";
                }

                bll.Update(model);
            }

            BindRepList();
        }