private void deleteBtn_Click(object sender, EventArgs e) { ConfirmAction confirm = new ConfirmAction(); DialogResult dr = confirm.ShowDialog(); if (dr == DialogResult.OK) { dao.Delete(idInput.Text, table); MessageBox.Show("Elemento eliminado!"); //Close edit form this.Close(); } }
//------------------------------------------------------------Delete or Edit Action private void employeeDV_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) { return; } var dto = (EmployeeDTO)employeeDV.Rows[e.RowIndex].DataBoundItem; if (dto == null) { return; } ChooseAction3 chooseAction = new ChooseAction3(); DialogResult dr = chooseAction.ShowDialog(); if (dr == DialogResult.OK) //Wants to edit { FillEmployeeForm(dto); createUserBtn.Text = EDIT_EMPLOYEE_PARAM; } else if (dr == DialogResult.Cancel) //Wants to delete { ConfirmAction confirmation = new ConfirmAction(); //Confirmar que quiere eliminar DialogResult result = confirmation.ShowDialog(); //Si, Elimino el record if (result == DialogResult.OK) { dao.DELETE(dto.EmployeeId); MessageBox.Show("Elemento eliminado!"); FillDataView(); } else { MessageBox.Show("Problemas borrando..."); } }//Obtener usuario del empleado... else if (dr == DialogResult.Abort) // Wants to get employee user credentials { MessageBox.Show(dao.GetEmployeeUserCredentials(dto.EmployeeId, dto.IdentificationCard)); } }
//-------------------------------------------------------------------------------------Edit or Delete //-------------------------------------------------------------------------------------Choose action over record private void CustomerDV_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) { return; } var dto = (CustomerDTO)CustomerDV.Rows[e.RowIndex].DataBoundItem; if (dto == null) { return; } ChooseAction2 chooseAction = new ChooseAction2(); DialogResult dr = chooseAction.ShowDialog(); if (dr == DialogResult.OK) //Wants to edit { FillCustomerForm(dto); validateCustomerBtn.Text = editCustomerParam; } else if (dr == DialogResult.Cancel) //Wants to delete { ConfirmAction confirmation = new ConfirmAction(); //Confirmar que quiere eliminar DialogResult result = confirmation.ShowDialog(); //Si, Elimino el record if (result == DialogResult.OK) { dao.DELETE(dto.Id); MessageBox.Show("Elemento eliminado!"); ReopenForm(); } else { MessageBox.Show("Problemas borrando..."); } } }
//---------------------------------------------------------------------------------Search action //------------------------------------------------------------------------------Edit or Delete Car events private void carDV_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) { return; } var dto = (CarDTO)carDV.Rows[e.RowIndex].DataBoundItem; if (dto == null) { return; } //new GeneralCrud(dto.CarTypeId, dto.CarTypeDescription, dto.CarTypeStatus, "type"); ChooseAction2 confirmAction = new ChooseAction2(); DialogResult dr = confirmAction.ShowDialog(); if (dr == DialogResult.OK) { //Prepare the form to edit record carId = dto.Id; EditMode(dto); } else if (dr == DialogResult.Cancel) { ConfirmAction confirm = new ConfirmAction(); DialogResult result = confirm.ShowDialog(); if (result == DialogResult.OK) { ///Delete the record carDao.DELETE(dto.Id); MessageBox.Show("Elemento borrado!"); ResetCarForm(); } } }
private void inspectionsDV_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { //Abrir form de renta. //Si se renta el vehiculo, desaparece de las inspecciones... //Refresh data table //Dialog rent(ABORT), edit(OK) or delete(CANCEL) inspection if (e.RowIndex < 0) { return; } var dto = (InspectionDTO)inspectionsDV.Rows[e.RowIndex].DataBoundItem; if (dto == null) { return; } //new GeneralCrud(dto.CarTypeId, dto.CarTypeDescription, dto.CarTypeStatus, "type"); // ChooseAction3 confirmAction = new ChooseAction3("Rentar", "Editar", "Eliminar"); DialogResult dr = confirmAction.ShowDialog(); if (dr == DialogResult.OK) //Edit record { //Prepare the form to edit record FillForm(dto); } else if (dr == DialogResult.Abort) //Display Rent form... { RentForm rentForm = new RentForm(dto); DialogResult rentResult = rentForm.ShowDialog(); if (rentResult == DialogResult.OK || dr == DialogResult.Cancel) { //Here do refresh to the table... rentForm.Close(); inspectionsDV.DataSource = dao.GETALL(); } } else if (dr == DialogResult.Cancel) //Delete record { ConfirmAction confirm = new ConfirmAction(); DialogResult result = confirm.ShowDialog(); if (result == DialogResult.OK) { ///Delete the record dao.DELETE(dto.Id); MessageBox.Show("Elemento borrado!"); RefreshForm(); } } }