Exemplo n.º 1
0
 private void VerificarPrimerInicioSistema()
 {
     //Settings Configuracion = new Settings();
     if (Configuracion.PrimerInicioSistema)
     {
         MessageBox.Show("Bienvenido");
         NegocioCliente.Insertar("VENTA AL PÚBLICO EN GENERAL", "", null, DateTime.Now, null, null, null, null, null, null);
         NegocioEmpleado.Insertar("JOSÉ MARÍA", "LANZA", "M", Convert.ToDateTime("07/08/1988"), "33815021", "San Miguel 2257", "4275666", "3815273420", "*****@*****.**", "Administrador", "admin", "admin");
         DataTable dtCategoriaCaja = new DataTable();
         NegocioCategoria.Insertar("BEBIDAS", "Bebidas con y sin alcohol");
         NegocioCategoria.Insertar("ALIMENTOS", "");
         dtCategoriaCaja = NegocioCategoria.Mostrar();
         NegocioCaja.Insertar("CAJA 1", "Todas", true, Environment.MachineName, dtCategoriaCaja);
         Configuracion.PrimerInicioSistema = false;
         Configuracion.Save();
     }
 }
Exemplo n.º 2
0
        private void InsertarEditar()
        {
            string agregarActualizar = "";

            if (txtNombres.Text == string.Empty)
            {
                errorIcono.SetError(txtNombres, "Ingrese el nombre del empleado");
                txtNombres.SelectAll();
            }
            else if (txtApellidos.Text == string.Empty)
            {
                errorIcono.SetError(txtApellidos, "Ingrese el apellido del empleado");
                txtApellidos.SelectAll();
            }
            else if (cmbSexo.Text == string.Empty)
            {
                errorIcono.SetError(cmbSexo, "Ingrersse el sexo del trabajador");
                cmbSexo.Focus();
            }
            else if (dtpFechaNacimiento.Value == DateTime.Now.Date)
            {
                errorIcono.SetError(dtpFechaNacimiento, "Ingrese la fecha de nacimiento del empleado");
                dtpFechaNacimiento.Focus();
            }
            else if (txtNumeroDocumento.Text == string.Empty)
            {
                errorIcono.SetError(txtNumeroDocumento, "INgrese el número de documento del empleado");
                txtNumeroDocumento.SelectAll();
            }
            else if (cmbAcceso.Text == string.Empty)
            {
                errorIcono.SetError(cmbAcceso, "Ingrese el nivel de acceso del empleado");
                cmbAcceso.Focus();
            }
            else if (txtUsuario.Text == string.Empty)
            {
                errorIcono.SetError(txtUsuario, "Ingrese el nombre de usuario del empleado");
                txtUsuario.SelectAll();
            }
            else if (txtPassword.Text == string.Empty)
            {
                errorIcono.SetError(txtPassword, "Ingrese la contraseña del usuario");
                txtPassword.SelectAll();
            }
            else if (txtPassword.Text != txtConfirmarPassword.Text)
            {
                errorIcono.SetError(txtConfirmarPassword, "Las contraseñas no coinciden");
                txtConfirmarPassword.SelectAll();
            }
            else
            {
                try
                {
                    switch (ctrlSeleccionado)
                    {
                    case 0:    //INSERTAR
                        agregarActualizar = NegocioEmpleado.Insertar(txtNombres.Text.Trim().ToUpper(),
                                                                     txtApellidos.Text.Trim().ToUpper(), cmbSexo.Text, dtpFechaNacimiento.Value, txtNumeroDocumento.Text,
                                                                     txtDomicilio.Text, txtTelefonoFijo.Text, txtTelefonoCelular.Text, txtEmail.Text, cmbAcceso.Text,
                                                                     txtUsuario.Text.Trim(), txtPassword.Text.Trim());

                        NotificacionOk("Empleado guardado correctamente", "Guardando");
                        txtNombres.SelectAll();
                        Limpiar();
                        break;

                    case 1:    //EDITAR
                        agregarActualizar = NegocioEmpleado.Editar(Convert.ToInt32(txtIdEmpleado.Text),
                                                                   txtNombres.Text.Trim().ToUpper(), txtApellidos.Text.Trim().ToUpper(), cmbSexo.Text, dtpFechaNacimiento.Value,
                                                                   txtNumeroDocumento.Text, txtDomicilio.Text, txtTelefonoFijo.Text, txtTelefonoCelular.Text, txtEmail.Text, cmbAcceso.Text,
                                                                   txtUsuario.Text.Trim(), txtPassword.Text.Trim());

                        Nombres   = txtNombres.Text;
                        Apellidos = txtApellidos.Text;
                        Sexo      = cmbSexo.Text;
                        dtpFechaNacimiento.Value = FechaNacimiento;
                        NumeroDocumento          = txtNumeroDocumento.Text;
                        Domicilio                 = txtDomicilio.Text;
                        TelefonoFijo              = txtTelefonoFijo.Text;
                        TelefonoCelular           = txtTelefonoCelular.Text;
                        Email                     = txtEmail.Text;
                        Acceso                    = cmbAcceso.Text;
                        Usuario                   = txtUsuario.Text;
                        Password                  = txtPassword.Text;
                        txtConfirmarPassword.Text = string.Empty;
                        ctrlSeleccionado          = 3;
                        NotificacionOk("Empleado editado correctamente", "Editando");
                        break;

                    default:
                        NotificacionError(agregarActualizar, "Error");
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + ex.StackTrace);
                }
                HabilitarBotones();
            }
        }