示例#1
0
    void btn_Click(object sender, EventArgs e)
    {
        //原有个数
        SysEnums souceSes = new SysEnums();

        souceSes.Retrieve(SysEnumAttr.EnumKey, this.RefNo, SysEnumAttr.IntKey);

        SysEnums ses = new SysEnums();

        for (int i = 0; i < souceSes.Count + 10; i++)
        {
            TextBox tb = this.UCSys1.GetTextBoxByID("TB_" + i);
            if (tb == null)
            {
                continue;
            }
            if (string.IsNullOrEmpty(tb.Text))
            {
                continue;
            }

            SysEnum se = new SysEnum();
            se.IntKey  = i;
            se.Lab     = tb.Text.Trim();
            se.Lang    = BP.Web.WebUser.SysLang;
            se.EnumKey = this.RefNo;
            se.MyPK    = se.EnumKey + "_" + se.Lang + "_" + se.IntKey;
            ses.AddEntity(se);
        }

        if (ses.Count == 0)
        {
            this.Alert("枚举项目不能为空.");
            return;
        }

        ses.Delete(SysEnumAttr.EnumKey, this.RefNo);

        string lab = "";

        foreach (SysEnum se in ses)
        {
            se.Save();
            lab += "@" + se.IntKey + "=" + se.Lab;
        }
        SysEnumMain main = new SysEnumMain(this.RefNo);

        main.Name   = UCSys1.GetTextBoxByID("TB_Name").Text;
        main.CfgVal = lab;
        main.Update();
        this.Alert("保存成功.");
    }
示例#2
0
    void btn_New_Click(object sender, EventArgs e)
    {
        string      no   = this.UCSys1.GetTextBoxByID("TB_No").Text;
        string      name = this.UCSys1.GetTextBoxByID("TB_Name").Text;
        SysEnumMain m    = new SysEnumMain();

        m.No = no;
        if (m.RetrieveFromDBSources() == 1)
        {
            this.Alert("枚举编号:" + m.No + " 已经被:" + m.Name + "占用");
            return;
        }
        m.Name = name;
        if (string.IsNullOrEmpty(name))
        {
            this.Alert("枚举名称不能为空");
            return;
        }

        SysEnums ses = new SysEnums();

        for (int i = 0; i < 20; i++)
        {
            TextBox tb = this.UCSys1.GetTextBoxByID("TB_" + i);
            if (tb == null)
            {
                continue;
            }
            if (string.IsNullOrEmpty(tb.Text))
            {
                continue;
            }

            SysEnum se = new SysEnum();
            se.IntKey  = i;
            se.Lab     = tb.Text.Trim();
            se.Lang    = BP.Web.WebUser.SysLang;
            se.EnumKey = m.No;
            se.MyPK    = se.EnumKey + "_" + se.Lang + "_" + se.IntKey;
            ses.AddEntity(se);
        }

        if (ses.Count == 0)
        {
            this.Alert("枚举项目不能为空.");
            return;
        }

        string lab = "";

        foreach (SysEnum se in ses)
        {
            se.Save();
            lab += "@" + se.IntKey + "=" + se.Lab;
        }

        m.Lang   = BP.Web.WebUser.SysLang;
        m.CfgVal = lab;
        m.Insert();
        this.Response.Redirect("EnumList.aspx?RefNo=" + m.No + "&T=" + DateTime.Now.ToString("yyyyMMddHHmmssfff"), true);
    }