Example #1
0
        /// <summary>
        /// 添加类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            string properValue = this.txtPropertyValue.Text.Trim();
            string productType = ddlProductType.SelectedValue;
            string parentId    = ddlOne.SelectedValue;
            string two         = ddlTwo.SelectedValue;

            if (productType == "0" || parentId == "0" || two == "0")
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('请选择属性类型!');", true);
                return;
            }
            if (properValue.Length == 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('属性值不能为空!');", true);
                return;
            }

            ProperValue item = new ProperValue();

            item.infoType    = Convert.ToInt32(productType);
            item.parentId    = Convert.ToInt32(parentId);
            item.properId    = Convert.ToInt32(two);
            item.properValue = properValue;


            item.status = 0;
            item.remark = "";

            item.addTime = DateTime.Now;

            if (Session["loginUser"] == null)
            {
                Response.Redirect("/admin/login.aspx");
                return;
            }
            AdminUser admin = Session["loginUser"] as AdminUser;

            item.addUser = admin.id;
            if (ViewState["modId"] != null)
            {
                item.id = Convert.ToInt32(ViewState["modId"]);
                ProperValueService.Update(item);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');location.href='propertyValue.aspx'", true);
            }
            else
            {
                int num = ProperValueService.Add(item);
            }

            sp.InitBindData(repInfo, pager1, "ProperValue", "id", sear());
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');", true);
        }
Example #2
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);
         ProperValueService.Delete(id);
         sp.InitBindData(repInfo, pager1, "ProperValue", "id", sear());
     }
     if (e.CommandName.Equals("mod"))
     {
         int         id   = Convert.ToInt32(e.CommandArgument);
         ProperValue item = ProperValueService.GetModel(id);
         if (item != null)
         {
             this.ddlProductType.SelectedValue = item.infoType.ToString();
             //产品一级属性下拉框
             DataSet ds = ProperTypeService.GetList("parentId = 0 and infoType = " + item.infoType);
             ddlOne.Items.Clear();
             if (ds.Tables[0].Rows.Count > 0)
             {
                 ddlOne.DataSource     = ds;
                 ddlOne.DataTextField  = "properName";
                 ddlOne.DataValueField = "id";
                 ddlOne.DataBind();
             }
             ddlOne.Items.Insert(0, new ListItem("请选择", "0"));
             if (item.parentId != 0)
             {
                 ddlOne.SelectedValue = item.parentId.ToString();
                 ds = ProperTypeService.GetList("parentId = " + item.parentId);
                 ddlTwo.Items.Clear();
                 if (ds.Tables[0].Rows.Count > 0)
                 {
                     ddlTwo.DataSource     = ds;
                     ddlTwo.DataTextField  = "properName";
                     ddlTwo.DataValueField = "id";
                     ddlTwo.DataBind();
                 }
                 ddlTwo.Items.Insert(0, new ListItem("请选择", "0"));
                 if (item.properId != 0)
                 {
                     ddlTwo.SelectedValue  = item.properId.ToString();
                     txtPropertyValue.Text = item.properValue;
                 }
             }
         }
         ViewState["modId"] = id;
         ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "overKeyWordDiv();", true);
     }
 }