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 dataGridViewFeeling_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { Color color; foreach (DataGridViewRow row in dataGridViewFeeling.Rows) { GetFeeling_Result feeling = (GetFeeling_Result)row.DataBoundItem; if (feeling.FeelingTypeId == FeelingTypeLike) { color = Color.Green; } else if (feeling.FeelingTypeId == FeelingTypeDislike) { color = Color.Red; } else { color = Color.Black; } row.DefaultCellStyle.ForeColor = color; row.DefaultCellStyle.SelectionBackColor = color; } }
private void buttonEditFeeling_Click(object sender, EventArgs e) { if (dataGridViewFeeling.SelectedRows.Count == 1) { GetFeeling_Result selected = (GetFeeling_Result)dataGridViewFeeling.SelectedRows[0].DataBoundItem; FormEditFeeling form = new FormEditFeeling(); form.CurrentClient = CurrentClient; try { form.LoadFeeling(selected.ClientId); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { PopulateFeelings(); } } catch (Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); if (modelError.Number == ModelError.INVALID_OPERATION) { PopulateFeelings(); } } } }
public void LoadFeeling(int?clientToId) { using (ProjetSGBDEntities context = new ProjetSGBDEntities()) { ClientTo = context.GetFeeling(CurrentClient.Id, null).Where(feeling => feeling.ClientId == clientToId).First(); } }
public FormEditFeeling() { InitializeComponent(); CurrentClient = null; ClientTo = null; }
public static string DisplayName(this GetFeeling_Result client) { return(String.Format("{0} {1}", client.FirstName, client.LastName)); }