Example #1
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            int id       = int.Parse(this.tl_BaseDic.FocusedNode.GetValue("ID").ToString());
            int parentId = int.Parse(this.tl_BaseDic.FocusedNode.GetValue("ParentID").ToString());

            if (string.IsNullOrEmpty(txt_Name.Text.Trim()))
            {
                XtraMessageBox.Show("节点名称不能为空!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrEmpty(txt_Order.Text.Trim()))
            {
                XtraMessageBox.Show("排序不能为空!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!Common.Tools.IsInt(txt_Order.Text.Trim()))
            {
                XtraMessageBox.Show("排序必须为正整数!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            PROPTYPEBASE prop_Curr = new PROPTYPEBASE();

            if (IsAdd)
            {
                if (IsAddChild)
                {
                    prop_Curr.PROPPARENT = id;
                }
                else
                {
                    prop_Curr.PROPPARENT = parentId;
                }
            }
            else
            {
                prop_Curr = prop.Get(p => p.PROPID == id);
            }

            prop_Curr.PROPNAME  = txt_Name.Text.Trim();
            prop_Curr.PROPORDER = Convert.ToInt32(txt_Order.Text.Trim());

            if (prop.SaveOrUpdate(prop_Curr, !IsAdd))
            {
                XtraMessageBox.Show("操作成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BasicDictionary_Load(null, null);
            }
            else
            {
                XtraMessageBox.Show("操作失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            IsAdd      = false;
            IsAddChild = false;
        }
Example #2
0
 private void btn_Add_Click(object sender, EventArgs e)
 {
     try
     {
         IsAdd = true;
         PROPTYPEBASE propType  = new PROPTYPEBASE();
         int          parrentId = int.Parse(this.tl_BaseDic.FocusedNode.GetValue("ParentID").ToString());
         txt_rootName.Text = prop.Get(p => p.PROPID == parrentId).PROPNAME;
         txt_Name.Text     = string.Empty;
         txt_Order.Text    = "1";
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("新增失败!" + ex.Message, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #3
0
        private void tl_BaseDic_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            try
            {
                int id       = int.Parse(this.tl_BaseDic.FocusedNode.GetValue("ID").ToString());
                int parentId = int.Parse(this.tl_BaseDic.FocusedNode.GetValue("ParentID").ToString());

                PROPTYPEBASE prop_Parent = prop.Get(p => p.PROPID == parentId);
                PROPTYPEBASE prop_Curr   = prop.Get(p => p.PROPID == id);

                txt_Name.Text     = this.tl_BaseDic.FocusedNode.GetValue("MenuName").ToString();
                txt_rootName.Text = prop_Parent == null ? "" : prop_Parent.PROPNAME;
                txt_Order.Text    = prop_Curr.PROPORDER.ToString();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }
Example #4
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            int          id       = int.Parse(this.tl_BaseDic.FocusedNode.GetValue("ID").ToString());
            PROPTYPEBASE propType = prop.Get(p => p.PROPID == id);

            if (DialogResult.Yes == XtraMessageBox.Show("您确定要删除吗?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
            {
                if (prop.IsExist(p => p.PROPPARENT == id))
                {
                    XtraMessageBox.Show("该节点名称存在子节点,不能删除!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    prop.Delete(p => p.PROPID == id);
                    BasicDictionary_Load(null, null);
                }
            }
        }