Exemplo n.º 1
0
        //------------------------------------------------------------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));
            }
        }
Exemplo n.º 2
0
        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();
                }
            }
        }