private void dataGridSoggiorni_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if ((dataGridSoggiorni.Items.Count > 0) && (dataGridSoggiorni.SelectedItems.Count > 0)) { msw = new ModificaSoggiornoWindow(((Soggiorno)dataGridSoggiorni.SelectedItems[0]).Id); msw.ShowDialog(); if (msw.DialogResult.HasValue && msw.DialogResult.Value) { soggiorniResult.Clear(); //aggiornamento dati avviene dentro la finestra msw hasDoneModification = true; } } }
private void dataGridSoggiorni_MouseDoubleClick(object sender, MouseButtonEventArgs e) { //se ci sono risultati ed almeno uno è selezionato, mostro i dettagli del servizio if ((dataGridSoggiorni.Items.Count > 0) && (dataGridSoggiorni.SelectedItems.Count > 0)) { msw = new ModificaSoggiornoWindow(((Soggiorno)dataGridSoggiorni.SelectedItems[0]).Id); msw.ShowDialog(); if (msw.DialogResult.HasValue && msw.DialogResult.Value) { soggiorniNonCheckedIn.Clear(); } } }
private void dataGridTableau_CellDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { int maxCol = dataGridTableau.ColumnCount; int maxRow = dataGridTableau.RowCount; //MessageBox.Show(dataGridTableau[5, 50].Value.ToString()); if (e.RowIndex < 0 || e.ColumnIndex <= 0 || e.RowIndex >=maxRow || e.ColumnIndex >= maxCol) return; if (dataGridTableau[e.ColumnIndex, e.RowIndex].InheritedStyle.BackColor != System.Drawing.Color.LightGray && dataGridTableau[e.ColumnIndex, e.RowIndex].InheritedStyle.BackColor != System.Drawing.Color.White) {//modifica soggiorno var date = colToDate(e.ColumnIndex); //seleziona soggiorno cliccato var sog = (from s in soggiorni where (s.Camera.Numero == getCameraNumero(e.RowIndex)) && (date >= s.Arrivo && date < s.Partenza) select s).First(); msw = new ModificaSoggiornoWindow(sog.Id); msw.ShowDialog(); if (msw.DialogResult.HasValue && msw.DialogResult.Value) { if (msw.soggiorno == null) cancellaSoggiornoFromGrid(sog); else modificaSoggiornoInGrid(sog, msw.soggiorno); soggiorni = dag.cercaSoggiorniTableau(firstDay, lastDay); } } else {//nuovo soggiorno var s = new Soggiorno(); s.Arrivo = colToDate(e.ColumnIndex); s.Partenza = s.Arrivo.AddDays(1); s.Camera = new Camera { Numero = getCameraNumero(e.RowIndex) }; asw = new AddSoggiornoWindow(s); asw.ShowDialog(); if (asw.DialogResult.HasValue && asw.DialogResult.Value) { dag.inserisciSoggiorno(asw.nuovoSoggiorno, asw.isNuovoCliente); insertSoggiornoInGrid(asw.nuovoSoggiorno); soggiorni = dag.cercaSoggiorniTableau(firstDay, lastDay); } } }