private void Telefono_KeyPress(object sender, KeyPressEventArgs e)
 {
     kp.NoNumeros(sender, e);
     kp.NoSimbolos(sender, e);
     if (Telefono.Text.Length > 8)
     {
         Telefono.Focus();
         errorProvider2.SetError(Telefono, "Ingresar teléfono con 8 cifras");
         return;
     }
     else
     {
         errorProvider2.Clear();
     }
 }
Exemple #2
0
        private bool Validar()
        {
            bool paso = true;

            ErrorProvider.Clear();

            if (Nombres.Text == string.Empty)
            {
                ErrorProvider.SetError(Nombres, "El campo Nombre no puede estar vacio");
                Nombres.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(EstadoCivil.Text))
            {
                ErrorProvider.SetError(EstadoCivil, "El campo Direccion no puede estar vacio");
                EstadoCivil.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(Direccion.Text))
            {
                ErrorProvider.SetError(Direccion, "El campo Direccion no puede estar vacio");
                Direccion.Focus();
                paso = false;
            }


            if (string.IsNullOrWhiteSpace(Telefono.Text))
            {
                ErrorProvider.SetError(Telefono, "El campo Direccion no puede estar vacio");
                Telefono.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(Email.Text))
            {
                ErrorProvider.SetError(Email, "El campo Direccion no puede estar vacio");
                Email.Focus();
                paso = false;
            }

            return(paso);
        }
        private void Continuar_Click(object sender, EventArgs e)
        {
            foreach (Bunifu.Framework.UI.BunifuMetroTextbox item in panel1.Controls)
            {
                if (item.Text == "")
                {
                    errorProvider1.SetError(item, "Falta rellenar este campo");
                    item.Focus();
                    return;
                }
                else
                {
                    errorProvider1.Clear();
                }
            }

            if (!correo())
            {
                errorProvider1.SetError(Correo, "Correo ingresado incorrectamente");
                return;
            }
            else
            {
                errorProvider1.Clear();
            }


            if (!contraseñas())
            {
                errorProvider1.SetError(ConContraseña, "Las contraseñas no coinciden");
                return;
            }
            else
            {
                errorProvider1.Clear();
            }
            if (Telefono.Text.Length > 8)
            {
                Telefono.Focus();
                return;
            }


            SqlConnection cnn = ConexionK.Cnn();

            string cadena = "INSERT INTO  Director VALUES ('" + Usuario.Text + "','" + Nombre.Text + "','" +
                            Correo.Text + "','" + Contraseña.Text + "',1,'" + Telefono.Text + "')";

            try
            {
                SqlCommand cmm = new SqlCommand(cadena, cnn);
                cnn.Open();
                cmm.ExecuteNonQuery();
                cnn.Close();

                ////USUARIO
                conectar = Conexion.Cnn();
                string consulta = "insert into Usuarios values(@usu,@pass,@tipo)";
                cmd = new SqlCommand(consulta, conectar);
                cmd.Parameters.AddWithValue("@usu", Usuario.Text);
                cmd.Parameters.AddWithValue("@pass", Contraseña.Text.Trim());
                cmd.Parameters.AddWithValue("@tipo", 1);
                cmd.ExecuteNonQuery();
                conectar.Close();


                this.Hide();
                pad.Hide();
                F_Splash.MN.padre.Hide();
                Login fh = new Login();
                fh.ShowDialog();
                F_Splash.MN.padre.Close();
            }
            catch
            {
                cnn.Close();
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            if (Empresa.Text == "")
            {
                Empresa.Focus();
                MessageBox.Show("¡Faltan Datos!");
                return;
            }

            if (Dueño.Text == "")
            {
                Dueño.Focus();
                MessageBox.Show("¡Faltan Datos!");
                return;
            }

            if (Telefono.Text == "")
            {
                Telefono.Focus();
                MessageBox.Show("¡Faltan Datos!");
                return;
            }

            if (Direccion.Text == "")
            {
                Direccion.Focus();
                MessageBox.Show("¡Faltan Datos!");
                return;
            }

            if (usuario.Text == "")
            {
                usuario.Focus();
                MessageBox.Show("¡Faltan Datos!");
                return;
            }

            if (key1.Text == "")
            {
                key1.Focus();
                MessageBox.Show("¡Faltan Datos!");
                return;
            }

            if (key2.Text == "")
            {
                key2.Focus();
                MessageBox.Show("¡Faltan Datos!");
                return;
            }

            if (key1.Text != key2.Text)
            {
                MessageBox.Show("¡Las Contraseñas no coinciden!");
                key1.Text = "";
                key2.Text = "";
                key1.Focus();
                return;
            }
            else
            {
                Empresa a = new Empresa();

                a.Nombre    = Empresa.Text;
                a.Dueño     = Dueño.Text;
                a.Telefono  = Telefono.Text;
                a.Direccion = Direccion.Text;

                a.Usuario = usuario.Text;
                a.Clave   = key1.Text;

                a.ListaDivisas = new List <Divisa>();

                Divisa Bs = new Divisa();

                Bs.Nombre      = "Bolívares";
                Bs.Logo        = "Bs";
                Bs.equivalente = 250000;

                a.ListaDivisas.Add(Bs);

                Random ran = new Random();

                byte[] buffer = new byte[14];

                string g = File.ReadAllText("Data/Registro.OKs");

                ListaEmpresas asd = JsonConvert.DeserializeObject <ListaEmpresas>(g);

                bool s = true;

                do
                {
                    s = false;

                    a.id = "";

                    ran.NextBytes(buffer);

                    foreach (char c in buffer)
                    {
                        a.id += c;
                    }

                    foreach (Empresa c in asd.UsuariosTotales)
                    {
                        if (c.id == a.id)
                        {
                            s = true;
                            break;
                        }
                    }
                } while (s);

                foreach (Empresa c in asd.UsuariosTotales)
                {
                    if (c.Usuario == a.Usuario)
                    {
                        MessageBox.Show("¡Este nombre de usuario ya esta en uso!");
                        return;
                    }
                }

                asd.UsuariosTotales.Add(a);

                g = JsonConvert.SerializeObject(asd);
                File.WriteAllText("Data/Registro.OKs", g);

                //transacciones-------------------------------------------
                Transacciones tr = new Transacciones();

                tr.TodasLasCompras = new List <Compra>();
                tr.TodasLasVentas  = new List <Venta>();
                tr.id = a.id;

                g = JsonConvert.SerializeObject(tr);
                File.WriteAllText(string.Format("trans/{0}{1}", a.Usuario, ".tr"), g);

                //Stock--------------------------------------------------

                Stock st = new Stock();

                st.ListaDeArticulos = new List <Articulo>();
                st.id = a.id;

                g = JsonConvert.SerializeObject(st);
                File.WriteAllText(string.Format("stock/{0}{1}", a.Usuario, ".st"), g);

                //estatus----------------------------------------------------

                Estatus es = new Estatus();
                es.id = a.id;

                g = JsonConvert.SerializeObject(es);
                File.WriteAllText(string.Format("estatus/{0}{1}", a.Usuario, ".es"), g);

                Application.Restart();
            }
        }
        private void Control_Leave(object sender, EventArgs e)
        {
            if (sender is RadTextBox)
            {
                objTextbox = (RadTextBox)sender;

                switch (objTextbox.Name)
                {
                //tab 2
                case "Nombre_Fiscal":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    RFC.Focus();
                    break;

                //tab 3
                case "RFC":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Tipo_Inmueble.Focus();
                    break;

                //tab 6
                case "Vialidad":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Codigo_Postal.Focus();
                    break;

                //tab 8
                case "No_Ext":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    No_Int.Focus();
                    break;

                //tab 9
                case "No_Int":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Colonia.Focus();
                    break;

                //tab 10
                case "Colonia":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Entidad_Federativa.Focus();
                    break;

                //tab 13
                case "eMail":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Telefono.Focus();
                    break;

                //tab 16
                case "Cuenta_Banco":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    btnExaminar.Focus();
                    break;
                }
            }
            else if (sender is RadMaskedEditBox)
            {
                objMaskedEditBox = (RadMaskedEditBox)sender;

                switch (objMaskedEditBox.Name)
                {
                //tab 7
                case "Codigo_Postal":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    No_Ext.Focus();
                    break;

                //tab 14
                case "Telefono":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Celular.Focus();
                    break;

                //tab 15
                case "Celular":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Cuenta_Banco.Focus();
                    break;
                }
            }
            else if (sender is RadDropDownList)
            {
                objDropDownList = (RadDropDownList)sender;

                switch (objDropDownList.Name)
                {
                //tab 1
                case "Giro_Comercial":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Nombre_Fiscal.Focus();
                    break;

                //tab 4
                case "Tipo_Inmueble":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Tipo_Vialidad.Focus();
                    break;

                //tab 5
                case "Tipo_Vialidad":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Vialidad.Focus();
                    break;

                //tab 11
                case "Entidad_Federativa":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    Municipio.Focus();
                    break;

                //tab 12
                case "Municipio":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    eMail.Focus();
                    break;
                }
            }
            else if (sender is RadButton)
            {
                objButton = (RadButton)sender;

                switch (objButton.Name)
                {
                //tab 17
                case "btnExaminar":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    btnAceptar.Focus();
                    break;

                //tab 18
                case "btnAceptar":
                    pvAddSupplier.SelectedPage = pvpDatosGenerales;
                    btnCancelar.Focus();
                    break;
                }
            }
        }