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("保存成功."); }
public string SaveEnum(string enumKey, string enumLab, string cfg) { SysEnumMain sem = new SysEnumMain(); sem.No = enumKey; if (sem.RetrieveFromDBSources() == 0) { sem.Name = enumLab; sem.CfgVal = cfg; sem.Lang = WebUser.SysLang; sem.Insert(); } else { sem.Name = enumLab; sem.CfgVal = cfg; sem.Lang = WebUser.SysLang; sem.Update(); } string[] strs = cfg.Split('@'); foreach (string str in strs) { if (string.IsNullOrEmpty(str)) { continue; } string[] kvs = str.Split('='); SysEnum se = new SysEnum(); se.EnumKey = enumKey; se.Lang = WebUser.SysLang; se.IntKey = int.Parse(kvs[0]); se.Lab = kvs[1]; se.Insert(); } return("save ok."); }