private void buttonDeleteDishWish_Click(object sender, EventArgs e)
 {
     if (dataGridViewDishWish.SelectedRows.Count == 1)
     {
         GetWishedDish_Result selected = (GetWishedDish_Result)dataGridViewDishWish.SelectedRows[0].DataBoundItem;
         DialogResult         result   = MessageBox.Show("Êtes-vous sûr de vouloir supprimer la ressenti pour le plat '" + selected.DisplayName() + "'?", "Confirmation de suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
         if (result == DialogResult.Yes)
         {
             try {
                 using (ProjetSGBDEntities context = new ProjetSGBDEntities()) {
                     context.DeleteDishWish(CurrentClient.Id, selected.DishId, selected.ModifiedAt);
                 }
                 PopulateDishWishes();
             } 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);
                     PopulateDishWishes();
                 }
                 else
                 {
                     MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
 }
        private void dataGridViewDishWish_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            Color color;

            foreach (DataGridViewRow row in dataGridViewDishWish.Rows)
            {
                GetWishedDish_Result dishWish = (GetWishedDish_Result)row.DataBoundItem;
                if (dishWish.FeelingTypeId == FeelingTypeLike)
                {
                    color = Color.Green;
                }
                else if (dishWish.FeelingTypeId == FeelingTypeDislike)
                {
                    color = Color.Red;
                }
                else
                {
                    color = Color.Black;
                }
                row.DefaultCellStyle.ForeColor          = color;
                row.DefaultCellStyle.SelectionBackColor = color;
            }
        }
 private void buttonEditDishWish_Click(object sender, EventArgs e)
 {
     if (dataGridViewDishWish.SelectedRows.Count == 1)
     {
         GetWishedDish_Result selected = (GetWishedDish_Result)dataGridViewDishWish.SelectedRows[0].DataBoundItem;
         FormEditDishWish     form     = new FormEditDishWish();
         form.CurrentClient = CurrentClient;
         try {
             form.LoadDishWish(selected.DishId);
             DialogResult result = form.ShowDialog();
             if (result == DialogResult.OK)
             {
                 PopulateDishWishes();
             }
         } catch (Exception ex) {
             ModelError modelError = new ModelError(ex);
             MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             if (modelError.Number == ModelError.INVALID_OPERATION)
             {
                 PopulateDishWishes();
             }
         }
     }
 }
Beispiel #4
0
 public static string DisplayName(this GetWishedDish_Result dishWish)
 {
     return(String.Format("{0} ({1})", dishWish.DishName, dishWish.DishType));
 }
 public void LoadDishWish(int dishId)
 {
     using (ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         CurrentDish = context.GetWishedDish(CurrentClient.Id, null).Where(dish => dish.DishId == dishId).First();
     }
 }
 public FormEditDishWish()
 {
     InitializeComponent();
     CurrentClient = null;
     CurrentDish   = null;
 }