private void btnDelete_Click(object sender, EventArgs e) { AirlinesManager ds = new AirlinesManager(); AirlinesManagerTableAdapters.CustomerTableAdapter cTable = new AirlinesManagerTableAdapters.CustomerTableAdapter(); cTable.Fill(ds.Customer); int selectedID = Convert.ToInt32(cmbCustomer.SelectedValue); DataRow[] dr = ds.Customer.Select("CustomerID=" + selectedID); dr[0].Delete(); cTable.Update(ds.Customer); MessageBox.Show("Information Deleted", "Confirmed", MessageBoxButtons.OK, MessageBoxIcon.Information); cTable.Fill(ds.Customer); cmbCustomer.DataSource = ds.Customer; dgvCustomers.DataSource = ds.Customer; }
private void btnAdd_Click(object sender, EventArgs e) { try { if ((txtName.Text == "") || (txtAddress.Text == "") || (txtPhone.Text == "") || (txtEmail.Text == "")) { MessageBox.Show("No TextBox can be empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { AirlinesManager ds = new AirlinesManager(); AirlinesManagerTableAdapters.CustomerTableAdapter cTable = new AirlinesManagerTableAdapters.CustomerTableAdapter(); AirlinesManager.CustomerRow cRow = ds.Customer.NewCustomerRow(); cRow.Name = txtName.Text; cRow.Address = txtAddress.Text; cRow.Phone = txtPhone.Text; cRow.Email = txtEmail.Text; bool phone = CheckNumber(txtPhone.Text); if (phone == false) { MessageBox.Show("Please enter valid phone number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } int status = ValidateEmailId(txtEmail.Text); if (status == 0) { MessageBox.Show("Please enter valid email-id", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (status == 1 && phone == true) { ds.Customer.Rows.Add(cRow); cTable.Update(ds.Customer); cTable.Fill(ds.Customer); cmbCustomer.DataSource = ds.Customer; dgvCustomers.DataSource = ds.Customer; } } } catch (Exception ex) { handleException(ex); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { AirlinesManager ds = new AirlinesManager(); AirlinesManagerTableAdapters.CustomerTableAdapter cTable = new AirlinesManagerTableAdapters.CustomerTableAdapter(); cTable.Fill(ds.Customer); bool phone = CheckNumber(txtPhone.Text); if (phone == false) { MessageBox.Show("Please enter valid phone number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } int status = ValidateEmailId(txtEmail.Text); if (status == 0) { MessageBox.Show("Please enter valid email-id", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (status == 1 && phone == true) { int selectedID = Convert.ToInt32(cmbCustomer.SelectedValue); DataRow[] dr = ds.Customer.Select("CustomerID=" + selectedID); dr[0]["Name"] = txtName.Text; dr[0]["Address"] = txtAddress.Text; dr[0]["Phone"] = txtPhone.Text; dr[0]["Email"] = txtEmail.Text; cTable.Update(ds.Customer); MessageBox.Show("Information Updated", "Confirmed", MessageBoxButtons.OK, MessageBoxIcon.Information); cTable.Fill(ds.Customer); cmbCustomer.DataSource = ds.Customer; dgvCustomers.DataSource = ds.Customer; } } catch (Exception ex) { handleException(ex); } }