/// <summary> /// 得到一个对象实体 /// </summary> public static EtNet_Models.PanelMenu GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,founderid,colsnum,rowsnum,title,imageload,direction from PanelMenu "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; EtNet_Models.PanelMenu model = new EtNet_Models.PanelMenu(); DataTable tbl = EtNet_DAL.DBHelper.GetDataSet(strSql.ToString(), parameters); if (tbl.Rows.Count > 0) { model.id = int.Parse(tbl.Rows[0]["id"].ToString()); model.founderid = int.Parse(tbl.Rows[0]["founderid"].ToString()); model.colsnum = int.Parse(tbl.Rows[0]["colsnum"].ToString()); model.rowsnum = int.Parse(tbl.Rows[0]["rowsnum"].ToString()); model.title = tbl.Rows[0]["title"].ToString(); model.imageload = tbl.Rows[0]["imageload"].ToString(); model.direction = tbl.Rows[0]["direction"].ToString(); return(model); } else { return(null); } }
//删除一个面板菜单 private void DelPanelMenu(HttpContext context) { int id = int.Parse(context.Request.QueryString["menuid"].Substring(7)); EtNet_Models.PanelMenu model = EtNet_BLL.PanelMenuManager.GetModel(id); if (model != null) { if (EtNet_BLL.PanelMenuManager.Delete(id)) { int closnum = model.colsnum; //所属行的位置 int rowsnum = model.rowsnum; //所属列的位置 string str = " founderid=" + ((EtNet_Models.LoginInfo)context.Session["login"]).Id; str += " AND colsnum =" + closnum; str += " AND rowsnum >" + rowsnum; str += " order by rowsnum asc "; DataTable tbl = EtNet_BLL.PanelMenuManager.GetList(str); for (int i = 0; i < tbl.Rows.Count; i++) { model = new EtNet_Models.PanelMenu(); model.id = int.Parse(tbl.Rows[i]["id"].ToString()); model.imageload = tbl.Rows[i]["imageload"].ToString(); model.title = tbl.Rows[i]["title"].ToString(); model.colsnum = int.Parse(tbl.Rows[i]["colsnum"].ToString()); model.direction = tbl.Rows[i]["direction"].ToString(); model.founderid = int.Parse(tbl.Rows[i]["founderid"].ToString()); model.rowsnum = int.Parse(tbl.Rows[i]["rowsnum"].ToString()) - 1; EtNet_BLL.PanelMenuManager.Update(model); } } } }
//修改菜单面板的标题 private void ModifyPanelMenuTitle(HttpContext context) { string[] str = context.Request.QueryString["id"].ToString().Split(','); int id = int.Parse(str[0].Trim().Substring(7).ToString()); EtNet_Models.PanelMenu model = EtNet_BLL.PanelMenuManager.GetModel(id); model.title = str[1]; EtNet_BLL.PanelMenuManager.Update(model); }
/// <summary> /// 修改面板菜单位置 /// </summary> private void ModifyPanelMenu(HttpContext context) { string[] dtlist = context.Request.QueryString["datalist"].Split(','); string[] data = null; EtNet_Models.PanelMenu model = null; for (int i = 0; i < dtlist.Length - 1; i++) { data = dtlist[i].Split('_'); model = EtNet_BLL.PanelMenuManager.GetModel(int.Parse(data[0].Substring(7))); string strd = data[1]; model.colsnum = JudgeColsPosition(data[1]); model.rowsnum = int.Parse(data[2]); EtNet_BLL.PanelMenuManager.Update(model); } context.Response.Write("已修改!"); }
/// <summary> /// 合并为指定的列数 /// </summary> private void MergerDataList(int targetnum) { string strSql = " founderid=" + ((EtNet_Models.LoginInfo)Session["login"]).Id; strSql += " order by colsnum,rowsnum"; DataTable tbl = EtNet_BLL.PanelMenuManager.GetList(strSql); DataRow[] rows = null; EtNet_Models.PanelMenu model = null; int colsnoe = 0; if (tbl.Rows.Count > 0) { switch (targetnum) { case 1: colsnoe = tbl.Select(" colsnum = 1").Length; rows = tbl.Select("colsnum in(2,3)"); break; case 2: colsnoe = tbl.Select(" colsnum = 1").Length; rows = tbl.Select("colsnum in(3)"); break; case 3: colsnoe = tbl.Select(" colsnum = 1").Length; rows = tbl.Select("colsnum in(4)"); break; } for (int i = 0; i < rows.Length; i++) { model = new EtNet_Models.PanelMenu(); model.id = int.Parse(rows[i]["id"].ToString()); model.founderid = int.Parse(rows[i]["founderid"].ToString()); model.colsnum = 1; model.direction = rows[i]["direction"].ToString(); model.imageload = rows[i]["imageload"].ToString(); model.title = rows[i]["title"].ToString(); model.rowsnum = ++colsnoe; EtNet_BLL.PanelMenuManager.Update(model); } } }
/// <summary> /// 首次打开主页面板时创建的默认的条目 /// </summary> private void FirstPanelItem(int founderid, string panel) { string strSql = " id in(" + panel + ")"; DataTable tbl = EtNet_BLL.PanelMenuListManager.GetList(strSql); EtNet_Models.PanelMenu model = null; for (int i = 0; i < tbl.Rows.Count; i++) { model = new EtNet_Models.PanelMenu(); model.colsnum = 1; model.rowsnum = i + 1; model.title = tbl.Rows[i]["cname"].ToString(); model.imageload = tbl.Rows[i]["imageload"].ToString(); model.founderid = founderid; model.direction = tbl.Rows[i]["num"].ToString(); EtNet_BLL.PanelMenuManager.Add(model); } }
/// <summary> /// 首次打开主页面板时创建的四个默认的条目 /// </summary> private void FirstFourLItem() { string strSql = " num in('1','2','5','12')"; DataTable tbl = EtNet_BLL.PanelMenuListManager.GetList(strSql); EtNet_Models.PanelMenu model = null; for (int i = 0; i < tbl.Rows.Count; i++) { model = new EtNet_Models.PanelMenu(); model.colsnum = 1; model.rowsnum = i + 1; model.title = tbl.Rows[i]["cname"].ToString(); model.imageload = tbl.Rows[i]["imageload"].ToString(); model.founderid = ((EtNet_Models.LoginInfo)Session["login"]).Id; model.direction = tbl.Rows[i]["num"].ToString(); EtNet_BLL.PanelMenuManager.Add(model); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(EtNet_Models.PanelMenu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PanelMenu set "); strSql.Append("founderid=@founderid,"); strSql.Append("colsnum=@colsnum,"); strSql.Append("rowsnum=@rowsnum,"); strSql.Append("title=@title,"); strSql.Append("imageload=@imageload,"); strSql.Append("direction=@direction"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@founderid", SqlDbType.Int, 4), new SqlParameter("@colsnum", SqlDbType.Int, 4), new SqlParameter("@rowsnum", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.VarChar, 100), new SqlParameter("@imageload", SqlDbType.VarChar, 200), new SqlParameter("@direction", SqlDbType.VarChar, 20), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.founderid; parameters[1].Value = model.colsnum; parameters[2].Value = model.rowsnum; parameters[3].Value = model.title; parameters[4].Value = model.imageload; parameters[5].Value = model.direction; parameters[6].Value = model.id; int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters); if (result >= 1) { return(true); } else { return(false); } }
/// <summary> /// 新加菜单面板 /// </summary> private void AddPanelMenu(HttpContext context) { int id = int.Parse(context.Request.QueryString["id"].Trim()); EtNet_Models.PanelMenuList model = EtNet_BLL.PanelMenuListManager.GetModel(id); string str = " founderid=" + ((EtNet_Models.LoginInfo)context.Session["login"]).Id + " AND colsnum='1' "; if (model != null) { int rows = EtNet_BLL.PanelMenuManager.GetList(str).Rows.Count; EtNet_Models.PanelMenu menumodel = new EtNet_Models.PanelMenu(); menumodel.colsnum = 1; menumodel.rowsnum = rows + 1; menumodel.title = model.cname; menumodel.imageload = model.imageload; menumodel.direction = model.num; menumodel.founderid = ((EtNet_Models.LoginInfo)context.Session["login"]).Id; if (EtNet_BLL.PanelMenuManager.Add(menumodel)) { string strdata = " <div id='portlet" + EtNet_BLL.PanelMenuManager.MaxId().ToString() + "' class='portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'>"; strdata += "<div class='portlet-header ui-widget-header ui-corner-all'>"; strdata += "<span class='ui-icon-del'></span><span class='ui-icon ui-icon-expand'></span>"; strdata += "<span class='ui-icon-edit'></span><span class='ui-icon-refresh'></span><span class='portlet-header-title'>" + model.cname + "</span></div>"; strdata += "<div id='content" + model.num + "' class='portlet-content' style='display:block;'>"; context.Response.Write(strdata); LoadContentData(context, model.num.Trim()); strdata = "</div></div>"; context.Response.Write(strdata); } } }
/// <summary> /// 增加一条数据 /// </summary> public static bool Add(EtNet_Models.PanelMenu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PanelMenu("); strSql.Append("founderid,colsnum,rowsnum,title,imageload,direction)"); strSql.Append(" values ("); strSql.Append("@founderid,@colsnum,@rowsnum,@title,@imageload,@direction)"); SqlParameter[] parameters = { new SqlParameter("@founderid", SqlDbType.Int, 4), new SqlParameter("@colsnum", SqlDbType.Int, 4), new SqlParameter("@rowsnum", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.VarChar, 100), new SqlParameter("@imageload", SqlDbType.VarChar, 200), new SqlParameter("@direction", SqlDbType.VarChar, 20) }; parameters[0].Value = model.founderid; parameters[1].Value = model.colsnum; parameters[2].Value = model.rowsnum; parameters[3].Value = model.title; parameters[4].Value = model.imageload; parameters[5].Value = model.direction; int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters); if (result >= 1) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(EtNet_Models.PanelMenu model) { return(EtNet_DAL.PanelMenuService.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public static bool Add(EtNet_Models.PanelMenu model) { return(EtNet_DAL.PanelMenuService.Add(model)); }