private void btnAddPlots_Click(object sender, EventArgs e) { if (dgUnscheduledPlots.SelectedRows.Count == 0) { MessageBox.Show("You have not selected any Plots", "Info", MessageBoxButtons.OK); } else { foreach (DataGridViewRow r in dgUnscheduledPlots.SelectedRows) { Plot newPlot = new Plot((int)r.Cells[0].Value); JobPlot newJPlot = new JobPlot(0, newPlot.ID, int.Parse(lblJobIdValue.Text), newPlot.PlotType, 0, 0); newJPlot.Save(); } PopulatePlots(); } }
private void btnRemovePlot_Click(object sender, EventArgs e) { if (dgJobPlots.SelectedRows.Count == 0) { MessageBox.Show("You must select a Plot to remove!", "Warning!", MessageBoxButtons.OK); } else { int plotId = dgJobPlots.SelectedRows[0].Index;//.DataGridView.Columns["PlotId"].; DataGridViewRow dgr = dgJobPlots.Rows[plotId]; int jpId = (((JobPlot)dgr.DataBoundItem)).JobPlotId; JobPlot jpToDelete = new JobPlot(jpId); if (jpToDelete.Delete()) { PopulateJobPlots(); } } }
public List <JobPlot> GetAllJobPlotsForJob(int jobId) { List <JobPlot> lstJobPlots = new List <JobPlot>(); SqlCommand spJobPlotsByJob = new SqlCommand("GetJobPlotsByJob", conn); spJobPlotsByJob.CommandType = System.Data.CommandType.StoredProcedure; spJobPlotsByJob.Parameters.Add( new SqlParameter("@JobID", jobId)); try { conn.Open(); SqlDataAdapter sDa = new SqlDataAdapter(spJobPlotsByJob); DataTable dtJobPlots = new DataTable(); sDa.Fill(dtJobPlots); foreach (DataRow r in dtJobPlots.Rows) { //DateTime pDate; //DateTime.TryParse(r[6].ToString(), out pDate); //DateTime onDate; //DateTime.TryParse(r[7].ToString(), out onDate); //DateTime cDate; //DateTime.TryParse(r[8].ToString(), out cDate); JobPlot jp = new JobPlot((int)r[0], (int)r[1], (int)r[2], (int)r[3], (int)r[4], (int)r[5]); lstJobPlots.Add(jp); } } catch (Exception ex) { } finally { conn.Close(); } return(lstJobPlots); }