コード例 #1
0
        /// <summary>
        /// 父级属性名称
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="properName"></param>
        /// <returns></returns>
        protected string GetName(object pid)
        {
            ProperType item = ProperTypeService.GetModel(Convert.ToInt32(pid));

            if (item != null)
            {
                return(item.properName);
            }
            return("");
        }
コード例 #2
0
        /// <summary>
        /// 添加类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            string properName  = this.txtPropertyName.Text.Trim();
            string productType = ddlProductType.SelectedValue;

            if (productType == "0")
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('请选择产品类型!');", true);
                return;
            }
            if (properName.Length == 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('属性名称不能为空!');", true);
                return;
            }
            string parentId = ddlOne.SelectedValue;

            ProperType item = new ProperType();

            item.infoType    = Convert.ToInt32(productType);
            item.properName  = properName;
            item.properValue = "";
            item.parentId    = Convert.ToInt32(parentId);

            item.status = 0;
            if (cboTj.Checked)
            {
                item.status = 1;
            }
            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"]);
                ProperTypeService.Update(item);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');location.href='propertyInfo.aspx'", true);
            }
            else
            {
                int num = ProperTypeService.Add(item);
            }

            sp.InitBindData(repInfo, pager1, "ProperType", "id", sear());
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');", true);
        }
コード例 #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);
                ProperTypeService.Delete(id);
                sp.InitBindData(repInfo, pager1, "ProperType", "id", sear());
            }
            if (e.CommandName.Equals("mod"))
            {
                int        id   = Convert.ToInt32(e.CommandArgument);
                ProperType item = ProperTypeService.GetModel(id);
                if (item != null)
                {
                    this.ddlProductType.SelectedValue = item.infoType.ToString();
                    if (item.parentId == 0)
                    {
                        txtPropertyName.Text = item.properName;
                    }
                    else
                    {
                        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"));

                        ddlOne.SelectedValue = item.parentId.ToString();
                        txtPropertyName.Text = item.properName;
                        if (item.status == 1)
                        {
                            cboTj.Checked = true;
                        }
                        else
                        {
                            cboTj.Checked = false;
                        }
                    }
                }
                ViewState["modId"] = id;
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "overKeyWordDiv();", true);
            }
        }
コード例 #4
0
        /// <summary>
        /// 父级属性名称
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="properName"></param>
        /// <returns></returns>
        protected string GetParentName(object pid, object properName)
        {
            int parentId = Convert.ToInt32(pid);

            if (parentId != 0)
            {
                ProperType item = ProperTypeService.GetModel(parentId);
                if (item != null)
                {
                    return(item.properName);
                }
                return("");
            }
            else
            {
                return("顶级");
            }
        }