Пример #1
0
        public void Insertar(C_Usuario Dato)
        {
            try
            {
                abrirConexion();
                MySqlCommand cmd1 = new MySqlCommand("SELECT COUNT(*) FROM usuarios", conn);
                string       id   = (cmd1.ExecuteScalar()).ToString();
                if (Convert.ToInt32(id) > 0)
                {
                    MySqlCommand idmax = new MySqlCommand("SELECT MAX(usuario_id) FROM usuarios", conn);
                    string       _id   = (idmax.ExecuteScalar()).ToString();
                    MySqlCommand cmd   = new MySqlCommand("INSERT INTO usuarios (usuario_id,nombre,nombre_usuario,clave,rol_id,sucursal_id) VALUES ('" + (Convert.ToInt32(_id) + 1) + "', '" + Dato.Nombre + "', '" + Dato.Usuario + "', '" + Dato.Clave + "', '" + C_Usuario.IdRol + "', '" + C_Usuario.IdSuc + "')", conn);
                    cmd.ExecuteNonQuery();
                }
                else
                {
                    MySqlCommand cmd3 = new MySqlCommand("INSERT INTO usuarios (usuario_id,nombre,nombre_usuario,clave,rol_id,sucursal_id) VALUES ('" + 1 + "', '" + Dato.Nombre + "', '" + Dato.Usuario + "', '" + Dato.Clave + "', '" + C_Usuario.IdRol + "', '" + C_Usuario.IdSuc + "')", conn);
                    cmd3.ExecuteNonQuery();
                }

                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al registrar Ciudad " + ex);
                throw new Exception("Error !!!");
            }
        }
Пример #2
0
        private void MostrarUnUsuario(int dni)
        {
            C_Usuario ObjetoUsuario = _shalong.UsuarioMostrar1(dni);

            Cmb_M_TipoTrabajador.SelectedValue = ObjetoUsuario.CodigoTipoTrabajador;
            Txt_M_Nombre.Text            = ObjetoUsuario.Nombre;
            Txt_M_ApellidoPaterno.Text   = ObjetoUsuario.ApellidoPaterno;
            Txt_M_ApellidoMaterno.Text   = ObjetoUsuario.ApellidoMaterno;
            dtp_M_FechaNacimiento.Value  = ObjetoUsuario.FechaNacimiento;
            Txt_M_LugarNacimiento.Text   = ObjetoUsuario.LugarNacimiento;
            Txt_M_Direccion.Text         = ObjetoUsuario.Direccion;
            Txt_M_Telefono.Text          = ObjetoUsuario.Telefono;
            dtp_M_FechaInicio.Value      = ObjetoUsuario.FechaInicio;
            Txt_M_CorreoElectronico.Text = ObjetoUsuario.Email;
            Txt_M_Password.Text          = ObjetoUsuario.Password;
            ///////////////////////////////////////////////////////
            Cmb_E_TipoTrabajador.SelectedValue = ObjetoUsuario.CodigoTipoTrabajador;
            Txt_E_Nombre.Text            = ObjetoUsuario.Nombre;
            Txt_E_ApellidoPaterno.Text   = ObjetoUsuario.ApellidoPaterno;
            Txt_E_ApellidoMaterno.Text   = ObjetoUsuario.ApellidoMaterno;
            dtp_E_FechaNacimiento.Value  = ObjetoUsuario.FechaNacimiento;
            Txt_E_LugarNacimiento.Text   = ObjetoUsuario.LugarNacimiento;
            Txt_E_Direccion.Text         = ObjetoUsuario.Direccion;
            Txt_E_Telefono.Text          = ObjetoUsuario.Telefono;
            dtp_E_FechaInicio.Value      = ObjetoUsuario.FechaInicio;
            Txt_E_CorreoElectronico.Text = ObjetoUsuario.Email;
            Txt_E_Password.Text          = ObjetoUsuario.Password;
        }
