/// <summary> /// A switch based on the Page Enum returns the selected Form /// </summary> /// <param name="page"></param> /// <seealso cref="Page"/> /// <returns>The chosen Form</returns> private static Form GetForm(FORMS.FormMain.Page page) { switch (page) { case FormMain.Page.Chat: ChatAvailable(); return(new FORMS.COMPONENTS.MAINPANEL.Chat(_client.Groups[_listBoxGroups.SelectedIndex].Chats[0], _client)); case FORMS.FormMain.Page.Profile: _listBoxGroups.SelectedIndex = -1; _openGroup = new GROUP.Data(); return(new FORMS.COMPONENTS.MAINPANEL.ProfileShow(_selectedUser, _client)); case FORMS.FormMain.Page.ProfileEdit: return(new FORMS.COMPONENTS.MAINPANEL.ProfileEdit(_selectedUser)); case FORMS.FormMain.Page.ProfileCreate: return(new FORMS.COMPONENTS.MAINPANEL.ProfileCreate()); case FORMS.FormMain.Page.GroupSelector: return(new FORMS.COMPONENTS.MAINPANEL.GroupSelector(_client)); default: return(new FORMS.COMPONENTS.MAINPANEL.ProfileShow(_selectedUser, _client)); } }
/// <summary> /// Changes the current pages that should be put in de Panels /// </summary> /// <param name="page"></param> /// <seealso cref="Page"/> public static void ChangePanels(FORMS.FormMain.Page page, GROUP.Data selectedGroup) { if (selectedGroup.GroupId != _openGroup.GroupId) { ChangePanels(page); _openGroup = selectedGroup; } }
/// <summary> /// Returns a SmallSelector Form for the given group /// </summary> /// <param name="group"></param> /// <returns></returns> public static Form ShowSmallSelector(USER.Data client, GROUP.Data group) { return(new COMPONENTS.SmallSelector(group, client) { TopLevel = false, AutoScroll = false, // UI This could be changed Visible = true }); }
/// <summary> /// Returns Group class with all the information from the database. /// </summary> static public GROUP.Data GetGroupInfo(int groupId) { //Define output GROUP.Data output = new GROUP.Data(); //use try so the code doesn`t crash try { if (_connection.State != System.Data.ConnectionState.Open) { _connection.Open(); } // the incomplete query string query = "SELECT * FROM `group` WHERE `GroupID` = @id"; // DEFINE the paramaters MySqlParameter param1 = new MySqlParameter(); param1.ParameterName = "@id"; param1.Value = groupId; // build the command MySqlCommand command = new MySqlCommand(query, _connection); // add the parameters to the command command.Parameters.Add(param1); // use the command using (MySqlDataReader reader = command.ExecuteReader()) { // if the query finds a result if (reader.HasRows) { // read through the result while (reader.Read()) { //Retrieve information from the database and put it into a class. output = new GROUP.Data( Convert.ToInt32(reader["GroupID"]), Convert.ToString(reader["GroupName"]), Convert.ToString(reader["GroupDescription"]) ); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } _connection.Close(); return(output); }
private static void ChatAvailable() { int selectedGroupIndex = _listBoxGroups.SelectedIndex; GROUP.Data group = (GROUP.Data)_listBoxGroups.SelectedItem; if (_client.Groups[selectedGroupIndex].Chats.Count == 0) { DATABASE.DbConnect.AddChat(group.GroupId, "General", "The general chat"); } foreach (GROUP.Data item in _client.Groups) { item.FillChats(); } }
/// <summary> /// Initializes the form with the given values /// </summary> /// <param name="name">Name of the group</param> /// <param name="description">Description of the group</param> public SmallSelector(GROUP.Data group, USER.Data client) { InitializeComponent(); _myGroup = group; _client = client; this.lbl_Name.Text = _myGroup.Name; this.lbl_Description.Text = _myGroup.Description; foreach (var item in client.Groups) { if (item.GroupId == group.GroupId) { _usable = false; } } }
public static void JoinGroup(USER.Data client, GROUP.Data myGroup) { //use try so the code doesn`t crash try { if (_connection.State != System.Data.ConnectionState.Open) { _connection.Open(); } // the incomplete query string query = "INSERT INTO `group_members` (`GroupID`, `UserID`)" + "VALUES(@GroupId, @ClientId)"; // DEFINE the paramaters MySqlParameter param1 = new MySqlParameter(); param1.ParameterName = "@ClientId"; param1.Value = client.UserId; MySqlParameter param2 = new MySqlParameter(); param2.ParameterName = "@GroupId"; param2.Value = myGroup.GroupId; // build the command MySqlCommand command = new MySqlCommand(query, _connection); // add the parameters to the command command.Parameters.Add(param1); command.Parameters.Add(param2); // use the command ExecuteInsert(command); } catch (Exception ex) { Console.WriteLine(ex.Message); } _connection.Close(); }
public static void JoinGroup(USER.Data client, GROUP.Data myGroup) { DATABASE.DbConnect.JoinGroup(client, myGroup); }
public ListChannelsSidePanel(GROUP.Data group) { _group = group; InitializeComponent(); }