private void FormMain_Load(object sender, EventArgs e) { try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<Reception> Receptions = from item in context.Reception select item; IQueryable<Client> Clients = from item in context.Client select item; IQueryable<Dish> Dishes = from item in context.Dish select item; dataGridViewReceptions.DataSource = Receptions.ToList(); dataGridViewReceptions.Columns[6].Visible = false; dataGridViewReceptions.Columns[7].Visible = false; dataGridViewReceptions.Columns[8].Visible = false; dataGridViewClients.DataSource = Clients.ToList(); dataGridViewClients.Columns[0].Visible = false; dataGridViewClients.Columns[6].Visible = false; dataGridViewClients.Columns[7].Visible = false; dataGridViewClients.Columns[8].Visible = false; dataGridViewDish.DataSource = Dishes.OrderBy(dish => dish.DishTypeId).ThenBy(dish => dish.Name).ToList(); dataGridViewDish.Columns[2].Visible = false; dataGridViewDish.Columns[3].Visible = false; dataGridViewDish.Columns[4].Visible = false; dataGridViewDish.Columns[5].Visible = false; } } catch(Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message,"Erreur fatale!",MessageBoxButtons.OK,MessageBoxIcon.Error); } }
private void FormReservationDetails_Load(object sender, EventArgs e) { if((CurrentClient != null) && (CurrentReception != null)) { textBoxDate.Text = CurrentReception.ReceptionDate.ToString("dd MMMM yyyy"); textBoxName.Text = CurrentReception.ReceptionName; try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<GetReservedDish_Result> _reservedDishes = context.GetReservedDish(CurrentReception.ReceptionId, CurrentClient.Id); if(_reservedDishes.Where(dish => dish.DishTypeId == DishTypeStarter).Count() == 1) { _starter_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeStarter).First(); _starter = context.Dish.Where(dish => dish.DishId == _starter_old.DishId).First(); textBoxStarter.Text = _starter.Name; } if(_reservedDishes.Where(dish => dish.DishTypeId == DishTypeMainDish).Count() == 1) { _mainCourse_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeMainDish).First(); _mainCourse = context.Dish.Where(dish => dish.DishId == _mainCourse_old.DishId).First(); textBoxMainCourse.Text = _mainCourse.Name; } if(_reservedDishes.Where(dish => dish.DishTypeId == DishTypeDessert).Count() == 1) { _dessert_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeDessert).First(); _dessert = context.Dish.Where(dish => dish.DishId == _dessert_old.DishId).First(); textBoxDessert.Text = _dessert.Name; } } } catch(Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.Abort; Close(); } } }
private void PopulateStarters() { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { dataGridViewStarters.DataSource = context.GetMenu(currentReception.ReceptionId, DishTypeStarter).ToList(); } foreach(DataGridViewColumn colum in dataGridViewStarters.Columns) { colum.Visible = false; } dataGridViewStarters.Columns[1].Visible = true; }
public TablesMapGenerator(int RecId) { Tables = new List<Table>(); _tablesMaps = null; _recId = RecId; using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { _clients = context.GetReservation(RecId).Where(res => res.IsValid == true).ToList(); _nbSeats = context.Reception.Where(rec => rec.ReceptionId == RecId).First().SeatsPerTable; } }
private void PopulateReceptions() { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<GetReservedReception_Result> Receptions = context.GetReservedReception(CurrentClient.Id); dataGridViewReservations.DataSource = Receptions.ToList(); dataGridViewReservations.Columns[3].Visible = false; dataGridViewReservations.Columns[4].Visible = false; dataGridViewReservations.Columns[5].Visible = false; } }
private void PopulateDishes() { IQueryable<GetUnwishedDish_Result> dishes; using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { dishes = context.GetUnwishedDish(CurrentClient.Id); foreach(GetUnwishedDish_Result dish in dishes) { comboBoxDishes.Items.Add(new DishWishSelection(dish.DishId, dish.DisplayName())); } comboBoxDishes.DisplayMember = "DisplayName"; } }
public void LoadReception(int id) { if(CurrentClient != null) { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<GetReservedReception_Result> recs = context.GetReservedReception(CurrentClient.Id); if(recs.Where(rec => rec.ReceptionId == id).Count() == 1) { CurrentReception = recs.Where(rec => rec.ReceptionId == id).First(); } } } }
private void PopulateClients() { IQueryable<GetUnfeeling_Result> clients; using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { clients = context.GetUnfeeling(CurrentClient.Id); foreach(GetUnfeeling_Result client in clients) { comboBoxClients.Items.Add(new ClientSelection(client.ClientId, client.DisplayName(), client.LastName)); } comboBoxClients.DisplayMember = "DisplayName"; } }
private void PopulateDishWishes() { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<GetWishedDish_Result> DishWishs = context.GetWishedDish(CurrentClient.Id, null); dataGridViewDishWish.DataSource = DishWishs.ToList(); foreach(DataGridViewColumn column in dataGridViewDishWish.Columns) { column.Visible = false; } dataGridViewDishWish.Columns[0].Visible = true; dataGridViewDishWish.Columns[1].Visible = true; dataGridViewDishWish.Columns[2].Visible = true; } }
private void PopulateFeelings() { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<GetFeeling_Result> Feelings = context.GetFeeling(CurrentClient.Id, null); dataGridViewFeeling.DataSource = Feelings.ToList(); foreach(DataGridViewColumn column in dataGridViewFeeling.Columns) { column.Visible = false; } dataGridViewFeeling.Columns[0].Visible = true; dataGridViewFeeling.Columns[1].Visible = true; dataGridViewFeeling.Columns[2].Visible = true; } }
public FormMain() { InitializeComponent(); try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<Client> Clients = from item in context.Client select item; foreach(Client client in Clients) { comboBoxCurrentClient.Items.Add(new ClientSelection(client.ClientId, client.DisplayName(), client.Acronym)); } comboBoxCurrentClient.DisplayMember = "DisplayName"; } } catch(Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonSave_Click(object sender, EventArgs e) { ClientSelection client = (ClientSelection)comboBoxClients.SelectedItem; FeelingType feelingtype = (FeelingType)comboBoxFeeling.SelectedItem; if((client != null) && (feelingtype != null)) { try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { context.NewFeeling(CurrentClient.Id, client.Id, feelingtype.Id, CurrentClient.Acronym); } } catch(Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; } } }
private void FormNewReservation_Load(object sender, EventArgs e) { if(CurrentClient != null) { try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<GetReservableReception_Result> Receptions = context.GetReservableReception(CurrentClient.Id); foreach(GetReservableReception_Result rec in Receptions) { comboBoxReception.Items.Add(new ReceptionSelection(rec.ReceptionId, rec.DisplayName())); } comboBoxReception.DisplayMember = "DisplayName"; } } catch(Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.Abort; Close(); } } }
private void buttonSave_Click(object sender, EventArgs e) { FeelingType feelingtype = (FeelingType)comboBoxFeeling.SelectedItem; if(ClientTo != null && feelingtype != null) { try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { context.UpdateFeeling(CurrentClient.Id, ClientTo.ClientId, feelingtype.Id, ClientTo.ModifiedAt, CurrentClient.Acronym); } } catch(Exception ex) { ModelError modelError = new ModelError(ex); if(modelError.Number == ModelError.DATA_NOT_UP_TO_DATE) { MessageBox.Show(modelError.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadFeeling(ClientTo.ClientId); DialogResult = DialogResult.None; } else { MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public void PopulateList(int recId, int dtyId, ClientSelection client) { IQueryable<GetMenu_Result> dishes; CurrentClient = client; int DishTypeStarter = Int32.Parse(ConfigurationManager.AppSettings["DishTypeStarter"]); int DishTypeMainDish = Int32.Parse(ConfigurationManager.AppSettings["DishTypeMainDish"]); int DishTypeDessert = Int32.Parse(ConfigurationManager.AppSettings["DishTypeDessert"]); using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { dishes = context.GetMenu(recId, dtyId); dataGridViewDish.DataSource = dishes.ToList(); foreach(DataGridViewColumn colum in dataGridViewDish.Columns) { colum.Visible = false; } dataGridViewDish.Columns[1].Visible = true; } if(dtyId == DishTypeStarter) { labelSelection.Text = "Nouvelle entrée :"; } else if(dtyId == DishTypeMainDish) { labelSelection.Text = "Nouveau plat principal :"; } else if(dtyId == DishTypeDessert) { labelSelection.Text = "Nouveau dessert :"; } }
private void PopulateMenu(int IdReception) { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable<GetMenu_Result> Starters = context.GetMenu(IdReception, DishTypeStarter); IQueryable<GetMenu_Result> MainCourse = context.GetMenu(IdReception, DishTypeMainDish); IQueryable<GetMenu_Result> Desserts = context.GetMenu(IdReception, DishTypeDessert); dataGridViewDessert.DataSource = Desserts.ToList(); foreach(DataGridViewColumn colum in dataGridViewDessert.Columns) { colum.Visible = false; } dataGridViewDessert.Columns[1].Visible = true; dataGridViewMainCourse.DataSource = MainCourse.ToList(); foreach(DataGridViewColumn colum in dataGridViewMainCourse.Columns) { colum.Visible = false; } dataGridViewMainCourse.Columns[1].Visible = true; dataGridViewStarter.DataSource = Starters.ToList(); foreach(DataGridViewColumn colum in dataGridViewStarter.Columns) { colum.Visible = false; } dataGridViewStarter.Columns[1].Visible = true; } }
private void ColorizeMenu(DataGridView source) { int FeelingTypeLike = Int32.Parse(ConfigurationManager.AppSettings["FeelingTypeLike"]); int FeelingTypeDislike = Int32.Parse(ConfigurationManager.AppSettings["FeelingTypeDislike"]); GetMenu_Result item; IQueryable<GetWishedDish_Result> liked; IQueryable<GetWishedDish_Result> disliked; Color color; using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { liked = context.GetWishedDish(CurrentClient.Id, FeelingTypeLike); disliked = context.GetWishedDish(CurrentClient.Id, FeelingTypeDislike); foreach(DataGridViewRow row in source.Rows) { item = (GetMenu_Result)row.DataBoundItem; if(liked.Where(mainCourse => mainCourse.DishId == item.DishId).Count() > 0) { color = Color.Green; } else if(disliked.Where(mainCourse => mainCourse.DishId == item.DishId).Count() > 0) { color = Color.Red; } else { color = Color.Black; } row.DefaultCellStyle.ForeColor = color; row.DefaultCellStyle.SelectionBackColor = color; } } }
public void Save(string acronym) { int i = 0; ObjectParameter tableIdParam = new ObjectParameter("TabId", typeof(int)); int tableId; using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { foreach(Table table in Tables) { i++; context.NewTable(_recId, i, acronym, tableIdParam); tableId = Int32.Parse(tableIdParam.Value.ToString()); foreach(GetReservation_Result seated in table.Seateds) { context.NewSit(tableId, seated.ClientId, acronym); } } } }
private void buttonSave_Click(object sender, EventArgs e) { ReceptionSelection selectedRec = (ReceptionSelection)comboBoxReception.SelectedItem; GetMenu_Result selectedMenu; if(selectedRec != null) { try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { context.NewReservation(selectedRec.Id, CurrentClient.Id, CurrentClient.Acronym); if(dataGridViewDessert.SelectedRows.Count == 1) { selectedMenu = (GetMenu_Result)dataGridViewDessert.SelectedRows[0].DataBoundItem; context.NewReservedDish(CurrentClient.Id, selectedMenu.DishId, selectedRec.Id, CurrentClient.Acronym); } if(dataGridViewMainCourse.SelectedRows.Count == 1) { selectedMenu = (GetMenu_Result)dataGridViewMainCourse.SelectedRows[0].DataBoundItem; context.NewReservedDish(CurrentClient.Id, selectedMenu.DishId, selectedRec.Id, CurrentClient.Acronym); } if(dataGridViewStarter.SelectedRows.Count == 1) { selectedMenu = (GetMenu_Result)dataGridViewStarter.SelectedRows[0].DataBoundItem; context.NewReservedDish(CurrentClient.Id, selectedMenu.DishId, selectedRec.Id, CurrentClient.Acronym); } } Close(); } catch(Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; } } }
private void buttonDelete_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Êtes-vous sûr de vouloir supprimer la réservation " + CurrentReception.ReceptionName + "?", "Confirmation de suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if(result == DialogResult.Yes) { try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { context.DeleteReservation(CurrentReception.ReceptionId, CurrentClient.Id, CurrentReception.ModifiedAt); } } catch(Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; } } else { DialogResult = DialogResult.None; } }
private void UpdateDish(GetReservedDish_Result oldDish, Dish newDish) { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { if(oldDish != null) { if((newDish != null) && (oldDish.DishId != newDish.DishId)) { context.DeleteReservedDish(oldDish.ClientId, oldDish.DishId, CurrentReception.ReceptionId, oldDish.ModifiedAt); context.NewReservedDish(CurrentClient.Id, newDish.DishId, CurrentReception.ReceptionId, CurrentClient.Acronym); } } else { if(newDish != null) { context.NewReservedDish(CurrentClient.Id, newDish.DishId, CurrentReception.ReceptionId, CurrentClient.Acronym); } } } }
private void PopulateReservations() { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { dataGridViewReservations.DataSource = context.Reservation.Where(res => res.ReceptionId == currentReception.ReceptionId).ToList(); } foreach(DataGridViewColumn colum in dataGridViewReservations.Columns) { colum.Visible = false; } dataGridViewReservations.Columns[2].Visible = true; dataGridViewReservations.Columns[3].Visible = true; dataGridViewReservations.Columns[4].Visible = true; }
public void LoadDishWish(int dishId) { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { CurrentDish = context.GetWishedDish(CurrentClient.Id, null).Where(dish => dish.DishId == dishId).First(); } }
public void LoadFeeling(int? clientToId) { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { ClientTo = context.GetFeeling(CurrentClient.Id, null).Where(feeling => feeling.ClientId == clientToId).First(); } }
private void buttonDeleteFeeling_Click(object sender, EventArgs e) { if(dataGridViewFeeling.SelectedRows.Count == 1) { GetFeeling_Result selected = (GetFeeling_Result)dataGridViewFeeling.SelectedRows[0].DataBoundItem; DialogResult result = MessageBox.Show("Êtes-vous sûr de vouloir supprimer la ressenti pour le client '" + selected.DisplayName() + "'?", "Confirmation de suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if(result == DialogResult.Yes) { try { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { context.DeleteFeeling(CurrentClient.Id, selected.ClientId, selected.ModifiedAt); } PopulateFeelings(); } catch(Exception ex) { ModelError modelError = new ModelError(ex); if(modelError.Number == ModelError.DATA_NOT_UP_TO_DATE) { MessageBox.Show(modelError.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); PopulateFeelings(); } else { MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private void PopulateFeeling() { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { comboBoxFeeling.DataSource = context.FeelingType.ToList(); } comboBoxFeeling.DisplayMember = "Label"; }
public void SetReception(int id) { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { currentReception = context.Reception.Where(rec => rec.ReceptionId == id).First(); } }
private void buttonStarter_Click(object sender, EventArgs e) { FormSelectDish form = new FormSelectDish(); DialogResult result; try { form.PopulateList(CurrentReception.ReceptionId, DishTypeStarter, CurrentClient); result = form.ShowDialog(); if((result == DialogResult.OK) && (form.SelectedDishId != null)) { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { _starter = context.Dish.Where(dish => dish.DishId == form.SelectedDishId).First(); textBoxStarter.Text = _starter.Name; } } } catch(Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadDisliked() { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { DislikedIds = (from client in context.GetFeeling(ClientId, FeelingTypeDislike) select client.ClientId).ToList(); } }
private void PopulateTablesMap() { using(ProjetSGBDEntities context = new ProjetSGBDEntities()) { tablesMap = context.GetTablesMap(currentReception.ReceptionId, null).ToList(); } ShowTablesMap(); }