void item_Click(object sender, RoutedEventArgs e) { selected_group = ((Group)((MenuItem)sender).Tag); SelectedGroupLabel.Content = selected_group.ToString(); NameTextBox.Text = ((MenuItem)sender).Header.ToString(); }
public AddClientsToGroup(SqlConnection conn, Group group) { InitializeComponent(); connection = conn; selected_group = group; LoadClients(); FillList(); }
public EditGroupWindow(Group group, SqlConnection conn) { InitializeComponent(); connection = conn; selected_group = group; FillIsntructorComboBox(); FillTimeCombobox(); FillRoomCombobox(); FillData(); }
private bool CompareForAutoComplete(string input, Group group) { if (groups.ToString().ToLower().StartsWith(input.ToLower())) { return true; } else { return false; } }
public static DataSet GroupSanityCheck(Group group, SqlConnection connection) { using (DataSet ds = new DataSet()) { using (SqlCommand command = new SqlCommand("ScheduleSanityCheck", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@excludeId", group.Id); command.Parameters.AddWithValue("@date", group.Date); command.Parameters.AddWithValue("@timeperiod", group.Time); command.Parameters.AddWithValue("@instructorid", group.Instructor.Id); command.Parameters.AddWithValue("@roomid", group.Room.Id); SqlDataAdapter adapter = new SqlDataAdapter(command); adapter.Fill(ds); return ds; } } }
void list_SelectionChanged(object sender, SelectionChangedEventArgs e) // When item is selected displaying details on the right. { if ((sender as ListView).SelectedItem != null)//Selection changed fires twice in WPF, first time when object is deselected, //and second time when it is actually selected; //So we make sure that we catch second event { selected_group = null; GroupNameLabel.Content = "";//Cleaning GroupRoomLabel.Content = "";//Details GroupTimeLabel.Content = "";//Grid GroupDateLabel.Content = "";//Just to make sure GroupInstructorLabel.Content = ""; DescriptionTextBox.Text = ""; ClientList.Items.Clear(); DetailsGrid.Visibility = Visibility.Visible;//Showing it instead of Datagrid DataGrid1.Visibility = Visibility.Hidden;//and hiding datagrid if (((Group)(((Label)((ListView)sender).SelectedItem).Tag)) != null)//Now. If there is an object bound to selected item in listview { //We display it's details; selected_group = ((Group)(((Label)((ListView)sender).SelectedItem).Tag));//Select it explicitly for use in other methods GroupNameLabel.Content = selected_group.Name;//Displaying name GroupRoomLabel.Content = selected_group.Room.ToString();//Room GroupTimeLabel.Content = TimePeriodToString(selected_group.Time);//Timeperiod GroupDateLabel.Content = selected_group.Date.ToString("dd-MM-yyyy");//date GroupInstructorLabel.Content = selected_group.Instructor.ToString();//Instructor DescriptionTextBox.Text = selected_group.Description;//Description foreach (Client item in selected_group.Clients)//And all the clients for this group if there are any { ClientList.Items.Add(item.ToString()); } } (sender as ListView).SelectedItem = null;//and deselecting the item, for it causes some weird behaviour when switching weeks; } }
private void GroupList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (((ListView)sender).SelectedItem != null) { selected_group = ((Group)((ListView)sender).SelectedItem); SelectedGroupLabel.Content = selected_group.ToString(); } }
public static void UpdateGroup(SqlConnection connection, Group group) { using (SqlCommand command = new SqlCommand("UpdateGroup", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@id", group.Id); command.Parameters.AddWithValue("@name", group.Name); command.Parameters.AddWithValue("@description", group.Description); command.Parameters.AddWithValue("@instructor", Convert.ToInt32(group.Instructor.Id)); command.Parameters.AddWithValue("@room", Convert.ToInt32(group.Room.Id)); command.Parameters.AddWithValue("@time", group.Time); command.Parameters.AddWithValue("@date", group.Date); command.ExecuteNonQuery(); } }
public static void DeleteGroup(SqlConnection connection, Group group) { using (SqlCommand command = new SqlCommand("DeleteGroup", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@targetId", group.Id); command.ExecuteNonQuery(); } }
public static void AddClientToGroup(SqlConnection connection, Group group, Client client) { using (SqlCommand command = new SqlCommand("AddClientToGroup", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@groupid", group.Id); command.Parameters.AddWithValue("@clientid", client.Id); command.ExecuteNonQuery(); } }
private bool SanityCheckSearch(Group group, SqlConnection connection) { using (DataSet ds = DataAccess.GroupSanityCheck(group,connection)) { if (ds.Tables[0].Rows.Count != 0) { return false; } else { return true; } } }
private void AddButton_Click(object sender, RoutedEventArgs e) { string name = NameTextbox.Text; string description = DescriptionTextBox.Text; timeperiod time = (timeperiod)TimePeriodCombo.SelectedIndex; DateTime date = datePicker.SelectedDate.GetValueOrDefault(DateTime.Now); Instructor instructor = (((ComboBoxItem)InstructorCombobox.SelectedItem).Tag as Instructor); GymRoom room = (((ComboBoxItem)RoomCombobox.SelectedItem).Tag as GymRoom); Group group = new Group(name, description, time, date, instructor, room); if (SanityCheckSearch(group,connection)) { DataAccess.CreateNewGroup(connection, group); MessageBox.Show("Group Sheduled Succesfully"); ClearInput(1); } else { MessageBox.Show("There is already group scheduled for this date\\time \n for this instructor, and-or this room\n Check your input data"); ClearInput(2); } }
/// <summary> /// Deprecated Method for adding a new object to the Groups EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToGroups(Group group) { base.AddObject("Groups", group); }
/// <summary> /// Create a new Group object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> /// <param name="active">Initial value of the Active property.</param> public static Group CreateGroup(global::System.Int32 id, global::System.String name, global::System.DateTime createDate, global::System.Boolean active) { Group group = new Group(); group.ID = id; group.Name = name; group.CreateDate = createDate; group.Active = active; return group; }
public void InsertEmails(List<Email> emails, string groupName) { Group emailGroup = null; if (!String.IsNullOrEmpty(groupName)) { emailGroup = new Group() { Name = groupName }; _dbContext.SaveChanges(); } foreach(Email email in emails) { email.CreatedDate = DateTime.Now; email.EditedDate = DateTime.Now; //EmailGroup emailGroupJoin = new EmailGroup() { GroupID = emailGroup.ID }; //email.EmailGroups.Add(emailGroupJoin); _dbContext.Emails.AddObject(email); } _dbContext.SaveChanges(); }
/// <summary> /// Create a new Group object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="isEmailReceiver">Initial value of the IsEmailReceiver property.</param> public static Group CreateGroup(global::System.Int32 id, global::System.String name, global::System.Boolean isEmailReceiver) { Group group = new Group(); group.ID = id; group.Name = name; group.IsEmailReceiver = isEmailReceiver; return group; }