private void dataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { hostDevelopment hd = e.Row.DataBoundItem as hostDevelopment; if (hd != null) { bs_Development.Remove(hd); sess.Delete(hd); } }
private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { try { DataGridViewRow oDGVR = this.dataGridView1.Rows[e.RowIndex]; hostDevelopment hd = oDGVR.DataBoundItem as hostDevelopment; if (oDGVR.Cells[1].Value == null || oDGVR.Cells[1].Value.ToString() == "") { Debug.Print("Type is Not Letter!!!"); oDGVR.Cells[1].Value = hostConstants.devtypeBugs; } else { if (oDGVR.Cells[1].Value.ToString() != hostConstants.devtypeBugs && oDGVR.Cells[1].Value.ToString() != hostConstants.devtypeFeature && oDGVR.Cells[1].Value.ToString() != hostConstants.devtypeRoadMap) { //force to BUG Debug.Print("Type is not Release ,Bug ,Feature!!! - Setting to BUG"); oDGVR.Cells[1].Value = hostConstants.devtypeBugs; } } if (hd == null) { return; } if (hd.Created == DateTime.MinValue) { hd.Created = DateTime.Now; } e.Cancel = false; } catch (Exception ex) { SetMessage("Failed to validate, caught exception:" + ex.ToString()); e.Cancel = true; } }