private void AsignarEvento() { clsEvento.AsignarRutSinGuion(ref txt_Rut); clsEvento.AsignarRutSinGuion(ref txt_RunPersonal); clsEvento.AsignarNumero(ref txt_ref_cliente); clsEvento.AsignarKeyPress(ref txt_RazonSocial); }
private void AsignarEvento() { SqlCommand cmd = new SqlCommand(); //SqlCommand cmd = new SqlCommand(); DataSet dt; string strname; foreach (Control c in tbl_personal.Controls) { //foreach (Control childc in c.Controls) //{ if (c is TextBox) { strname = ((TextBox)c).Name; cmd.CommandText = "SELECT requerido, validacion " + " FROM glo_configuracioncampo WHERE campo= '" + strname.Replace("txt_", "") + "'"; dt = Conectar.Listar(Clases.clsBD.BD, cmd); if (dt.Tables[0].Rows.Count == 0) { ((TextBox)c).KeyPress += new KeyPressEventHandler(ClaseEvento.Avanzar_KeyPress); } else { if (dt.Tables[0].Rows[0]["validacion"].ToString() == "rut") { Evento.AsignarRutSinGuion(ref txt_rut); } if (dt.Tables[0].Rows[0]["validacion"].ToString() == "numerico") { ((TextBox)c).KeyPress += new KeyPressEventHandler(ClaseEvento.Numero_KeyPress); ((TextBox)c).KeyDown += new KeyEventHandler(ClaseEvento.Numero_KeyDown); } } } if (c is ComboBox) { ((ComboBox)c).KeyPress += new KeyPressEventHandler(ClaseEvento.Avanzar_KeyPress); } if (c is DateTimePicker) { ((DateTimePicker)c).KeyPress += new KeyPressEventHandler(ClaseEvento.Avanzar_KeyPress); } } }