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."); }
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); }