コード例 #1
0
        /// <summary>
        /// 加载信息
        /// </summary>
        private void LoadOneCate()
        {
            //产品类型
            DataSet ds = ProductTypeService.GetList("parentId = 0");

            if (ds.Tables[0].Rows.Count > 0)
            {
                this.ddlOne.DataSource = ds;
                ddlOne.DataTextField   = "typeName";
                ddlOne.DataValueField  = "id";
                ddlOne.DataBind();
            }
            ddlOne.Items.Insert(0, new ListItem("请选择", "0"));
            this.ddlTwo.Items.Insert(0, new ListItem("请选择", "0"));
            this.ddlThree.Items.Insert(0, new ListItem("请选择", "0"));

            ds = TypeInfoService.GetList("infoType = 1");
            if (ds.Tables[0].Rows.Count > 0)
            {
                ddlVariety.DataSource     = ds;
                ddlVariety.DataTextField  = "typeName";
                ddlVariety.DataValueField = "id";
                ddlVariety.DataBind();
            }
            ddlVariety.Items.Insert(0, new ListItem("请选择", "0"));

            ds = TypeInfoService.GetList("infoType = 2");
            if (ds.Tables[0].Rows.Count > 0)
            {
                this.ddlRelieve.DataSource = ds;
                ddlRelieve.DataTextField   = "typeName";
                ddlRelieve.DataValueField  = "id";
                ddlRelieve.DataBind();
            }
            ddlRelieve.Items.Insert(0, new ListItem("请选择", "0"));


            ds = TypeInfoService.GetList("infoType = 3");
            if (ds.Tables[0].Rows.Count > 0)
            {
                this.ddlCook.DataSource = ds;
                ddlCook.DataTextField   = "typeName";
                ddlCook.DataValueField  = "id";
                ddlCook.DataBind();
            }
            ddlCook.Items.Insert(0, new ListItem("请选择", "0"));
        }
コード例 #2
0
        private void InitTypeData()
        {
            string errText = "";

            if (_typeInfoService == null)
            {
                _typeInfoService = new TypeInfoService();
            }
            var list = _typeInfoService.GetEntityList(out errText);

            if (list == null || list.Count == 0)
            {
                this.treeView1.Nodes.Clear();
                return;
            }
            CreatTreeViewNodes(list);
        }
コード例 #3
0
 /// <summary>
 /// 控件行命令事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("del"))
     {
         int id = Convert.ToInt32(e.CommandArgument);
         TypeInfoService.Delete(id);
         sp.InitBindData(this.repInfo, pager1, "TypeInfo", "id", sear());
     }
     if (e.CommandName.Equals("mod"))
     {
         Label lblName = e.Item.FindControl("lblName") as Label;
         lblName.Visible = false;
         TextBox txtName = e.Item.FindControl("txtModName") as TextBox;
         txtName.Visible = true;
         LinkButton lbtnMod = e.Item.FindControl("lbtnMod") as LinkButton;
         lbtnMod.Visible = false;
         LinkButton lbtnSave = e.Item.FindControl("lbtnSave") as LinkButton;
         lbtnSave.Visible = true;
         this.hidId.Value = e.CommandArgument.ToString();
     }
     if (e.CommandName.Equals("save"))
     {
         TextBox txtName = e.Item.FindControl("txtModName") as TextBox;
         string  name    = txtName.Text.Trim();
         if (name.Length == 0)
         {
             ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('名称不能为空!');", true);
             return;
         }
         TypeInfo nt = TypeInfoService.GetModel(Convert.ToInt32(hidId.Value));
         if (nt != null)
         {
             nt.typeName = name;
             nt.id       = Convert.ToInt32(e.CommandArgument);
             if (TypeInfoService.Exists(nt))
             {
                 ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('名称已经存在!');", true);
                 sp.InitBindData(this.repInfo, pager1, "TypeInfo", "id", sear());
                 return;
             }
             TypeInfoService.Update(nt.id, nt.typeName);
         }
         sp.InitBindData(this.repInfo, pager1, "TypeInfo", "id", sear());
     }
 }
コード例 #4
0
        /// <summary>
        /// 添加事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            lblError.Text = "";

            TypeInfo item = new TypeInfo();

            if (ddlParent.SelectedValue == "0")
            {
                lblError.Text = "请选择大类!";
                return;
            }
            item.infoType = Convert.ToInt32(ddlParent.SelectedValue);

            if (this.txtTitle.Text.Trim().Length == 0)
            {
                lblError.Text = "分类名称不能为空!";
                return;
            }
            item.typeName  = txtTitle.Text.Trim();
            item.typeValue = 0;
            item.remark    = "";
            item.status    = 1;
            item.remark    = "";
            item.addTime   = DateTime.Now;
            item.addUser   = 0;
            if (Session["loginUser"] != null)
            {
                item.addUser = (Session["loginUser"] as AdminUser).id;
            }
            string hidId = this.hidId.Value;

            if (TypeInfoService.Exists(item))
            {
                lblError.Text = "该分类以及存在";
                return;
            }
            TypeInfoService.Add(item);
            txtTitle.Text = "";
            sp.InitBindData(this.repInfo, pager1, "TypeInfo", "id", sear());
        }