public static RibButton PopulateRibButton(IDataReader reader) { RibButton item = new RibButton(); item.RibBtn = (short)reader["Rib_Btn"]; item.RibBtnName = reader["Rib_Btn_Name"] as string; item.RibBtnType = (short)reader["Rib_Btn_Type"]; item.RibOrder = (short)reader["Rib_Order"]; item.RibPanel = (short)reader["Rib_Panel"]; item.RibPanelName = reader["Rib_Panel_Name"] as string; item.RibTab = (short)reader["Rib_Tab"]; item.RibTabName = reader["Rib_Tab_Name"] as string; if (reader["Rib_Image"] != DBNull.Value) { item.RibImage = reader["Rib_Image"] as string; } item.RibImageIndex = (short)reader["Rib_Image_Index"]; if (reader["M_Function"] != DBNull.Value) { item.MFunction = reader["M_Function"] as string; } if (reader["M_Code"] != DBNull.Value) { item.MCode = reader["M_Code"] as string; } item.MID = (short)reader["M_ID"]; if (reader["Rib_Code"] != DBNull.Value) { item.RibCode = reader["Rib_Code"] as string; } return(item); }
public static void CreateUpdateDeleteRibButton(RibButton item, DataProviderAction action) { if (item == null) { return; } SqlConnection conn = DBUtils.GetConnection(); SqlCommand cmd = DBUtils.GetCommand(); try { cmd.Transaction = conn.BeginTransaction(); ArrayList paras = new ArrayList(); if (action == DataProviderAction.Create) { paras.Add(DBUtils.MakeOutParam("@Rib_Btn", SqlDbType.SmallInt)); } else { paras.Add(DBUtils.MakeInParam("@Rib_Btn", SqlDbType.SmallInt, item.RibBtn)); } paras.Add(DBUtils.MakeInParam("@Rib_Btn_Name", SqlDbType.NVarChar, 20, item.RibBtnName)); paras.Add(DBUtils.MakeInParam("@Rib_Btn_Type", SqlDbType.SmallInt, item.RibBtnType)); paras.Add(DBUtils.MakeInParam("@Rib_Order", SqlDbType.SmallInt, item.RibOrder)); paras.Add(DBUtils.MakeInParam("@Rib_Panel", SqlDbType.SmallInt, item.RibPanel)); paras.Add(DBUtils.MakeInParam("@Rib_Tab", SqlDbType.SmallInt, item.RibTab)); paras.Add(DBUtils.MakeInParam("@Rib_Image", SqlDbType.NVarChar, 20, item.RibImage)); paras.Add(DBUtils.MakeInParam("@Rib_Image_Index", SqlDbType.SmallInt, item.RibImageIndex)); paras.Add(DBUtils.MakeInParam("@M_Function", SqlDbType.NVarChar, 64, item.MFunction)); paras.Add(DBUtils.MakeInParam("@M_Code", SqlDbType.NVarChar, 12, item.MCode)); paras.Add(DBUtils.MakeInParam("@M_ID", SqlDbType.SmallInt, item.MID)); paras.Add(DBUtils.MakeInParam("@Rib_Code", SqlDbType.NVarChar, 12, item.RibCode)); paras.Add(DBUtils.MakeInParam("@Action", SqlDbType.Int, action)); DBUtils.ExecuteNonQuery(conn, cmd, CommandType.StoredProcedure, PublicConsts.DatabaseOwner + ".P_CreateUpdateDelete_RibButton", paras); if (action == DataProviderAction.Create) { item.RibBtn = ((((SqlParameter)paras[0]).Value != null) ? (Convert.ToInt16(((SqlParameter)paras[0]).Value)) : (short)0); } cmd.Transaction.Commit(); } catch { cmd.Transaction.Rollback(); throw; } finally { DBUtils.SetDispose(conn, cmd); } }
public static RibButton GetRibButton(short ribbtn) { RibButton item = new RibButton(); try { ArrayList paras = new ArrayList(); paras.Add(DBUtils.MakeInParam("@Rib_Btn", SqlDbType.SmallInt, ribbtn)); paras.Add(DBUtils.MakeInParam("@Get_Action", SqlDbType.NVarChar, 10, DataGetAction.Row.ToString().ToLower())); SqlDataReader reader = DBUtils.ExecuteReader(CommandType.StoredProcedure, PublicConsts.DatabaseOwner + ".P_Get_RibButton", paras); if (reader.Read()) { item = PopulateRibButton(reader); } reader.Close(); } catch { throw; } return(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; } }
public void Add(RibButton item) { base.List.Add(item); }