Ejemplo n.º 1
0
        private void AsignarEvento()
        {
            SqlCommand cmd = new SqlCommand();

            //	SqlCommand cmd = new SqlCommand();
            DataSet dt;
            string  strname;

            foreach (System.Windows.Forms.Control c in tbl_cliente.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")
                        {
                            ((TextBox)c).KeyPress  += new KeyPressEventHandler(ClaseEvento.Rut_KeyPress);
                            ((TextBox)c).KeyDown   += new KeyEventHandler(ClaseEvento.Rut_KeyDown);
                            ((TextBox)c).Validated += new EventHandler(ClaseEvento.validarut_Validated);
                            ((TextBox)c).Leave     += new EventHandler(ClaseEvento.run_Leave);
                        }
                        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);
                }
            }
            clsEvento.AsignarMailMultiple(ref txt_Email);
            clsEvento.AsignarMailMultiple(ref txt_Emailfacturacion);
            clsEvento.AsignarDireccion(ref txt_direccion);

            //txt_Email.Validated += new EventHandler(ClaseEvento.validaEmail_Validated);
        }
        private void AsignarEvento()
        {
            this.txt_Rut.KeyPress += new KeyPressEventHandler(ClaseEvento.Rut_KeyPress);
            txt_Rut.KeyDown       += new KeyEventHandler(ClaseEvento.Rut_KeyDown);
            txt_Rut.Validated     += new EventHandler(ClaseEvento.validarut_Validated);


            this.txt_N_Cliente_Ref.KeyPress += new KeyPressEventHandler(ClaseEvento.Numero_KeyPress);
            txt_N_Cliente_Ref.KeyDown       += new KeyEventHandler(ClaseEvento.Numero_KeyDown);

            txt_RazonSocial.KeyPress += new KeyPressEventHandler(ClaseEvento.Avanzar_KeyPress);

            cbx_Estado.KeyPress += new KeyPressEventHandler(ClaseEvento.Avanzar_KeyPress);
            clsEvento.AsignarDireccion(ref txt_Direccion);
        }