Ejemplo n.º 1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         List <Error> Lista = this.ValidarDatos();
         if (Lista.Count == 0)
         {
             Configuracion         Datos = this.ObtenerDatos();
             Configuracion_Negocio CN    = new Configuracion_Negocio();
             CN.GuardarDatosConfiguracion(Datos);
             if (Datos.Completado)
             {
                 this.DialogResult = DialogResult.OK;
             }
             else
             {
                 MessageBox.Show("Ocurrió un error al guardar los datos. Intente nuevamente.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             this.MostrarMensajeError(Lista);
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmConfiguracion ~ btnGuardar_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
 private void IniciarForm()
 {
     try
     {
         Configuracion_Negocio CN    = new Configuracion_Negocio();
         Configuracion         Datos = CN.ObtenerDatosConfiguracion(Comun.Conexion);
         if (Datos.Completado)
         {
             this.CargarDatos(Datos);
         }
         else
         {
             this.IniciarDatos();
         }
         this.ActiveControl = this.txtRazonSocial;
         this.txtRazonSocial.Focus();
         if (File.Exists(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo)))
         {
             this.pictureBox1.Image = Image.FromFile(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
 private void bgwCorteTarjetas_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         Configuracion DatosAux = new Configuracion {
             Conexion = Comun.Conexion
         };
         Configuracion_Negocio CN = new Configuracion_Negocio();
         DatosAux.IDUsuario = Comun.IDUsuario;
         CN.EjecutarCorte(DatosAux);
         if (!DatosAux.Completado)
         {
             LogError.AddExcFileTxt(new Exception("Error al Ejecutar corte"), "frmMenuInicio ~ backgroundWorker1_DoWork");
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmMenuInicio ~ backgroundWorker1_DoWork");
     }
 }
Ejemplo n.º 4
0
 private void IniciarForm()
 {
     try
     {
         this.PermisosUsuario();
         this.LlenarComboSucursal();
         if (!this.bgwProductos.IsBusy)
         {
             this.bgwProductos.RunWorkerAsync();
         }
         if (!this.bgwIncidencias.IsBusy)
         {
             this.bgwIncidencias.RunWorkerAsync();
         }
         if (!this.bgwVentas.IsBusy)
         {
             this.bgwVentas.RunWorkerAsync();
         }
         //if (!string.IsNullOrEmpty(this.ObtenerSucursalCombo().IDSucursal))
         //{
         if (!this.bgwOcupacion.IsBusy)
         {
             this.bgwOcupacion.RunWorkerAsync(this.ObtenerSucursalCombo().IDSucursal);
         }
         //}
         Configuracion DatosAux = new Configuracion {
             Conexion = Comun.Conexion
         };
         Configuracion_Negocio CN = new Configuracion_Negocio();
         CN.EsFechaCorte(DatosAux);
         if (DatosAux.EsFechaCorte)
         {
             this.lblMensajes.Text = "Ejecutando corte en tarjetas de monedero... No cierre el programa. Un cierre inesperado puede desencadenar inestabilidad en el sistema.";
             this.bgwCorteTarjetas.RunWorkerAsync();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                List <Error> Errores = this.ValidarDatosEntrada();
                if (Errores.Count == 0)
                {
                    IniciarSistema();
                    Usuario DatosUsuario = new Usuario();
                    DatosUsuario          = this.ObtenerDatosUsuario();
                    DatosUsuario.Conexion = Comun.Conexion;
                    if (!string.IsNullOrEmpty(Comun.MACAddress))
                    {
                        this.Ingresar(DatosUsuario);

                        if (Comun.FaltaLogo)
                        {
                            Configuracion_Negocio CN  = new Configuracion_Negocio();
                            Configuracion         Aux = CN.ObtenerLogoImagen(Comun.Conexion);
                            if (Aux.BufferImagen.Length > 0)
                            {
                                Bitmap       imagen = null;
                                Byte[]       bytes  = Aux.BufferImagen;
                                MemoryStream ms     = new MemoryStream(bytes);
                                imagen = new Bitmap(ms);
                                try
                                {
                                    imagen.Save(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo));
                                }
                                catch (Exception ex)
                                {
                                    LogError.AddExcFileTxt(ex, "SaveImage ~ Login");
                                }
                                Aux.IDSucursal = Comun.IDSucursalCaja;
                                Aux.Conexion   = Comun.Conexion;
                                CN.LogoActualizado(Aux);
                            }
                        }


                        if (DatosUsuario.Completado)
                        {
                            if (DatosUsuario.Resultado == 1)
                            {
                                if (DatosUsuario.CrearIDCaja)
                                {
                                    frmAperturaCaja AperturaCaja = new frmAperturaCaja();
                                    AperturaCaja.ShowDialog();
                                    AperturaCaja.Dispose();
                                    if (AperturaCaja.DialogResult == DialogResult.OK)
                                    {
                                        this.Visible = false;
                                        frmMenuInicio Home = new frmMenuInicio();
                                        Home.ShowDialog();
                                        Home.Dispose();
                                        this.Visible = true;
                                        this.txtUsuario.Focus();
                                        this.txtUsuario.Text         = "";
                                        this.txtContraseña.Text      = "";
                                        this.txtMensajeError.Text    = "";
                                        this.txtMensajeError.Visible = false;
                                    }
                                }
                                else
                                {
                                    this.Visible = false;
                                    frmMenuInicio Home = new frmMenuInicio();
                                    Home.ShowDialog();
                                    Home.Dispose();
                                    this.Visible = true;
                                    this.txtUsuario.Focus();
                                    this.txtUsuario.Text         = "";
                                    this.txtContraseña.Text      = "";
                                    this.txtMensajeError.Text    = "";
                                    this.txtMensajeError.Visible = false;
                                }
                            }
                            else
                            {
                                this.DatosIncorrectos(DatosUsuario.Resultado);
                                if (DatosUsuario.Resultado == -8)
                                {
                                    frmAsignarCaja frmac = new frmAsignarCaja();
                                    frmac.ShowDialog();
                                    frmac.Dispose();
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "No se pudo obtener la configuración del Equipo. El sistema debe cerrarse.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "No se pudo obtener la configuración del Equipo. El sistema debe cerrarse.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Application.Exit();
                    }
                }
                else
                {
                    this.MostrarMensajeError(Errores);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogError.AddExcFileTxt(ex, "frmLogin ~ btnAceptar_Click");
            }
        }
Ejemplo n.º 6
0
 private void CargarDatos(Configuracion Datos)
 {
     try
     {
         this.txtRazonSocial.Text     = Datos.RazonSocial;
         this.txtNombreComercial.Text = Datos.NombreComercial;
         this.txtEslogan.Text         = Datos.Eslogan;
         this.txtRFC.Text             = Datos.RFC;
         this.txtRepresentante.Text   = Datos.Representante;
         this.txtRegimenFiscal.Text   = Datos.RegimenFiscal;
         this.txtDomicilioFiscal.Text = Datos.DomicilioFiscal;
         if (!string.IsNullOrEmpty(Datos.UrlLogo))
         {
             if (!File.Exists(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Datos.UrlLogo)))
             {
                 Configuracion_Negocio CN  = new Configuracion_Negocio();
                 Configuracion         Aux = CN.ObtenerLogoImagen(Comun.Conexion);
                 if (Aux.BufferImagen.Length > 0)
                 {
                     System.IO.MemoryStream ms = new System.IO.MemoryStream(Aux.BufferImagen);
                     Image.FromStream(ms).Save(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Datos.UrlLogo));
                 }
             }
             this.pbLogo.Image = Image.FromFile(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Datos.UrlLogo));
         }
         this.txtPorcentajeIva.Text  = string.Format("{0:F2}", Datos.PorcentajeIva);
         this.chkFechaCorte1.Checked = Datos.BandFecha01;
         this.chkFechaCorte2.Checked = Datos.BandFecha02;
         this.chkFechaCorte3.Checked = Datos.BandFecha03;
         if (Datos.BandFecha01)
         {
             this.dtpFechaCorte1.Value = Datos.Fecha01;
         }
         else
         {
             this.dtpFechaCorte1.Value = DateTime.Today;
         }
         if (Datos.BandFecha02)
         {
             this.dtpFechaCorte2.Value = Datos.Fecha02;
         }
         else
         {
             this.dtpFechaCorte2.Value = DateTime.Today;
         }
         if (Datos.BandFecha03)
         {
             this.dtpFechaCorte3.Value = Datos.Fecha03;
         }
         else
         {
             this.dtpFechaCorte3.Value = DateTime.Today;
         }
         this.txtGarantia.Text         = Datos.TextoGarantia;
         this.txtPagoDiasFestivos.Text = string.Format("{0:F2}", Datos.PagoDiasFestivos);
         this.txtPagoDiasVaciones.Text = string.Format("{0:F2}", Datos.PagoDiasVacaciones);
         this.txtPagosDiaDomingo.Text  = string.Format("{0:F2}", Datos.PagoDiasDomingo);
         this.txtFaltasRetrasos.Text   = Datos.FaltasRetardos.ToString();
         this.txtTextoTicket.Text      = Datos.TextoTicket;
         this.txtPorcDesc.Text         = string.Format("{0:F2}", Datos.DescCumpleaños);
         DatosAux = Datos;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }