Example #1
0
 private void DgvTechnician_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         //6 editar 7 eliminar
         if (DgvTechnician.CurrentCell.ColumnIndex == 6)
         {
             txtId.Enabled     = false;
             IbtnCreate.Text   = "Guardar";
             IbtnNew.Enabled   = true;
             txtId.Text        = DgvTechnician.Rows[e.RowIndex].Cells[0].Value.ToString();
             txtName.Text      = DgvTechnician.Rows[e.RowIndex].Cells[1].Value.ToString();
             txtContact.Text   = DgvTechnician.Rows[e.RowIndex].Cells[2].Value.ToString();
             txtAlias.Text     = DgvTechnician.Rows[e.RowIndex].Cells[3].Value.ToString();
             txtTelephone.Text = DgvTechnician.Rows[e.RowIndex].Cells[4].Value.ToString();
             cboPosition.Text  = DgvTechnician.Rows[e.RowIndex].Cells[5].Value.ToString();
         }
         else if (DgvTechnician.CurrentCell.ColumnIndex == 7)
         {
             if (orderLog.TechnicianOrders(DgvTechnician.Rows[e.RowIndex].Cells[0].Value.ToString()) == 0)
             {
                 DialogResult dr = MessageBox.Show("¿Desea eliminar el técnico?" +
                                                   Environment.NewLine + Environment.NewLine +
                                                   "ID: " + DgvTechnician.Rows[e.RowIndex].Cells[0].Value.ToString() +
                                                   Environment.NewLine +
                                                   "Nombre: " + DgvTechnician.Rows[e.RowIndex].Cells[1].Value.ToString(),
                                                   "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (dr == DialogResult.Yes)
                 {
                     //Eliminamos
                     technicianLog.Delete(DgvTechnician.Rows[e.RowIndex].Cells[0].Value.ToString());
                     //Actualizamos tabla
                     IbtnRefresh_Click(null, e);
                 }
             }
             else
             {
                 MessageBox.Show("El técnico no se puede eliminar porque es utilizado en una " +
                                 "o más órdenes de servicio", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
 }