public ActionResult Create(System_Menu SMenu) { SMenu.Shortcut = 1; bool result = MenuInstance.Insert(SMenu); if (result) { return RedirectToAction("Index", "Menus"); } else { return View(); } }
private void GenerateChild(System_Menu Menu, List<System_Menu> allMenu) { Menu.ChildrenMenus = allMenu.Where(o => o.Menu_PCode == Menu.Menu_Code); if (Menu.ChildrenMenus.Count() == 0) { return; } foreach (var d in Menu.ChildrenMenus) { GenerateChild(d, allMenu); } }
private void GenerateChild(System_Menu Menu, List<System_Menu> allMenu) { //Menu = allMenu.Where(o => o.Menu_PCode == Menu.Menu_Code) //if (Menu.ChildrenMenus.Count() == 0) //{ // return; //} //foreach (var d in Menu.ChildrenMenus) //{ // GenerateChild(d, allMenu); //} }
/// <summary> /// 获取实体数据 /// </summary> /// <param name='strCondition'>条件(AND Code='11')</param> /// <returns>model</returns> public System_Menu GetModel(string strCondition) { List<System_Menu> list = instance.GetListByWhere(strCondition); System_Menu model = new System_Menu(); if (list != null && list.Count > 0) { model = list[0]; } else { model = null; } return model; }
/// <summary> /// 获取实体数据 /// </summary> /// <param name='strCondition'>条件(AND Code='11')</param> /// <returns>model</returns> public System_Menu GetModels(string strCondition) { string where = string.Format(" AND Menu_Code='{0}'", strCondition); List<System_Menu> list = instance.GetListByWhere(where); System_Menu model = new System_Menu(); if (list != null && list.Count > 0) { model = list[0]; } else { model = null; } return model; }
public bool AddUpdatePlanObject(System_Menu info) { int result = 0; if (info != null) { if (info.Menu_ID.Equals(0)) { result = instance.Add(info); } else { result = instance.Update(info); } } return result > 0 ? true : false; }
private static void GenerateChild(System_Menu Menu, List<System_Menu> allMenu) { var child=allMenu.Where(o => o.Menu_PCode == Menu.Menu_Code); if (child.Count()>0) { Menu.ChildrenMenus = child; } else { Menu.ChildrenMenus = null; } if (Menu.ChildrenMenus == null) { return; } foreach (var d in Menu.ChildrenMenus) { GenerateChild(d, allMenu); } }
public ActionResult Index(string id) { ViewData["MenuList"] = MenuInstance.GetChildListMenu(); if (string.IsNullOrEmpty(id)) { MenuModel = MenuInstance.GetModels("001"); return View(MenuModel); } else { MenuModel = MenuInstance.GetModels(id); var result = JsonConvert.SerializeObject(MenuModel, new JsonDateConverter("yyyy-MM-dd")); return JavaScript(result); } }
public List<System_Menu> GetAllShortcut() { List<System_Menu> ret = new List<System_Menu>(); string sql = "SELECT Menu_ID,Menu_Code,Menu_Title,Menu_Location,Menu_PCode,Menu_Enable,Menu_Url,Menu_Order,Stat,Menu_Icon,Shortcut FROM System_Menu where 1=1 AND ((Stat is null) or (Stat=0) ) and (Shortcut!=0) ORDER BY Shortcut "; SqlDataReader dr = null; try { dr = (SqlDataReader)idb.ReturnReader(sql); while (dr.Read()) { System_Menu system_Menu = new System_Menu(); if (dr["Menu_ID"] != DBNull.Value) system_Menu.Menu_ID = Convert.ToInt32(dr["Menu_ID"]); if (dr["Menu_Code"] != DBNull.Value) system_Menu.Menu_Code = Convert.ToString(dr["Menu_Code"]); if (dr["Menu_Title"] != DBNull.Value) system_Menu.Menu_Title = Convert.ToString(dr["Menu_Title"]); if (dr["Menu_Location"] != DBNull.Value) system_Menu.Menu_Location = Convert.ToString(dr["Menu_Location"]); if (dr["Menu_PCode"] != DBNull.Value) system_Menu.Menu_PCode = Convert.ToString(dr["Menu_PCode"]); if (dr["Menu_Enable"] != DBNull.Value) system_Menu.Menu_Enable = Convert.ToString(dr["Menu_Enable"]); if (dr["Menu_Url"] != DBNull.Value) system_Menu.Menu_Url = Convert.ToString(dr["Menu_Url"]); if (dr["Menu_Order"] != DBNull.Value) system_Menu.Menu_Order = Convert.ToInt32(dr["Menu_Order"]); if (dr["Stat"] != DBNull.Value) system_Menu.Stat = Convert.ToInt32(dr["Stat"]); if (dr["Menu_Icon"] != DBNull.Value) system_Menu.Menu_Icon = Convert.ToString(dr["Menu_Icon"]); if (dr["Shortcut"] != DBNull.Value) system_Menu.Shortcut = Convert.ToInt32(dr["Shortcut"]); ret.Add(system_Menu); } } catch (System.Exception ex) { throw ex; } finally { dr.Close(); } return ret; }
/// <summary> /// 更新系统菜单 System_Menu对象(即:一条记录 /// </summary> public int Update(System_Menu system_Menu) { StringBuilder sbParameter=new StringBuilder(); StringBuilder sb=new StringBuilder(); sb.Append(@"UPDATE System_Menu SET "); if(system_Menu.Menu_Code_IsChanged){sbParameter.Append("Menu_Code=@Menu_Code, ");} if(system_Menu.Menu_Title_IsChanged){sbParameter.Append("Menu_Title=@Menu_Title, ");} if(system_Menu.Menu_Location_IsChanged){sbParameter.Append("Menu_Location=@Menu_Location, ");} if(system_Menu.Menu_PCode_IsChanged){sbParameter.Append("Menu_PCode=@Menu_PCode, ");} if(system_Menu.Menu_Enable_IsChanged){sbParameter.Append("Menu_Enable=@Menu_Enable, ");} if(system_Menu.Menu_Url_IsChanged){sbParameter.Append("Menu_Url=@Menu_Url, ");} if(system_Menu.Menu_Order_IsChanged){sbParameter.Append("Menu_Order=@Menu_Order, ");} if(system_Menu.Menu_Icon_IsChanged){sbParameter.Append("Menu_Icon=@Menu_Icon, ");} if(system_Menu.Stat_IsChanged){sbParameter.Append("Stat=@Stat, ");} if(system_Menu.Shortcut_IsChanged){sbParameter.Append("Shortcut=@Shortcut ");} sb.Append(sbParameter.ToString().Trim().TrimEnd(',')); sb.Append( " WHERE 1=1 AND ((Stat is null) or (Stat=0)) and Menu_ID=@Menu_ID; " ); string sql=sb.ToString(); if(system_Menu.Menu_Code_IsChanged) { if (string.IsNullOrEmpty(system_Menu.Menu_Code)) { idb.AddParameter("@Menu_Code", DBNull.Value); } else { idb.AddParameter("@Menu_Code", system_Menu.Menu_Code); } } if(system_Menu.Menu_Title_IsChanged) { if (string.IsNullOrEmpty(system_Menu.Menu_Title)) { idb.AddParameter("@Menu_Title", DBNull.Value); } else { idb.AddParameter("@Menu_Title", system_Menu.Menu_Title); } } if(system_Menu.Menu_Location_IsChanged) { if (string.IsNullOrEmpty(system_Menu.Menu_Location)) { idb.AddParameter("@Menu_Location", DBNull.Value); } else { idb.AddParameter("@Menu_Location", system_Menu.Menu_Location); } } if(system_Menu.Menu_PCode_IsChanged) { if (string.IsNullOrEmpty(system_Menu.Menu_PCode)) { idb.AddParameter("@Menu_PCode", DBNull.Value); } else { idb.AddParameter("@Menu_PCode", system_Menu.Menu_PCode); } } if(system_Menu.Menu_Enable_IsChanged) { if (string.IsNullOrEmpty(system_Menu.Menu_Enable)) { idb.AddParameter("@Menu_Enable", DBNull.Value); } else { idb.AddParameter("@Menu_Enable", system_Menu.Menu_Enable); } } if(system_Menu.Menu_Url_IsChanged) { if (string.IsNullOrEmpty(system_Menu.Menu_Url)) { idb.AddParameter("@Menu_Url", DBNull.Value); } else { idb.AddParameter("@Menu_Url", system_Menu.Menu_Url); } } if(system_Menu.Menu_Order_IsChanged) { if (system_Menu.Menu_Order == 0) { idb.AddParameter("@Menu_Order", 0); } else { idb.AddParameter("@Menu_Order", system_Menu.Menu_Order); } } if(system_Menu.Menu_Icon_IsChanged) { if (string.IsNullOrEmpty(system_Menu.Menu_Icon)) { idb.AddParameter("@Menu_Icon", DBNull.Value); } else { idb.AddParameter("@Menu_Icon", system_Menu.Menu_Icon); } } if(system_Menu.Stat_IsChanged) { if (system_Menu.Stat == 0) { idb.AddParameter("@Stat", 0); } else { idb.AddParameter("@Stat", system_Menu.Stat); } } if(system_Menu.Shortcut_IsChanged) { if (system_Menu.Shortcut == 0) { idb.AddParameter("@Shortcut", 0); } else { idb.AddParameter("@Shortcut", system_Menu.Shortcut); } } idb.AddParameter("@Menu_ID", system_Menu.Menu_ID); int Re = 0; //SQL日志记录 var RunMethod = System.Reflection.MethodBase.GetCurrentMethod(); System.Collections.Hashtable param = new System.Collections.Hashtable(); string Ex = "0"; foreach (System.Collections.DictionaryEntry item in idb.GetParameters()) { param.Add(item.Key, item.Value); } try { Re = idb.ExeCmd(sql); Ex = Re.ToString(); } catch (Exception ex) { Ex = ex.Message; } SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name,Ex); return Re; }
/// <summary> /// 获取指定的系统菜单 System_Menu对象集合 /// </summary> public List<System_Menu> GetListByWhere(string strCondition) { List<System_Menu> ret = new List<System_Menu>(); string sql = "SELECT Menu_ID,Menu_Code,Menu_Title,Menu_Location,Menu_PCode,Menu_Enable,Menu_Url,Menu_Order,Menu_Icon,Stat,Shortcut FROM System_Menu WHERE 1=1 AND ((Stat is null) or (Stat=0) ) "; if(!string.IsNullOrEmpty(strCondition)) { strCondition.Replace('\'','"'); //防sql注入 sql += strCondition ; } SqlDataReader dr=null; try { dr=(SqlDataReader)idb.ReturnReader(sql); while(dr.Read()) { System_Menu system_Menu = new System_Menu(); if (dr["Menu_ID"] != DBNull.Value) system_Menu.Menu_ID = Convert.ToDecimal(dr["Menu_ID"]); if (dr["Menu_Code"] != DBNull.Value) system_Menu.Menu_Code = Convert.ToString(dr["Menu_Code"]); if (dr["Menu_Title"] != DBNull.Value) system_Menu.Menu_Title = Convert.ToString(dr["Menu_Title"]); if (dr["Menu_Location"] != DBNull.Value) system_Menu.Menu_Location = Convert.ToString(dr["Menu_Location"]); if (dr["Menu_PCode"] != DBNull.Value) system_Menu.Menu_PCode = Convert.ToString(dr["Menu_PCode"]); if (dr["Menu_Enable"] != DBNull.Value) system_Menu.Menu_Enable = Convert.ToString(dr["Menu_Enable"]); if (dr["Menu_Url"] != DBNull.Value) system_Menu.Menu_Url = Convert.ToString(dr["Menu_Url"]); if (dr["Menu_Order"] != DBNull.Value) system_Menu.Menu_Order = Convert.ToInt32(dr["Menu_Order"]); if (dr["Menu_Icon"] != DBNull.Value) system_Menu.Menu_Icon = Convert.ToString(dr["Menu_Icon"]); if (dr["Stat"] != DBNull.Value) system_Menu.Stat = Convert.ToInt32(dr["Stat"]); if (dr["Shortcut"] != DBNull.Value) system_Menu.Shortcut = Convert.ToInt32(dr["Shortcut"]); ret.Add(system_Menu); } }catch (System.Exception ex){ throw ex; } finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); } } return ret; }
/// <summary> /// 获取指定的系统菜单 System_Menu对象(即:一条记录 /// </summary> public System_Menu GetByKey(decimal menu_ID) { System_Menu system_Menu = new System_Menu(); string sql = "SELECT Menu_ID,Menu_Code,Menu_Title,Menu_Location,Menu_PCode,Menu_Enable,Menu_Url,Menu_Order,Menu_Icon,Stat,Shortcut FROM System_Menu WHERE 1=1 AND ((Stat is null) or (Stat=0) ) AND Menu_ID=@Menu_ID "; idb.AddParameter("@Menu_ID", menu_ID); SqlDataReader dr=null; try { dr=(SqlDataReader)idb.ReturnReader(sql); while(dr.Read()) { if (dr["Menu_ID"] != DBNull.Value) system_Menu.Menu_ID = Convert.ToDecimal(dr["Menu_ID"]); if (dr["Menu_Code"] != DBNull.Value) system_Menu.Menu_Code = Convert.ToString(dr["Menu_Code"]); if (dr["Menu_Title"] != DBNull.Value) system_Menu.Menu_Title = Convert.ToString(dr["Menu_Title"]); if (dr["Menu_Location"] != DBNull.Value) system_Menu.Menu_Location = Convert.ToString(dr["Menu_Location"]); if (dr["Menu_PCode"] != DBNull.Value) system_Menu.Menu_PCode = Convert.ToString(dr["Menu_PCode"]); if (dr["Menu_Enable"] != DBNull.Value) system_Menu.Menu_Enable = Convert.ToString(dr["Menu_Enable"]); if (dr["Menu_Url"] != DBNull.Value) system_Menu.Menu_Url = Convert.ToString(dr["Menu_Url"]); if (dr["Menu_Order"] != DBNull.Value) system_Menu.Menu_Order = Convert.ToInt32(dr["Menu_Order"]); if (dr["Menu_Icon"] != DBNull.Value) system_Menu.Menu_Icon = Convert.ToString(dr["Menu_Icon"]); if (dr["Stat"] != DBNull.Value) system_Menu.Stat = Convert.ToInt32(dr["Stat"]); if (dr["Shortcut"] != DBNull.Value) system_Menu.Shortcut = Convert.ToInt32(dr["Shortcut"]); } }catch (System.Exception ex){ throw ex; } finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); } } return system_Menu; }
/// <summary> /// 获取所有的系统菜单 System_Menu对象(即:一条记录 /// </summary> public List<System_Menu> GetAll() { List<System_Menu> ret = new List<System_Menu>(); string sql = "SELECT Menu_ID,Menu_Code,Menu_Title,Menu_Location,Menu_PCode,Menu_Enable,Menu_Url,Menu_Order,Menu_Icon,Stat,Shortcut FROM System_Menu where 1=1 AND ((Stat is null) or (Stat=0) ) order by Menu_ID desc "; SqlDataReader dr=null; try { dr=(SqlDataReader)idb.ReturnReader(sql); while(dr.Read()) { System_Menu system_Menu = new System_Menu(); if (dr["Menu_ID"] != DBNull.Value) system_Menu.Menu_ID = Convert.ToDecimal(dr["Menu_ID"]); if (dr["Menu_Code"] != DBNull.Value) system_Menu.Menu_Code = Convert.ToString(dr["Menu_Code"]); if (dr["Menu_Title"] != DBNull.Value) system_Menu.Menu_Title = Convert.ToString(dr["Menu_Title"]); if (dr["Menu_Location"] != DBNull.Value) system_Menu.Menu_Location = Convert.ToString(dr["Menu_Location"]); if (dr["Menu_PCode"] != DBNull.Value) system_Menu.Menu_PCode = Convert.ToString(dr["Menu_PCode"]); if (dr["Menu_Enable"] != DBNull.Value) system_Menu.Menu_Enable = Convert.ToString(dr["Menu_Enable"]); if (dr["Menu_Url"] != DBNull.Value) system_Menu.Menu_Url = Convert.ToString(dr["Menu_Url"]); if (dr["Menu_Order"] != DBNull.Value) system_Menu.Menu_Order = Convert.ToInt32(dr["Menu_Order"]); if (dr["Menu_Icon"] != DBNull.Value) system_Menu.Menu_Icon = Convert.ToString(dr["Menu_Icon"]); if (dr["Stat"] != DBNull.Value) system_Menu.Stat = Convert.ToInt32(dr["Stat"]); if (dr["Shortcut"] != DBNull.Value) system_Menu.Shortcut = Convert.ToInt32(dr["Shortcut"]); ret.Add(system_Menu); } }catch (System.Exception ex){ throw ex; } finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); } } return ret; }
/// <summary> /// 添加系统菜单 System_Menu对象(即:一条记录) /// </summary> public int Add(System_Menu system_Menu) { string sql = "INSERT INTO System_Menu (Menu_Code,Menu_Title,Menu_Location,Menu_PCode,Menu_Enable,Menu_Url,Menu_Order,Menu_Icon,Stat,Shortcut) VALUES (@Menu_Code,@Menu_Title,@Menu_Location,@Menu_PCode,@Menu_Enable,@Menu_Url,@Menu_Order,@Menu_Icon,@Stat,@Shortcut)"; if (string.IsNullOrEmpty(system_Menu.Menu_Code)) { idb.AddParameter("@Menu_Code", DBNull.Value); } else { idb.AddParameter("@Menu_Code", system_Menu.Menu_Code); } if (string.IsNullOrEmpty(system_Menu.Menu_Title)) { idb.AddParameter("@Menu_Title", DBNull.Value); } else { idb.AddParameter("@Menu_Title", system_Menu.Menu_Title); } if (string.IsNullOrEmpty(system_Menu.Menu_Location)) { idb.AddParameter("@Menu_Location", DBNull.Value); } else { idb.AddParameter("@Menu_Location", system_Menu.Menu_Location); } if (string.IsNullOrEmpty(system_Menu.Menu_PCode)) { idb.AddParameter("@Menu_PCode", DBNull.Value); } else { idb.AddParameter("@Menu_PCode", system_Menu.Menu_PCode); } if (string.IsNullOrEmpty(system_Menu.Menu_Enable)) { idb.AddParameter("@Menu_Enable", DBNull.Value); } else { idb.AddParameter("@Menu_Enable", system_Menu.Menu_Enable); } if (string.IsNullOrEmpty(system_Menu.Menu_Url)) { idb.AddParameter("@Menu_Url", DBNull.Value); } else { idb.AddParameter("@Menu_Url", system_Menu.Menu_Url); } if (system_Menu.Menu_Order == 0) { idb.AddParameter("@Menu_Order", 0); } else { idb.AddParameter("@Menu_Order", system_Menu.Menu_Order); } if (string.IsNullOrEmpty(system_Menu.Menu_Icon)) { idb.AddParameter("@Menu_Icon", DBNull.Value); } else { idb.AddParameter("@Menu_Icon", system_Menu.Menu_Icon); } if (system_Menu.Stat == 0) { idb.AddParameter("@Stat", 0); } else { idb.AddParameter("@Stat", system_Menu.Stat); } if (system_Menu.Shortcut == 0) { idb.AddParameter("@Shortcut", 0); } else { idb.AddParameter("@Shortcut", system_Menu.Shortcut); } int Re = 0; //SQL日志记录 var RunMethod = System.Reflection.MethodBase.GetCurrentMethod(); System.Collections.Hashtable param = new System.Collections.Hashtable(); string Ex = "0"; foreach (System.Collections.DictionaryEntry item in idb.GetParameters()) { param.Add(item.Key, item.Value); } try { Re = idb.ExeCmd(sql); Ex = Re.ToString(); } catch (Exception ex) { Ex = ex.Message; } SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name,Ex); return Re; }
public ActionResult Menusadd(System_Menu sf) { bool result = new BLL.Bll_System_Menu().Update(sf); string strResult = result ? sf.Menu_Code : "fail"; return Content(strResult); }
public ActionResult EditContact(System_Menu sf) { return new BLL.Bll_System_Menu().AddUpdatePlanObject(sf) ? Content("success") : Content("false"); }
public ActionResult Index(System_Menu Smenu) { bool result = MenuInstance.Update(Smenu); if (result) { return RedirectToAction("Index", "Menus"); } else { return View(); } }
/// <summary> /// 更新数据 /// </summary> /// <param name='model'>实体</param> /// <returns>bool</returns> public bool Update(System_Menu model,bool IsValid) { bool result = false; var e = new ModelExceptions(); if(e.IsValid && IsValid){ int _rseult = instance.Update(model); if (_rseult > 0) { result = true; } } return result; }
/// <summary> /// 插入数据 /// </summary> /// <param name='model'>实体</param> /// <param name='model'>是否完成验证</param> /// <returns>bool</returns> public bool Insert(System_Menu model,bool IsValid) { var e = new ModelExceptions(); bool result = false; if (e.IsValid && IsValid) { //完成了验证,开始更新数据库了 int _result = instance.Add(model); if (_result > 0) { result = true; } } return result; }
/// <summary> /// 插入数据 /// </summary> /// <param name='model'>实体</param> /// <returns>bool</returns> public bool Insert(System_Menu model) { bool result = false; try { int _result = instance.Add(model); if (_result > 0) { result = true; } } catch (Exception ex) { throw ex; } return result; }
public ActionResult EditData(System_Menu SMenu) { bool result = false; try { result = MenuInstance.Update(SMenu,ModelState.IsValid); } catch (ModelExceptions e) { e.FillModelState(ModelState); } if (result && ModelState.IsValid ) { //return RedirectToAction("Index", "Menus"); return View("/Menus/index" + SMenu.Menu_Code, SMenu); } else { return JsonError(GetError(ModelState), true); } }