public static void CreateUpdateDeleteSysMenu(SysMenu item, DataProviderAction action) { if (item == null) { return; } SqlConnection conn = DBUtils.GetConnection(); SqlCommand cmd = DBUtils.GetCommand(); try { cmd.Transaction = conn.BeginTransaction(); ArrayList paras = new ArrayList(); paras.Add(DBUtils.MakeInParam("@M_ID", SqlDbType.SmallInt, item.MID)); paras.Add(DBUtils.MakeInParam("@M_Name", SqlDbType.NVarChar, 40, item.MName)); paras.Add(DBUtils.MakeInParam("@M_PID", SqlDbType.SmallInt, item.MPID)); paras.Add(DBUtils.MakeInParam("@Mg_ID", SqlDbType.SmallInt, item.MgID)); paras.Add(DBUtils.MakeInParam("@M_Level", SqlDbType.SmallInt, item.MLevel)); paras.Add(DBUtils.MakeInParam("@M_Disp", SqlDbType.SmallInt, item.MDisp)); paras.Add(DBUtils.MakeInParam("@M_Auth", SqlDbType.Int, item.MAuth)); paras.Add(DBUtils.MakeInParam("@M_Tip", SqlDbType.NVarChar, 120, item.MTip)); paras.Add(DBUtils.MakeInParam("@M_Function", SqlDbType.NVarChar, 64, item.MFunction)); paras.Add(DBUtils.MakeInParam("@Is_Line", SqlDbType.Bit, item.IsLine)); paras.Add(DBUtils.MakeInParam("@Is_Sub", SqlDbType.Bit, item.IsSub)); paras.Add(DBUtils.MakeInParam("@M_SID", SqlDbType.SmallInt, item.MSID)); paras.Add(DBUtils.MakeInParam("@M_Normal_Icon", SqlDbType.NVarChar, 32, item.MNormalIcon)); paras.Add(DBUtils.MakeInParam("@M_Hot_Icon", SqlDbType.NVarChar, 32, item.MHotIcon)); paras.Add(DBUtils.MakeInParam("@M_Disable_Icon", SqlDbType.NVarChar, 32, item.MDisableIcon)); paras.Add(DBUtils.MakeInParam("@M_Icon_Index", SqlDbType.SmallInt, item.MIconIndex)); paras.Add(DBUtils.MakeInParam("@Is_Base", SqlDbType.Bit, item.IsBase)); paras.Add(DBUtils.MakeInParam("@M_Code", SqlDbType.NVarChar, 12, item.MCode)); paras.Add(DBUtils.MakeInParam("@M_Status", SqlDbType.SmallInt, item.MStatus)); paras.Add(DBUtils.MakeInParam("@M_Shortcut", SqlDbType.NVarChar, 20, item.MShortcut)); paras.Add(DBUtils.MakeInParam("@Action", SqlDbType.Int, action)); DBUtils.ExecuteNonQuery(conn, cmd, CommandType.StoredProcedure, PublicConsts.DatabaseOwner + ".P_CreateUpdateDelete_SysMenu", paras); cmd.Transaction.Commit(); } catch { cmd.Transaction.Rollback(); throw; } finally { DBUtils.SetDispose(conn, cmd); } }
public static SysMenu PopulateSysMenu(IDataReader reader) { SysMenu item = new SysMenu(); item.MID = (short)reader["M_ID"]; item.MName = reader["M_Name"] as string; item.MPID = (short)reader["M_PID"]; item.MgID = (short)reader["Mg_ID"]; item.MgName = reader["Mg_Name"] as string; item.MLevel = (short)reader["M_Level"]; item.MDisp = (short)reader["M_Disp"]; item.MAuth = (int)reader["M_Auth"]; if (reader["M_Tip"] != DBNull.Value) { item.MTip = reader["M_Tip"] as string; } if (reader["M_Function"] != DBNull.Value) { item.MFunction = reader["M_Function"] as string; } item.IsLine = Convert.ToBoolean(reader["Is_Line"]); item.IsSub = Convert.ToBoolean(reader["Is_Sub"]); if (reader["M_SID"] != DBNull.Value) { item.MSID = (short)reader["M_SID"]; } if (reader["M_Normal_Icon"] != DBNull.Value) { item.MNormalIcon = reader["M_Normal_Icon"] as string; } if (reader["M_Hot_Icon"] != DBNull.Value) { item.MHotIcon = reader["M_Hot_Icon"] as string; } if (reader["M_Disable_Icon"] != DBNull.Value) { item.MDisableIcon = reader["M_Disable_Icon"] as string; } item.MIconIndex = (short)reader["M_Icon_Index"]; item.IsBase = Convert.ToBoolean(reader["Is_Base"]); item.MCode = reader["M_Code"] as string; item.MStatus = (short)reader["M_Status"]; if (reader["M_Shortcut"] != DBNull.Value) { item.MShortcut = reader["M_Shortcut"] as string; } return(item); }
public static SysMenu GetSysMenu(short mid) { SysMenu item = new SysMenu(); try { ArrayList paras = new ArrayList(); paras.Add(DBUtils.MakeInParam("@M_ID", SqlDbType.SmallInt, mid)); paras.Add(DBUtils.MakeInParam("@Get_Action", SqlDbType.NVarChar, 10, DataGetAction.Row.ToString().ToLower())); SqlDataReader reader = DBUtils.ExecuteReader(CommandType.StoredProcedure, PublicConsts.DatabaseOwner + ".P_Get_SysMenu", paras); if (reader.Read()) { item = PopulateSysMenu(reader); } reader.Close(); } catch { throw; } return(item); }
public void Add(SysMenu item) { base.List.Add(item); }
public static void GetManMenus(UserCache uc, string manid) { if (uc == null) { return; } SysMenuGroups ag = uc.Menus; SysMenu fm; SysMenuGroup fg; RibTabs rts = uc.Ribbons; RibTab rt; RibPanel rp; try { ArrayList paras = new ArrayList(); paras.Add(DBUtils.MakeInParam("@Man_ID", SqlDbType.NVarChar, 6, manid)); SqlDataReader reader = DBUtils.ExecuteReader(CommandType.StoredProcedure, PublicConsts.DatabaseOwner + ".P_Get_Man_Menus", paras); #region Read MenuGroups while (reader.Read()) { SysMenuGroup mgItem = new SysMenuGroup(); mgItem.MgID = (short)reader["mg_id"]; mgItem.MgName = reader["mg_name"] as string; if (reader["mg_tip"] != DBNull.Value) { mgItem.MgTip = reader["mg_tip"] as string; } if (reader["mg_normal_icon"] != DBNull.Value) { mgItem.MgNormalIcon = reader["mg_normal_icon"] as string; } if (reader["mg_hot_icon"] != DBNull.Value) { mgItem.MgHotIcon = reader["mg_hot_icon"] as string; } if (reader["mg_disable_icon"] != DBNull.Value) { mgItem.MgDisableIcon = reader["mg_disable_icon"] as string; } mgItem.MgIconIndex = (short)reader["mg_icon_index"]; if (reader["mg_function"] != DBNull.Value) { mgItem.MgFunction = reader["mg_function"] as string; } mgItem.MgStatus = (short)reader["mg_status"]; mgItem.MgOrder = (short)reader["mg_order"]; ag.Add(mgItem); } #endregion Read MenuGroups #region Read Menus if (reader.NextResult() && (ag.Count > 0)) { while (reader.Read()) { if ((fg = ag.FindByGroupID((short)reader["mg_id"])) != null) { if ((fm = fg.Menus.FindSubMenu((short)reader["m_id"])) != null) { fm.MAuth = (int)((AuthType)fm.MAuth | (AuthType)((int)reader["menu_auth"])); continue; } } SysMenu mItem = new SysMenu(); mItem.MID = (short)reader["m_id"]; mItem.MName = reader["m_name"] as string; mItem.MPID = (short)reader["m_pid"]; mItem.MgID = (short)reader["mg_id"]; mItem.MLevel = (short)reader["m_level"]; mItem.MDisp = (short)reader["m_disp"]; mItem.MAuth = (int)reader["menu_auth"]; if (reader["m_tip"] != DBNull.Value) { mItem.MTip = reader["m_tip"] as string; } if (reader["m_function"] != DBNull.Value) { mItem.MFunction = reader["m_function"] as string; } mItem.IsLine = Convert.ToBoolean(reader["is_line"]); mItem.IsSub = Convert.ToBoolean(reader["is_sub"]); if (reader["m_sid"] != DBNull.Value) { mItem.MSID = (short)reader["m_sid"]; } if (reader["m_normal_icon"] != DBNull.Value) { mItem.MNormalIcon = reader["m_normal_icon"] as string; } if (reader["m_hot_icon"] != DBNull.Value) { mItem.MHotIcon = reader["m_hot_icon"] as string; } if (reader["m_disable_icon"] != DBNull.Value) { mItem.MDisableIcon = reader["m_disable_icon"] as string; } mItem.MIconIndex = (short)reader["m_icon_index"]; mItem.IsBase = Convert.ToBoolean(reader["is_base"]); mItem.MCode = reader["m_code"] as string; mItem.MStatus = (short)reader["m_status"]; if (reader["M_Shortcut"] != DBNull.Value) { mItem.MShortcut = reader["M_Shortcut"] as string; } if (fg != null) { if (mItem.MID != mItem.MPID) { fm = fg.Menus.FindSubMenu(mItem.MPID); if (fm != null) { fm.SubMenus.Add(mItem); } } else { fg.Menus.Add(mItem); } } } } #endregion Read Menus #region Read Ribbon Tabs if (reader.NextResult() && (ag.Count > 0)) { while (reader.Read()) { RibTab rtItem = new RibTab(); rtItem.ID = (short)reader["Rib_Tab"]; rtItem.RibTabName = reader["Rib_Tab_Name"] as string; rtItem.RibOrder = (short)reader["Rib_Order"]; rts.Add(rtItem); } } #endregion Read Ribbon Tabs #region Read Ribbon Panels if (reader.NextResult() && (ag.Count > 0)) { while (reader.Read()) { rt = rts.FindByRibTab((short)reader["Rib_Tab"]); if (rt == null) { continue; } RibPanel rpItem = new RibPanel(); rpItem.ID = (short)reader["Rib_Panel"]; rpItem.RibPanelName = reader["Rib_Panel_Name"] as string; rpItem.RibOrder = (short)reader["Rib_Order"]; rpItem.RibTab = (short)reader["Rib_Tab"]; rt.Panels.Add(rpItem); } } #endregion Read Ribbon Panels #region Read Ribbon Buttons if (reader.NextResult() && (ag.Count > 0)) { while (reader.Read()) { rt = rts.FindByRibTab((short)reader["Rib_Tab"]); if (rt == null) { continue; } rp = rt.Panels.FindByRibPanel((short)reader["Rib_Panel"]); if (rp == null) { continue; } RibButton rbItem = new RibButton(); rbItem.RibBtn = (short)reader["Rib_Btn"]; rbItem.RibBtnName = reader["Rib_Btn_Name"] as string; rbItem.RibBtnType = (short)reader["Rib_Btn_Type"]; rbItem.RibOrder = (short)reader["Rib_Order"]; rbItem.RibPanel = (short)reader["Rib_Panel"]; rbItem.RibTab = (short)reader["Rib_Tab"]; if (reader["Rib_Image"] != DBNull.Value) { rbItem.RibImage = reader["Rib_Image"] as string; } rbItem.RibImageIndex = (short)reader["Rib_Image_Index"]; if (reader["M_Function"] != DBNull.Value) { rbItem.MFunction = reader["M_Function"] as string; } if (reader["M_Code"] != DBNull.Value) { rbItem.MCode = reader["M_Code"] as string; } rbItem.MID = (short)reader["M_ID"]; if (reader["Rib_Code"] != DBNull.Value) { rbItem.RibCode = reader["Rib_Code"] as string; } rp.Buttons.Add(rbItem); } } #endregion Read Ribbon Buttons reader.Close(); } catch { throw; } }