protected void btnSave_Click(object sender, EventArgs e) { if (txtModule.Text != "") { SF_Module m = new SF_Module(); m.ModuleGroupID = Convert.ToDecimal(cboModuleGroup.SelectedItem.Value.ToString()); m.ModuleName = txtModule.Text.Trim(); m.ModuleTag = txtUrl.Text.Trim().Replace("/", "_").Remove(txtUrl.Text.LastIndexOf(".")); m.ModuleOrder = Convert.ToDecimal(txtOrder.Text); m.ModuleUrl = txtUrl.Text.Trim(); m.About = txtAbout.Text.Trim(); m.Status = radStatus.SelectedValue; if (Request.QueryString["mid"] != null) { m.ModuleID = int.Parse(Request.QueryString["mid"].ToString()); switch (Convert.ToInt32(mbll.UpdateModule(m))) { case 1: List <string> lst = new List <string>(); foreach (ListItem item in lstOpt.Items) { string s = string.Empty; s = Request.QueryString["mid"].ToString() + "|" + item.Value + "|0"; lst.Add(s); } foreach (ListItem item in lstSelectedOpt.Items) { string s = string.Empty; if (txtOldOperator.Text != "") { string[] oldOperator = (txtOldOperator.Text.Remove(txtOldOperator.Text.LastIndexOf("|"))).Split('|'); if (!oldOperator.Contains(item.Value)) { s = Request.QueryString["mid"].ToString() + "|" + item.Value + "|1"; lst.Add(s); } } else { s = Request.QueryString["mid"].ToString() + "|" + item.Value + "|1"; lst.Add(s); } } if (mbll.UpdateOperatorList(lst)) { JSHelper.Alert("更新成功!", this); } else { JSHelper.Alert("更新操作失败!", this); } break; case 2: JSHelper.Alert("标识已经存在,请重新定义标识!", this); break; default: JSHelper.Alert("更新模块失败!", this); break; } } else { if (!mbll.ModuleExists(txtModuleTag.Text.Trim())) { int MID = (int)mbll.CreateModule(m); //返回模块ID; if (MID != 0) //添加OK { List <string> lst = new List <string>(); //建立事务列表 foreach (ListItem item in lstSelectedOpt.Items) { string s = string.Empty; if (txtOldOperator.Text != "") { string[] oldOperator = (txtOldOperator.Text.Remove(txtOldOperator.Text.LastIndexOf("|"))).Split('|'); if (!oldOperator.Contains(item.Value)) { s = MID.ToString() + "|" + item.Value; lst.Add(s); } } else { s = MID.ToString() + "|" + item.Value; lst.Add(s); } } //权限加入是否成功! if (mbll.CreateOperatorList(lst)) { JSHelper.AlertAndRefreshParentWin("添加成功!", "ModuleManage.aspx", this); } else { JSHelper.Alert("添加操作失败!", this); } } else { JSHelper.Alert("标识已存在,请更换后重试!", this); } } else { JSHelper.Alert("添加操作失败!", this); } } } else { JSHelper.Alert("请填写完整!", this); } }