Add control

  • Thread starter Thread starter Juan Carlos
  • Start date Start date
J

Juan Carlos

Hi

I have this problem, I want to add a control to a Panel
but I can't. I get an object label from an event and I
have two panels. I want to add to panel No. 2 but I can't
and I can remove this object from the panel No. 1. I use
the ControlAdded event to see if it happens but it doesn't
happen. I tryed to create a new object label and add to
the panel No. 2 but If I do this I can't remove the object
from the panel No. 1. and I dont get an error it keeps
working.

this is my code
 
The code:

private void monitor_Finalizar(string idEmpresa, string
idContrato, string idMov, Label etiqueta)
{
Monitor monitor = new Monitor(CadenasSQL.cadenaDSN());
OdbcDataReader dr1 = null;

string paso = ""; //0 --> Termino bien
int resUnix = 0; //1 --> No termino bien -
Reintentar
int stCte = 0; //2 --> No termino bien -
No Reintentar
int stSrv = 0;
char st = ' ';
int intentos = 0;

monitor.CadenaSQL = CadenasSQL.strSQLTerminoNomina
(idEmpresa,idContrato,idMov);
monitor.prepararComandoConsulta();

dr1 = monitor.ejecutarConsulta();

if (dr1.Read())
{
paso = dr1.GetString(3);
resUnix = dr1.GetInt32(4);
stCte = dr1.GetInt32(5);
stSrv = dr1.GetInt32(6);
st = dr1.GetChar(7);
intentos = dr1.GetInt32(8);

if ((paso=="18") && (resUnix==1) &&
(stCte==6) && (stSrv==6) && (st=='P' || st=='A'))
{
MessageBox.Show("Control "
+ etiqueta.Name + " BIEN " + idMov);

panel1.Controls.Add
(etiqueta);
pnlProcesar.Controls.Remove
(etiqueta);
}
else if ((paso != "18") && (intentos <
2) )
IntentosNomina
(idEmpresa,idContrato,idMov,etiqueta,intentos);
else if ((paso != "18") && (intentos ==
2))
{
MessageBox.Show("Control "
+ etiqueta.Name + " MAL " + idMov);
panel1.Controls.Add
(etiqueta);
pnlProcesar.Controls.Remove
(etiqueta);
}

}
dr1.Close();
}
 
Back
Top