Пример #3
0
        private void EliminarUsuario()
        {
            C_Usuario objetoUsuario = new C_Usuario();

            objetoUsuario.Dni = Int32.Parse(Cmb_E_Dni.SelectedValue.ToString());
            objetoUsuario.CodigoTipoTrabajador = Int32.Parse(Cmb_E_TipoTrabajador.SelectedValue.ToString());
            objetoUsuario.Password             = Txt_E_Password.Text;
            objetoUsuario.Email           = Txt_E_CorreoElectronico.Text;
            objetoUsuario.Nombre          = Txt_E_Nombre.Text;
            objetoUsuario.ApellidoPaterno = Txt_E_ApellidoPaterno.Text;
            objetoUsuario.ApellidoMaterno = Txt_E_ApellidoMaterno.Text;
            objetoUsuario.FechaNacimiento = dtp_E_FechaNacimiento.Value;
            objetoUsuario.LugarNacimiento = Txt_E_LugarNacimiento.Text;
            objetoUsuario.Direccion       = Txt_E_Direccion.Text;
            objetoUsuario.Telefono        = Txt_E_Telefono.Text;
            objetoUsuario.FechaInicio     = dtp_E_FechaInicio.Value;
            if (_shalong.Usuario(3, objetoUsuario))
            {
                MessageBox.Show("Se elimino Correctamente", "Gestion Ventas", MessageBoxButtons.OK);
                CargarComboBox();
                this.Limpiar();
            }
            else
            {
                MessageBox.Show("No se pudo eliminar al usuario", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #4
0
        private void Ingresar()
        {
            if (Txt_Usuario.Text != String.Empty && Txt_Contraseña.Text != String.Empty)
            {
                if (_shalong.Login(Int32.Parse(Txt_Usuario.Text), Txt_Contraseña.Text))
                {
                    MessageBox.Show("Ingreso Correcto", "Gestion Ventas");
                    C_Parametros objetoParametros = new C_Parametros();
                    objetoParametros.DniUsuario = Int32.Parse(Txt_Usuario.Text);
                    objetoParametros.CodigoCaja = 0;
                    objetoParametros.EstadoCaja = false;
                    objetoParametros.ValorDolar = _shalong.TipoCambioDiario();
                    C_Usuario objetoUsuario = _shalong.UsuarioMostrar1(objetoParametros.DniUsuario);

                    /*if (!_shalong.Compañia(objetoUsuario.Compañia))
                     * {
                     *  MessageBox.Show("El tiempo del software ha caducado, contacte a su proveedor","Gestion Ventas",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                     *  return;
                     * }*/
                    this.Hide();
                    C_TipoTrabajador objetoTrabajador = _shalong.TipoTrabajadorMostrar1(objetoUsuario.CodigoTipoTrabajador);
                    objetoParametros.TipoTrabajador = "" + objetoTrabajador.Puesto;
                    Principal objetoPrincipal = new Principal(objetoParametros);
                    objetoPrincipal.Show();
                }
                else
                {
                    MessageBox.Show("Datos Incorrectos", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("No deje los campos vacios", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #5
0
 public void Editar(C_Usuario Dato)
 {
     try
     {
         abrirConexion();
         MySqlCommand cmd = new MySqlCommand("UPDATE usuarios SET nombre = '" + Dato.Nombre + "',nombre_usuario = '" + Dato.Usuario + "',clave = '" + Dato.Clave + "',rol_id = '" + C_Usuario.IdRol + "',sucursal_id = '" + C_Usuario.IdSuc + "'WHERE usuario_id = '" + C_Usuario.IdUsuario + "'", conn);
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al Actualizar" + ex);
         throw new Exception("Error !!!");
     }
 }
Пример #6
0
        private async void txtidentidad_LostFocus(object sender, RoutedEventArgs e)
        {
            if (!txtidentidad.Text.Equals("") && cmbtipoA.SelectedValue != null)
            {
                if (tdAntAc != (int)cmbtipoA.SelectedValue || !docAntAc.Equals(txtidentidad.Text))
                {
                    C_Usuario cli = new C_Usuario();
                    cli.cedula = txtidentidad.Text;
                    if (cli.existeDocIdentidad("acomp", 0, (int)cmbtipoA.SelectedValue) == 1)
                    {
                        await p.ShowMessageAsync("Error", "El número ya está registrado", MessageDialogStyle.Affirmative);

                        txtidentidad.Text = "";
                        txtidentidad.Focus();
                    }
                }
            }
        }
Пример #7
0
        private async void txtCedul_LostFocus(object sender, RoutedEventArgs e)
        {
            if (!txtCedul.Text.Equals("") && cmbtipo.SelectedValue != null && cmbPais.SelectedValue != null)
            {
                if (tdAnt != (int)cmbtipo.SelectedValue || !docAnt.Equals(txtCedul.Text))
                {
                    C_Usuario cli = new C_Usuario();
                    cli.cedula = txtCedul.Text;
                    if (cli.existeDocIdentidad("cliente", (int)cmbPais.SelectedValue, (int)cmbtipo.SelectedValue) == 1)
                    {
                        await p.ShowMessageAsync("Error", "Existe ya un documento de identidad con ese número", MessageDialogStyle.Affirmative);

                        txtCedul.Text = "";
                        txtCedul.Focus();
                    }
                }
            }
        }
Пример #8
0
        public void Eliminar(C_Usuario Dato)
        {
            try
            {
                abrirConexion();
                MySqlCommand cmd = new MySqlCommand("DELETE FROM usuarios WHERE usuario_id = '" + Dato.ID + "'", conn);
                if (MessageBox.Show("¿Está seguro que que desea eliminar '" + Dato.Nombre + "'?", "¡Advertencia!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    cmd.ExecuteNonQuery();
                }

                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al Eliminar" + ex);
                throw new Exception("Error !!!");
            }
        }
Пример #9
0
        private void ModificarUsuario()
        {
            C_Usuario objetoUsuario = new C_Usuario();

            if (Cmb_M_Dni.SelectedIndex == -1)
            {
                MessageBox.Show("Seleccione un Usuario Por Favor", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                objetoUsuario.Dni = Int32.Parse(Cmb_M_Dni.SelectedValue.ToString());
            }
            if (Cmb_M_TipoTrabajador.SelectedIndex == -1)
            {
                MessageBox.Show("Seleccione un Tipo de Trabajador Por Favor", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                objetoUsuario.CodigoTipoTrabajador = Int32.Parse(Cmb_M_TipoTrabajador.SelectedValue.ToString());
            }
            objetoUsuario.Password        = Txt_M_Password.Text;
            objetoUsuario.Email           = Txt_M_CorreoElectronico.Text;
            objetoUsuario.Nombre          = Txt_M_Nombre.Text;
            objetoUsuario.ApellidoPaterno = Txt_M_ApellidoPaterno.Text;
            objetoUsuario.ApellidoMaterno = Txt_M_ApellidoMaterno.Text;
            objetoUsuario.FechaNacimiento = dtp_M_FechaNacimiento.Value;
            objetoUsuario.LugarNacimiento = Txt_M_LugarNacimiento.Text;
            objetoUsuario.Direccion       = Txt_M_Direccion.Text;
            objetoUsuario.Telefono        = Txt_M_Telefono.Text;
            objetoUsuario.FechaInicio     = dtp_M_FechaInicio.Value;
            if (_shalong.Usuario(2, objetoUsuario))
            {
                MessageBox.Show("Se Modifico el usuario correctamente", "Gestion Ventas", MessageBoxButtons.OK);
                CargarComboBox();
            }
            else
            {
                MessageBox.Show("No se pudo modificar el usuario", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #10
0
        private void GuardarUsuario()
        {
            C_Usuario objetoUsuario = new C_Usuario();

            if (Txt_I_Dni.Text == string.Empty)
            {
                MessageBox.Show("Ingrese un DNI", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                objetoUsuario.Dni = Int32.Parse(Txt_I_Dni.Text);
            }
            objetoUsuario.CodigoTipoTrabajador = Int32.Parse(Cmb_I_TipoTrabajador.SelectedValue.ToString());
            objetoUsuario.Password             = Txt_I_Password.Text;
            objetoUsuario.Email           = Txt_I_CorreoElectronico.Text;
            objetoUsuario.Nombre          = Txt_I_Nombre.Text;
            objetoUsuario.ApellidoPaterno = Txt_I_ApellidoPaterno.Text;
            objetoUsuario.ApellidoMaterno = Txt_I_ApellidoMaterno.Text;
            objetoUsuario.FechaNacimiento = dtp_I_FechaNacimiento.Value;
            objetoUsuario.LugarNacimiento = Txt_I_LugarNacimiento.Text;
            objetoUsuario.Direccion       = Txt_I_Direccion.Text;
            objetoUsuario.Telefono        = Txt_I_Telefono.Text;
            objetoUsuario.FechaInicio     = dtp_I_FechaInicio.Value;
            if (_shalong.Usuario(1, objetoUsuario))
            {
                MessageBox.Show("Ingreso correcto", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CargarComboBox();
                if (MessageBox.Show("¿Usted desea asignar permisos al usuario" + Txt_I_Dni.Text + "que acaba de crear?", "PERMISOS", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Permisos obj = new Permisos();
                    obj.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("No se pudo Guardar el Usuario Revise los Datos Por Favor", "Gestion Ventas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #11
0
        private async void tlGuardar_Click(object sender, RoutedEventArgs e)
        {
            if (txtApellido.Text.Equals("") || txtTcelular.Text.Equals("") || txtNombre.Text.Equals(""))
            {
                await p.ShowMessageAsync("Advertencia", "Debe completar los campos obligatorios", MessageDialogStyle.Affirmative);

                return;
            }
            if (error == true)
            {
                error = false;
                return;
            }
            C_Cliente clieNew = new C_Cliente();

            if (editando == 0)
            {
                if (!txtCedul.Text.Equals("") && cmbtipo.SelectedValue != null && cmbPais.SelectedValue != null)
                {
                    C_Usuario cli = new C_Usuario();
                    cli.cedula = txtCedul.Text;
                    if (cli.existeDocIdentidad("cliente", (int)cmbPais.SelectedValue, (int)cmbtipo.SelectedValue) == 1)
                    {
                        await p.ShowMessageAsync("Error", "Existe ya un documento de identidad con ese número", MessageDialogStyle.Affirmative);

                        txtCedul.Text = "";
                        txtCedul.Focus();
                        return;
                    }
                }


                if (!txtThabitacion.Text.Equals(""))
                {
                    if (clieNew.existeNumero(txtThabitacion.Text) == 1)
                    {
                        await p.ShowMessageAsync("Error", "El número ya está registrado", MessageDialogStyle.Affirmative);

                        txtThabitacion.Text = "";
                        txtThabitacion.Focus();
                        error = true;
                        return;
                    }
                }
                if (!txtTcelular.Text.Equals(""))
                {
                    if (clieNew.existeNumero(txtTcelular.Text) == 1)
                    {
                        await p.ShowMessageAsync("Error", "El número ya está registrado", MessageDialogStyle.Affirmative);

                        txtTcelular.Text = "";
                        txtTcelular.Focus();
                        error = true;
                        return;
                    }
                }
                if (!txtTcelular2.Text.Equals(""))
                {
                    if (clieNew.existeNumero(txtTcelular2.Text) == 1)
                    {
                        await p.ShowMessageAsync("Error", "El número ya está registrado", MessageDialogStyle.Affirmative);

                        txtTcelular2.Text = "";
                        txtTcelular2.Focus();
                        error = true;
                        return;
                    }
                }
            }

            if (cmbtipo.SelectedValue != null)
            {
                clieNew.id_td = (int)cmbtipo.SelectedValue;
            }
            clieNew.documento_identidad = txtCedul.Text;
            clieNew.nombre   = txtNombre.Text;
            clieNew.apellido = txtApellido.Text;
            if (cmbPais.SelectedValue != null)
            {
                clieNew.id_pais = (int)cmbPais.SelectedValue;
            }
            clieNew.direccion    = txtDireccion.Text;
            clieNew.t_habitacion = txtThabitacion.Text;
            clieNew.t_celular    = txtTcelular.Text;
            clieNew.t_oficina    = txtTcelular2.Text;
            if (clientSelect == true)
            {
                clieNew.id_status = (int)cmbStatus.SelectedValue;
            }
            if (cmbLocacion.SelectedValue != null)
            {
                clieNew.id_locacion = (int)cmbLocacion.SelectedValue;
            }
            clieNew.correo    = txtcorreo.Text;
            clieNew.profesion = txtProfesion.Text;
            if (!txtEdad.Text.Equals(""))
            {
                clieNew.edad = Convert.ToInt32(txtEdad.Text);
            }
            clieNew.edo_civil          = cmbEdoCivil.Text;
            clieNew.f_nacimiento       = dpFechaNac.SelectedDate;
            clieNew.asignado           = 0;
            clieNew.Id_statusPrincipal = (int)cmbStatusPrincipal.SelectedValue;
            clieNew.id_status          = (int)cmbStatus.SelectedValue;
            if (cmbStatusCita.SelectedIndex != -1)
            {
                clieNew.Id_subStatusCita = (int)cmbStatusCita.SelectedValue;
            }
            else
            {
                clieNew.Id_subStatusCita = null;
            }
            clieNew.observacion = txtobservacion.Text;
            if (cmbPromotor.SelectedIndex != -1)
            {
                clieNew.idPromotor = (int)cmbPromotor.SelectedValue;
            }


            if (clientSelect == false)
            {
                if (clieNew.NuevoCliente(App.userApp.iduser) == 1)
                {
                    await p.ShowMessageAsync("Información", "Se ha guardado correctamente", MessageDialogStyle.Affirmative);

                    //MessageBox.Show("Se ha guardado correctamente", "Información", MessageBoxButton.OK, MessageBoxImage.Information);
                    // clieNew.registarCambioStatus(App.userApp.iduser);
                    tlCancelar_Click(sender, e);
                    flNuevo.IsOpen = false;
                    Page_Loaded(sender, e);
                    error = false;
                }
                else
                {
                    await p.ShowMessageAsync("Error", "Error al guardar el usuario", MessageDialogStyle.Affirmative);
                }
            }
            else
            {
                if (!txtCedul.Text.Equals("") && cmbtipo.SelectedValue != null && cmbPais.SelectedValue != null)
                {
                    if (tdAnt != (int)cmbtipo.SelectedValue || !docAnt.Equals(txtCedul.Text))
                    {
                        C_Usuario cli = new C_Usuario();
                        cli.cedula = txtCedul.Text;
                        if (cli.existeDocIdentidad("cliente", (int)cmbPais.SelectedValue, (int)cmbtipo.SelectedValue) == 1)
                        {
                            await p.ShowMessageAsync("Error", "Existe ya un documento de identidad con ese número", MessageDialogStyle.Affirmative);

                            txtCedul.Text = "";
                            txtCedul.Focus();
                            error = true;
                            return;
                        }
                    }
                }
                if (!txtThabitacion.Text.Equals(""))
                {
                    if (!telhabAnt.Equals(txtThabitacion.Text))
                    {
                        if (clieNew.existeNumero(txtThabitacion.Text) == 1)
                        {
                            await p.ShowMessageAsync("Error", "El número ya está registrado", MessageDialogStyle.Affirmative);

                            txtThabitacion.Text = "";
                            txtThabitacion.Focus();
                            error = true;
                            return;
                        }
                    }
                }
                if (!txtTcelular.Text.Equals(""))
                {
                    if (!telCel1Ant.Equals(txtTcelular.Text))
                    {
                        if (clieNew.existeNumero(txtTcelular.Text) == 1)
                        {
                            await p.ShowMessageAsync("Error", "El número ya está registrado", MessageDialogStyle.Affirmative);

                            txtTcelular.Text = "";
                            txtTcelular.Focus();
                            error = true;
                            return;
                        }
                    }
                }
                if (!txtTcelular2.Text.Equals(""))
                {
                    if (!telCel2Ant.Equals(txtTcelular2.Text))
                    {
                        if (clieNew.existeNumero(txtTcelular2.Text) == 1)
                        {
                            await p.ShowMessageAsync("Error", "El número ya está registrado", MessageDialogStyle.Affirmative);

                            txtTcelular2.Text = "";
                            txtTcelular2.Focus();
                            error = true;
                            return;
                        }
                    }
                }
                clieNew.id_cliente = id;

                if (clieNew.editarCliente() == 1)
                {
                    await p.ShowMessageAsync("Información", "Se han actualizado correctamente los datos", MessageDialogStyle.Affirmative);

                    int sts = 0;
                    if (cmbStatusCita.SelectedValue != null)
                    {
                        sts = (int)cmbStatusCita.SelectedValue;
                        if (sts == -1)
                        {
                            sts = 0;
                        }
                    }
                    if (statusAnt != (int)cmbStatus.SelectedValue || idStatusPrinAnt != (int)cmbStatusPrincipal.SelectedValue || idSubStatusCitaAnt != sts)
                    {
                        clieNew.registarCambioStatus(App.userApp.iduser);
                    }

                    flNuevo.IsOpen = false;
                    guardado       = true;
                    editando       = 1;
                    error          = false;
                }
                else
                {
                    await p.ShowMessageAsync("Error", "Error al actualizar los datos", MessageDialogStyle.Affirmative);
                }
            }
        }