private void grdStudent_RowLeave(object sender, DataGridViewCellEventArgs e) { if (m_editWithGridView) { if (grdStudent.RowCount > 0) { if (grdStudent.CurrentRow != null) { LinqLayer.UpdateStudentName(Convert.ToInt32(grdStudent.Rows[grdStudent.CurrentRow.Index].Cells["Id"].Value), grdStudent.Rows[grdStudent.CurrentRow.Index].Cells["First Name"].Value.ToString(), grdStudent.Rows[grdStudent.CurrentRow.Index].Cells["Last Name"].Value.ToString()); } } } }
private void btnOK_Click(object sender, EventArgs e) { if (txtFirstName.Text.Trim() == "") { MessageBox.Show("You must enter a first name.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtLastName.Text.Trim() == "") { MessageBox.Show("You must enter a last name.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (m_AddEdit == StudentOperation.Add) { LinqLayer.AddStudent(txtFirstName.Text, txtLastName.Text); } else { LinqLayer.UpdateStudentName(m_Id, txtFirstName.Text, txtLastName.Text); } this.Close(); }