Ejemplo n.º 1
0
        protected void AgregarCliente_Click(object sender, EventArgs e)
        {
            if (DropComuna.SelectedValue != "-1" & DropCiudad.SelectedValue != "-1" & DropEstado.SelectedValue != "-1")
            {
                Rut       = txtRut.Text;
                Digito    = PreparaAcceso.Dv(Rut);
                Nombre    = txtNombre.Text;
                Direccion = txtDireccion.Text;
                TelFijo   = txtFijo.Text;
                TelMovil  = txtMovil.Text;
                Correo    = txtCorreo.Text;
                // Fecha = Calendar1.SelectedDate;
                Fecha   = Convert.ToDateTime(txt_fecha.Text);
                Usuario = Session["NomUsuario"].ToString();
                Comuna  = DropComuna.SelectedValue;
                Ciudad  = DropCiudad.SelectedValue;
                Estado  = DropEstado.SelectedValue;

                string[] array = new string[] { Digito, Convert.ToString(Fecha), Usuario };

                if (PreparaAcceso.funsionValFormVacios(array))
                {
                    if (PreparaAcceso.validarEmail(Correo) == true)
                    {
                        PreparaAcceso.AgregaCliente(Convert.ToDecimal(Rut), Digito, Nombre, Direccion, Convert.ToInt32(Comuna), Convert.ToInt32(Ciudad), TelFijo, TelMovil, Correo, Fecha, Convert.ToInt32(Estado), Usuario, CadenaConexion);
                        Response.Write("<script >alert('Cliente ingresado Correctamente');location.href = 'Clientes.aspx';</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<SCRIPT LANGUAGE='javascript'> alert('complete el campo Correo Electronico con un email valido!');</SCRIPT>");
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<SCRIPT LANGUAGE='javascript'> alert('Complete Los Campos Que Estan vacios!');</SCRIPT>");
                }
            }
            else if (DropComuna.SelectedValue == "-1" & DropCiudad.SelectedValue != "-1" & DropEstado.SelectedValue != "-1")
            {
                Response.Write("<script >alert('Verifique Seleccion de Comuna');</script>");
            }
            else if (DropComuna.SelectedValue != "-1" & DropCiudad.SelectedValue == "-1" & DropEstado.SelectedValue != "-1")
            {
                Response.Write("<script >alert('Verifique Seleccion de Ciudad');</script>");
            }
            else if (DropComuna.SelectedValue != "-1" & DropCiudad.SelectedValue != "-1" & DropEstado.SelectedValue == "-1")
            {
                Response.Write("<script >alert('Verifique Seleccion de Estado');</script>");
            }
            else if (DropComuna.SelectedValue == "-1" & DropCiudad.SelectedValue == "-1" & DropEstado.SelectedValue != "-1")
            {
                Response.Write("<script >alert('Verifique Seleccion de Comuna y Ciudad');</script>");
            }
            else if (DropComuna.SelectedValue != "-1" & DropCiudad.SelectedValue == "-1" & DropEstado.SelectedValue == "-1")
            {
                Response.Write("<script >alert('Verifique Seleccion de Ciudad y Estado');</script>");
            }
            else if (DropComuna.SelectedValue == "-1" & DropCiudad.SelectedValue == "-1" & DropEstado.SelectedValue != "-1")
            {
                Response.Write("<script >alert('Verifique Seleccion de Comuna y Estado');</script>");
            }
            else
            {
                Response.Write("<script >alert('Verifique Seleccion de Ciudad, Comuna y Estado ');</script>");
            }
        }