private void AddRolePage(ProxySocket proxySocket) { if (InvokeRequired) { Invoke(new Action <ProxySocket>(AddRolePage), proxySocket); } else { if (_dicProxySocket.ContainsKey(proxySocket.PlayerInfo.Username)) { var rc = (RoleControl)tcAccount.TabPages[proxySocket.PlayerInfo.Username].Controls[0]; proxySocket.SetRoleControl(rc); rc.SetProxySocket(proxySocket); _dicProxySocket[proxySocket.PlayerInfo.Username] = proxySocket; return; } var role = new RoleControl(); proxySocket.SetRoleControl(role); role.SetProxySocket(proxySocket); _dicProxySocket.Add(proxySocket.PlayerInfo.Username, proxySocket); var tp = new TabPage(proxySocket.PlayerInfo.Username); tp.Name = proxySocket.PlayerInfo.Username; tp.Controls.Add(role); role.Dock = DockStyle.Fill; tcAccount.TabPages.Add(tp); } }
void Start() { // this.SetAtkBtnCallbacks(); m_AllCtrls.Clear(); foreach (Hero one in Global.instance.m_Hero_All) { RoleControl ctrl = one.GetComponent <RoleControl>(); m_AllCtrls.Add(ctrl); } }
public static List <RoleControl> GetControlsForRole(int roleID) { List <RoleControl> roleControls = new List <RoleControl>(); SqlConnection conn = GetInventoryDbConnection(); try { conn.Open(); SqlCommand sqlCmd = new SqlCommand("proc_GetControlsForRole", conn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.AddWithValue("@RoleID", roleID); SqlDataReader reader = sqlCmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var roleControl = new RoleControl() { RoleID = reader.GetInt32(reader.GetOrdinal("RoleID")), FormName = reader.GetString(reader.GetOrdinal("Form")), Name = reader.GetString(reader.GetOrdinal("Control")), Visible = reader.GetBoolean(reader.GetOrdinal("Visible")), Disabled = reader.GetBoolean(reader.GetOrdinal("Disabled")), }; roleControls.Add(roleControl); } } reader.Close(); } #region Exceptions catch (DataException ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("DatabaseException"), ex); } catch (SqlException ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("SqlException"), ex); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("Exception"), ex); } finally { conn.Close(); } #endregion return(roleControls); }
public void LoadEmployeePosition(MainWindow window) { this.mainWindow = window; mainWindow.stkPosition.Children.Clear(); int n = positionList.Count; for (int i = 0; i < n; i++) { RoleControl roleControl = new RoleControl(); roleControl.txbId.Text = AddPrefix("CV", positionList[i].IdEmployeePosition); roleControl.txbRoleName.Text = positionList[i].Position; mainWindow.stkPosition.Children.Add(roleControl); } }
public static bool UpdateControl(RoleControl control, int roleID) { var connection = GetInventoryDbConnection(); try { var mySqlCommand = new SqlCommand("proc_UpdateControlForRole", connection) { CommandType = CommandType.StoredProcedure }; mySqlCommand.Parameters.AddWithValue("@RoleID", roleID); mySqlCommand.Parameters.AddWithValue("@Form", control.FormName); mySqlCommand.Parameters.AddWithValue("@Control", control.Name); mySqlCommand.Parameters.AddWithValue("@Visible", control.Visible ? 1 : 0); mySqlCommand.Parameters.AddWithValue("@Disabled", control.Disabled ? 1 : 0); connection.Open(); if (mySqlCommand.ExecuteNonQuery() == 1) { return(true); } } #region Exceptions catch (DataException ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("DatabaseException"), ex); } catch (SqlException ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("SqlException"), ex); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("Exception"), ex); } finally { connection.Close(); } #endregion return(false); }
void InitPermission(RoleControl control) { mainWindow.cbCheckAll.IsEnabled = true; mainWindow.btnUpdatePermission.IsEnabled = true; mainWindow.stkPermission.Children.Clear(); selectedPosition = ConvertToID(control.txbId.Text); List <Permission> permissionList = PermissionDAL.Instance.GetList(); List <PositionDetail> positionDetailList = PositionDetailDAL.Instance.GetListByPosition(selectedPosition); int n = permissionList.Count; for (int i = 0; i < n; i++) { PermissionControl permissionControl = new PermissionControl(); permissionControl.txbId.Text = permissionList[i].IdPermission.ToString(); permissionControl.txbRoleName.Text = permissionList[i].PermissionName; permissionControl.cbIsPermitted.IsChecked = positionDetailList[i].IsPermitted; mainWindow.stkPermission.Children.Add(permissionControl); } }
public void SetRoleControl(RoleControl roleControl) { _roleControl = roleControl; _logger = _roleControl.Logger; }
private void PopupContextMenu(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { if (editing == false) { ContextMenuStrip roleMenu = new ContextMenuStrip(); String controlName; if (sender is ToolStripMenuItem) { var toolStrip = (ToolStripMenuItem)sender; controlName = toolStrip.Name; } else { var c = (Control)sender; controlName = c.Name; } var isUpdate = _editingRoleControls.SingleOrDefault(c => c.FormName == _formName && c.Name == controlName && c.status != "NEW"); if (isUpdate != null) { Console.WriteLine(controlName); roleMenu.Items.Add(controlName); roleMenu.Items.Add("-"); roleMenu.Items.Add(!isUpdate.Disabled ? "Disable" : "Enable", null, new System.EventHandler(enable_click)); roleMenu.Items.Add(isUpdate.Visible ? "Hide" : "Show", null, new System.EventHandler(visible_click)); _currentControl = isUpdate; _currentControl.RoleID = _currentRoleID; _currentControl.status = "UPDATE"; } else { if (_editingRoleControls.Count > 0) { var control = _editingRoleControls.SingleOrDefault(c => c.FormName == _formName && c.Name == controlName && c.status == "NEW"); Console.WriteLine(controlName); roleMenu.Items.Add(controlName); roleMenu.Items.Add("-"); roleMenu.Items.Add("Disable", null, new System.EventHandler(enable_click)); roleMenu.Items.Add("Hide", null, new System.EventHandler(visible_click)); if (control == null) { _currentControl = new RoleControl() { Name = controlName, FormName = _formName, Disabled = false, Active = true, Visible = true, RoleID = _currentRoleID, status = "NEW" }; } else { _currentControl = control; } } else { Console.WriteLine(controlName); roleMenu.Items.Add(controlName); roleMenu.Items.Add("-"); roleMenu.Items.Add("Disable", null, new System.EventHandler(enable_click)); roleMenu.Items.Add("Hide", null, new System.EventHandler(visible_click)); _currentControl = new RoleControl() { Name = controlName, FormName = _formName, Disabled = false, Active = true, Visible = true, RoleID = _currentRoleID, status = "NEW" }; } } if (sender is ToolStripMenuItem) { roleMenu.Show(Cursor.Position); } else { roleMenu.Show((Control)sender, e.Location); } } } }
public static AccessToken Authenticate(int userID, string password) { SqlConnection conn = GetInventoryDbConnection(); AccessToken _token = null; try { conn.Open(); SqlCommand sqlCmd = new SqlCommand("proc_Authenticate", conn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.AddWithValue("@UserID", userID); sqlCmd.Parameters.AddWithValue("@Password", password); SqlDataReader reader = sqlCmd.ExecuteReader(); if (reader.HasRows) { if (reader.Read()) { _token = new AccessToken((int)reader["UserID"]) { Role = new Role((int)reader["RoleID"]) { Name = (String)reader["Title"], Description = (String)reader["Description"] }, FirstName = (String)reader["FirstName"], LastName = (String)reader["LastName"] }; } reader.NextResult(); var controls = new List <RoleControl>(); while (reader.Read()) { var control = new RoleControl() { RoleID = (int)reader["RoleID"], FormName = (String)reader["Form"], Name = (String)reader["Control"], Visible = (Boolean)reader["Visible"], Disabled = (Boolean)reader["Disabled"] }; controls.Add(control); } _token.Role.Controls = controls; return(_token); } reader.Close(); } catch (DataException ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("DatabaseException"), ex); } catch (SqlException ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("SqlException"), ex); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new ApplicationException(Messeges.GetMessage("Exception"), ex); } finally { conn.Close(); } return(_token); }
/// <summary> /// 动态创建控件 /// </summary> private void buildControl() { titlePanel = new Panel(); titlePanel.BackColor = ColorTranslator.FromHtml("#438EB9"); this.Controls.Add(titlePanel); // 注册鼠标事件到窗体 registerMouseEvent(titlePanel); corpName = new Label(); corpName.AutoSize = false; corpName.Text = "上海数码科技"; corpName.TextAlign = ContentAlignment.MiddleCenter; corpName.ForeColor = Color.Black; corpName.BackColor = Color.White; this.Controls.Add(corpName); systemTree = new BaseTreeView(); this.Controls.Add(systemTree); systemTree.BorderStyle = BorderStyle.None; systemTree.ItemHeight = 60; systemTree.Font = new Font("宋体", 10); systemTree.ImageList = initImages(); systemTree.NodeMouseClick += systemTree_NodeMouseClick; systemTree.Invalidate(); bar = new NativeBar(); this.Controls.Add(bar); // setCtrl = new SystemSetting(); this.Controls.Add(setCtrl); setCtrl.Visible = false; setCtrl.buildControl(); logPanel = new LoggerPannel(); this.Controls.Add(logPanel); logPanel.Visible = false; logPanel.buildControl(); roleCtrl = new RoleControl(); grantCtrl = new GrantControl(); this.Controls.Add(roleCtrl); this.Controls.Add(grantCtrl); roleCtrl.Visible = false; grantCtrl.Visible = false; roleCtrl.buildControl(); grantCtrl.buildControl(); orderControl = new OrderControl(); this.Controls.Add(orderControl); orderControl.buildControl(); orderControl.Visible = false; terminalCtrl = new TerminalControl(); this.Controls.Add(terminalCtrl); terminalCtrl.buildControl(); terminalCtrl.Visible = false; }