//take in form inputs and popluate grid content private void dataGrid_climbs_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { DataTable dt = climbDb.getDt(); DataRow dr = dt.Rows[e.RowIndex]; routeData route = new routeData(); //exception handling try { //collect information from the form route.attempts = Convert.ToInt32(dr["attempts"]); route.color = dr["color"].ToString(); route.date = Convert.ToDateTime(dr["date"].ToString()); route.grade = dr["grade"].ToString(); route.notes = dr["notes"].ToString(); route.routeDesc = dr["routeDesc"].ToString(); //create new climb singleClimb climb = new singleClimb(); //assign form data to climb climb.assignInfo(route); //create new route RouteInfo routeInfo = new RouteInfo(climb); //show route routeInfo.Show(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void assignInfo(routeData data) { details.attempts = data.attempts; details.color = data.color; details.date = data.date; details.grade = data.grade; details.notes = data.notes; details.routeDesc = data.routeDesc; }
public RouteInfo(singleClimb climbInfo) { //set value of form labels InitializeComponent(); routeData route = climbInfo.getDetails(); lbl_attempts.Text = route.attempts.ToString(); lbl_color.Text = route.color.ToString(); lbl_dateClimbed.Text = route.date.ToString(); lbl_description.Text = route.routeDesc.ToString(); lbl_grade.Text = route.grade.ToString(); lbl_notes.Text = route.notes.ToString(); }
//add the climb to the database public void addClimbToDb(Climb climb) { routeData route = climb.getDetails(); //exception handling try { //add row to data table dt.Rows.Add(route.date, route.routeDesc, route.color, route.grade, route.attempts, route.notes); } //exception handling catch (Exception e) { MessageBox.Show(e.ToString()); } }
//add details public void assignInfo(routeData data) { details.Add(data); }
// create new route data for climb public singleClimb() { details = new routeData(); }