示例#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();
                }
            }
        }