Ejemplo n.º 1
0
        private void btn_Edit_Click(object sender, EventArgs e)
        {
            if (btn_Edit.Text == "编辑")
            {
                if (txt_tabpageid.Text != "")
                {
                    EnableEdit();
                    btn_Edit.Text = "保存";
                }
                else
                {
                    MessageBox.Show("请先点击一条TabPage记录!");
                }
            }
            else
            {
                if (txt_tabpageid.Text != "" &&
                    txt_tabpagename.Text != "" &&
                    txt_tabpageindex.Text != "")
                {
                    if (txt_tabpageid.Text != lbl_tabpageid.Text ||
                        txt_tabpagename.Text != lbl_tabpagename.Text ||
                        txt_tabpageindex.Text != lbl_tabpageindex.Text)
                    {
                        JObject jobject = JsonHelper.readJson();
                        if (JsonHelper.SetTabPageJsonValue(jobject, txt_tabpageid.Text, "tabpagename", txt_tabpagename.Text, 0) &&
                            JsonHelper.SetTabPageJsonValue(jobject, txt_tabpageid.Text, "tabpageindex", txt_tabpageindex.Text, 0))
                        {
                            JsonHelper.UpdateTabPagename("edit", jobject, "apptag", lbl_tabpagename.Text, txt_tabpagename.Text, 0);
                            MessageBox.Show("修改成功!");
                        }
                        LoadTabPages();

                        if (MyEvent != null)
                        {
                            MyEvent("修改成功");//触发事件
                        }
                    }
                    else
                    {
                        MessageBox.Show("数据未更改!");
                        DisableEdit();
                        btn_Edit.Text = "编辑";
                    }
                    Cancel();
                }
            }
        }
Ejemplo n.º 2
0
 private void btn_Delete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("删除此选项卡会将此选项卡内的快捷方式全部删除,请先确认是否删除此选项卡?", "删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
     {
         JObject jobject = JsonHelper.readJson();
         if (JsonHelper.DeleteTabPageJsonValue(jobject, txt_tabpageid.Text, 0))
         {
             JsonHelper.UpdateTabPagename("delete", jobject, "apptag", lbl_tabpagename.Text, txt_tabpagename.Text, 0);
             MessageBox.Show("删除成功!");
             LoadTabPages();
             if (MyEvent != null)
             {
                 MyEvent("删除成功");//触发事件
             }
         }
         else
         {
             MessageBox.Show("删除失败!");
         }
         Cancel();
     }
 }