Exemple #1
0
        private void btn_Agregar_C_Click(object sender, RoutedEventArgs e)
        {
            Cliente_Negocio clienteN = new Cliente_Negocio();
            bool            resp     = false;

            if (Txt_Rut_Cliente.Text == "" || Txt_Dv_Cliente.Text == "" || Txt_P_Nombre_C.Text == "" || Txt_S_Nombre_C.Text == "" || Txt_P_Apellido_C.Text == "" || Txt_S_Apellido_C.Text == "" ||
                Txt_Direccion_C.Text == "" || Txt_numeracion_C.Text == "" || Txt_Fono_C.Text == "" || Txt_Correo_C.Text == "" ||
                Txt_NombreU_C.Text == "" || Txt_Contrasena_C.Password == "" || Cmb_Tipo_Cliente.Text == "" || Cmb_comuna_C.Text == "")
            {
                if (Txt_Rut_Cliente.Text == "" && Txt_Dv_Cliente.Text == "" && Txt_P_Nombre_C.Text == "" && Txt_S_Nombre_C.Text == "" && Txt_P_Apellido_C.Text == "" &&
                    Txt_S_Apellido_C.Text == "" && Txt_Direccion_C.Text == "" && Txt_numeracion_C.Text == "" && Txt_Fono_C.Text == "" &&
                    Txt_Correo_C.Text == "" && Txt_NombreU_C.Text == "" && Txt_Contrasena_C.Password == "" && Cmb_Tipo_Cliente.Text == "" &&
                    Cmb_comuna_C.Text == "")
                {
                    MessageBox.Show("Debe completar todos los campos");
                }
                else
                {
                    if (Txt_Rut_Cliente.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar Rut del cliente");
                        resp = true;
                    }
                    if (Txt_Dv_Cliente.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar dígito verificador ");
                        resp = true;
                    }
                    if (Txt_P_Nombre_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar primer nombre ");
                        resp = true;
                    }
                    if (Txt_S_Nombre_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar segundo nombre");
                        resp = true;
                    }
                    if (Txt_P_Apellido_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar apellido paterno");
                        resp = true;
                    }
                    if (Txt_S_Apellido_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar apellido materno ");
                        resp = true;
                    }
                    if (Txt_Direccion_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar dirección");
                        resp = true;
                    }
                    if (Txt_numeracion_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar numeración del domicilio ");
                        resp = true;
                    }
                    if (Txt_Fono_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar número de telefono");
                        resp = true;
                    }
                    if (Txt_Correo_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar correo");
                        resp = true;
                    }
                    if (Txt_NombreU_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar nombre de usuario");
                        resp = true;
                    }
                    if (Txt_Contrasena_C.Password == "" && !resp)
                    {
                        MessageBox.Show("Debe ingresar una contraseña");
                        resp = true;
                    }
                    if (Cmb_Tipo_Cliente.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe elecionar tipo de cliente ");
                        resp = true;
                    }
                    if (Cmb_comuna_C.Text == "" && !resp)
                    {
                        MessageBox.Show("Debe seleccionar comuna ");
                        resp = true;
                    }
                }
            }
            else
            {
                bool resultado = false;
                try
                {
                    var fiado1 = "0";
                    if (chk_Fiado.IsChecked == true)
                    {
                        fiado1 = "1";
                        chk_Fiado.IsChecked = true;
                    }
                    else
                    {
                        fiado1 = "0";
                        chk_Fiado.IsChecked = false;
                    }
                    resultado = clienteN.CrearCliente(Txt_Rut_Cliente.Text, Txt_Dv_Cliente.Text, Txt_P_Nombre_C.Text, Txt_S_Nombre_C.Text, Txt_P_Apellido_C.Text, Txt_S_Apellido_C.Text,
                                                      Txt_Direccion_C.Text, Txt_numeracion_C.Text, Txt_Depto_C.Text,
                                                      Txt_Fono_C.Text, Txt_Correo_C.Text, fiado1, Txt_NombreU_C.Text, Txt_Contrasena_C.Password,
                                                      Cmb_Tipo_Cliente.SelectedValue.ToString(), Cmb_comuna_C.SelectedValue.ToString(), cmb_id_taller_C.SelectedValue.ToString());
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }