private void dataGridView2_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { FormProvider.CurrentRowIndex = e.RowIndex; FormProvider.CurrentColIndex = e.ColumnIndex; switch (e.ColumnIndex) { case 1: if ((bool)dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) { if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete this entry?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { daysTableAdapter.Delete((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); } else { dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 1; dataGridView2.RefreshEdit(); } } break; case 2: if ((bool)dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue) { DayItem Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.Lunch = false; Item.LunchPrice = Decimal.Zero; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); } else { DayItem Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.Lunch = true; Item.LunchPrice = Item.GetLunchPrice(); Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); } break; } ReCountTotals(); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { FormProvider.CurrentRowIndex = e.RowIndex; FormProvider.CurrentColIndex = e.ColumnIndex; dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true; switch (e.ColumnIndex) { case 3: contextMenuStrip1.Tag = e.ColumnIndex; contextMenuStrip1.Show(MousePosition.X, MousePosition.Y); break; case 6: if (ProfileProvider.GetCategory((int)dataGridView2.Rows[e.RowIndex].Cells["profileIdDataGridViewTextBoxColumn1"].Value) == 1) { contextMenuStrip1.Tag = e.ColumnIndex; contextMenuStrip1.Show(MousePosition.X, MousePosition.Y); } break; case 8: if (ProfileProvider.GetCategory((int)dataGridView2.Rows[e.RowIndex].Cells["profileIdDataGridViewTextBoxColumn1"].Value) == 1) { contextMenuStrip1.Tag = e.ColumnIndex; contextMenuStrip1.Show(MousePosition.X, MousePosition.Y); } break; } } }
private void permaToolStripMenuItem_Click(object sender, EventArgs e) { switch ((int)contextMenuStrip1.Tag) { case 3: servicesTableAdapter.Fill(tDayDataSet.Services); DataRow Row = tDayDataSet.Services.FindByServiceId(1); Row["ServiceFee"] = dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells[3].Value.ToString(); servicesTableAdapter.Update(tDayDataSet); foreach (DataRow Dat in tDayDataSet.Days) { if ((bool)Dat["Lunch"] && (int)Dat["Category"]==1) { DayItem Item = new DayItem((int)Dat["DayId"],CurrentDay.Date); Item.LunchPrice = (decimal)dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells[3].Value; Item.Update(); } } break; case 6: servicesTableAdapter.Fill(tDayDataSet.Services); Row = tDayDataSet.Services.FindByServiceId(3); Row["ServiceFee"] = dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells[6].Value.ToString(); servicesTableAdapter.Update(tDayDataSet); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); foreach (DataRow Dat in tDayDataSet.Days) { if (ProfileProvider.GetCategory((int)Dat["ProfileId"]) == 1) { DayItem Item = new DayItem((int)Dat["DayId"], CurrentDay.Date); Item.ProgramPrice = (decimal)dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells[6].Value; Item.Update(); } } break; case 8: servicesTableAdapter.Fill(tDayDataSet.Services); Row = tDayDataSet.Services.FindByServiceId(2); Row["ServiceFee"] = dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells[8].Value.ToString(); servicesTableAdapter.Update(tDayDataSet); foreach (DataRow Dat in tDayDataSet.Days) { if (ProfileProvider.GetCategory((int)Dat["ProfileId"]) == 1 && Double.Parse(Dat["RoundTripPrice"].ToString())>0) { DayItem Item = new DayItem((int)Dat["DayId"], CurrentDay.Date); Item.RoundTripPrice = (decimal)dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells[8].Value; Item.Update(); } } break; case -3: servicesTableAdapter.Fill(tDayDataSet.Services); Row = tDayDataSet.Services.FindByServiceId(4); Row["ServiceFee"] = dataGridView8.Rows[dataGridView8.SelectedCells[0].RowIndex].Cells[3].Value.ToString(); servicesTableAdapter.Update(tDayDataSet); foreach (DataRow Dat in tDayDataSet.Days) { if ((bool)Dat["Lunch"] && (int)Dat["Category"]!=1) { DayItem Item = new DayItem((int)Dat["DayId"],CurrentDay.Date); Item.LunchPrice = (decimal)dataGridView8.Rows[dataGridView8.SelectedCells[0].RowIndex].Cells[3].Value; Item.Update(); } } break; } daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); }
private void dataGridView2_CellEndEdit(object sender, DataGridViewCellEventArgs e) { FormProvider.CurrentRowIndex = e.RowIndex; FormProvider.CurrentColIndex = e.ColumnIndex; switch (e.ColumnIndex) { case 3: DayItem Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.LunchPrice = (decimal)dataGridView2.Rows[e.RowIndex].Cells["lunchPriceDataGridViewTextBoxColumn"].Value; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 4: Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.TakeOutPrice = (decimal)dataGridView2.Rows[e.RowIndex].Cells["takeOutPriceDataGridViewTextBoxColumn"].Value; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 5: Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.MiscellaneousPrice = (decimal)dataGridView2.Rows[e.RowIndex].Cells["miscellaneousPriceDataGridViewTextBoxColumn"].Value; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 6: Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.ProgramPrice = (decimal)dataGridView2.Rows[e.RowIndex].Cells["ProgramPrice"].Value; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 7: Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.VanPrice = (decimal)dataGridView2.Rows[e.RowIndex].Cells["vanPriceDataGridViewTextBoxColumn"].Value; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 8: Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.RoundTripPrice = (decimal)dataGridView2.Rows[e.RowIndex].Cells["roundTripPriceDataGridViewTextBoxColumn"].Value; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 9: Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.BookOfTickets = (decimal)dataGridView2.Rows[e.RowIndex].Cells["bookOfTicketsDataGridViewTextBoxColumn"].Value; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 11: Item = new DayItem((int)dataGridView2.Rows[e.RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.Comments = dataGridView2.Rows[e.RowIndex].Cells["commentsDataGridViewTextBoxColumn"].Value.ToString(); Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; } ReCountTotals(); }
private void noChargeToolStripMenuItem_Click(object sender, EventArgs e) { if (contextMenuStrip1.Tag != null) { switch ((int)contextMenuStrip1.Tag) { case 3: DayItem Item = new DayItem((int)dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.LunchPrice = 0; Item.Lunch = false; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 6: Item = new DayItem((int)dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.ProgramPrice = 0; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case 8: Item = new DayItem((int)dataGridView2.Rows[dataGridView2.SelectedCells[0].RowIndex].Cells["dayIdDataGridViewTextBoxColumn"].Value, CurrentDay.Date); Item.RoundTripPrice = 0; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; case -3: Item = new DayItem((int)dataGridView8.Rows[dataGridView8.SelectedCells[0].RowIndex].Cells["dataGridViewTextBoxColumn12"].Value, CurrentDay.Date); Item.LunchPrice = 0; Item.Lunch = false; Item.Update(); daysTableAdapter.Fill(tDayDataSet.Days, CurrentDay.Date); break; } } }