Example #1
0
        void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                SysEnumMain main = new SysEnumMain();
                if (this.RefNo == null)
                {
                    main.No = this.Pub1.GetTBByID("TB_No").Text;
                    if (main.IsExits)
                    {
                        //this.Alert("编号(枚举英文名称)[" + main.No + "]已经存在。");
                        this.Alert("编号(枚举英文名称)[" + main.No + "]已经存在。");
                        return;
                    }

                    SysEnum se = new SysEnum();
                    if (se.IsExit(SysEnumAttr.EnumKey, main.No) == true)
                    {
                        this.Alert("编号(枚举英文名称)[" + main.No + "]已经存在。");
                        return;
                    }

                    main = (SysEnumMain)this.Pub1.Copy(main);
                    if (main.No.Length == 0 || main.Name.Length == 0)
                    {
                        throw new Exception("编号与名称不能为空");
                    }
                }
                else
                {
                    main.No = this.RefNo;
                    main.Retrieve();
                    main = (SysEnumMain)this.Pub1.Copy(main);
                    if (main.No.Length == 0 || main.Name.Length == 0)
                    {
                        throw new Exception("编号与名称不能为空");
                    }
                }

                string cfgVal = "";
                int    idx    = -1;
                while (idx < 19)
                {
                    idx++;
                    string t = this.Pub1.GetTBByID("TB_" + idx).Text.Trim();
                    if (t.Length == 0)
                    {
                        continue;
                    }

                    cfgVal += "@" + idx + "=" + t;
                }

                main.CfgVal = cfgVal;
                if (main.CfgVal == "")
                {
                    throw new Exception("错误:您必须输入枚举值,请参考帮助。");  //错误:您必须输入枚举值,请参考帮助。
                }
                main.Save();

                //重新生成
                SysEnums se1s = new SysEnums();
                se1s.Delete(SysEnumAttr.EnumKey, main.No);
                SysEnums ses = new SysEnums();
                ses.RegIt(main.No, cfgVal);

                string keyApp = "EnumOf" + main.No + WebUser.SysLang;
                BP.DA.Cash.DelObjFormApplication(keyApp);

                if (this.MyPK != null)
                {
                    this.Response.Redirect("SysEnum.aspx?RefNo=" + main.No + "&MyPK=" + this.MyPK + "&IDX=" + this.IDX, true);
                }
                return;
            }
            catch (Exception ex)
            {
                this.ResponseWriteBlueMsg(ex.Message);
                //this.ToErrorPage(ex.Message);
                //this.Alert(ex.Message);
            }
        }