Пример #1
0
 private void btnAceptar_Click(object sender, EventArgs e)
 {
     if (dgvProductos.CurrentRow != null)
     {
         if ((int)dgvProductos[5, dgvProductos.CurrentRow.Index].Value * (int)nudCantidad.Value <= (int)dgvProductos[6, dgvProductos.CurrentRow.Index].Value)
         {
             bool existencias;
             if (cboTipoPromocion.SelectedIndex == 0)
             {
                 existencias = true;
             }
             else
             {
                 existencias = false;
             }
             DataGridViewRow dr = dgvProductos.CurrentRow;
             if (frm != null)
             {
                 frm.PromocionProducto((int)dr.Cells[1].Value, dr.Cells[2].Value.ToString(), dr.Cells[3].Value.ToString(), (decimal)dr.Cells[4].Value, (int)nudCantidad.Value * (int)dr.Cells[5].Value, (int)dr.Cells[6].Value, (Unidades)Enum.Parse(typeof(Unidades), dr.Cells[7].Value.ToString()), (int)dr.Cells[0].Value, existencias);
             }
             else if (frmC != null)
             {
                 frmC.PromocionProducto((int)dr.Cells[1].Value, dr.Cells[2].Value.ToString(), dr.Cells[3].Value.ToString(), (decimal)dr.Cells[4].Value, (int)nudCantidad.Value * (int)dr.Cells[5].Value, (int)dr.Cells[6].Value, (Unidades)Enum.Parse(typeof(Unidades), dr.Cells[7].Value.ToString()), (int)dr.Cells[0].Value, existencias);
             }
             this.Close();
         }
         else
         {
             FuncionesGenerales.Mensaje(this, Mensajes.Alerta, "La cantidad de promociones a vender excede las existencias.", "Admin CSY");
         }
     }
 }
Пример #2
0
        private int CantidadVentas()
        {
            int cant = 0;

            try
            {
                string    sql = "SELECT COUNT(id) AS i FROM venta";
                DataTable dt  = ConexionBD.EjecutarConsultaSelect(sql);
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["i"] != DBNull.Value)
                    {
                        cant = int.Parse(dr["i"].ToString());
                    }
                }
            }
            catch (MySqlException ex)
            {
                FuncionesGenerales.MensajeError("Ha ocurrido un error al tomar la cantidad de ventas. La ventana se cerrará. Ocurrió un error al conectar con la base de datos.", ex);
                this.Close();
            }
            catch (Exception ex)
            {
                FuncionesGenerales.MensajeError("Ha ocurrido un error al tomar la cantidad de ventas. La ventana se cerrará. Ocurrió un error genérico.", ex);
                this.Close();
            }
            return(cant);
        }
Пример #3
0
 private void LlenarDataGrid()
 {
     try
     {
         dgvVentas.Rows.Clear();
         foreach (DataRow dr in dt.Rows)
         {
             DateTime fecha    = DateTime.Parse(dr["fecha"].ToString());
             decimal  total    = decimal.Parse(dr["total"].ToString());
             string   tipoPago = "Sin información";
             if (dr["tipo_pago"].ToString() == "0")
             {
                 tipoPago = "Efectivo";
             }
             else if (dr["tipo_pago"].ToString() == "1")
             {
                 tipoPago = "Tarjeta";
             }
             dgvVentas.Rows.Add(new object[] { dr["id"], fecha, total, tipoPago, dr["c"], FuncionesGenerales.NombreUsuario(dr["create_user_id"].ToString()) });
             Application.DoEvents();
         }
         dgvVentas_RowEnter(dgvVentas, new DataGridViewCellEventArgs(0, 0));
     }
     catch (Exception ex)
     {
         FuncionesGenerales.MensajeError("No se ha podido mostrar la información. ", ex);
     }
 }
Пример #4
0
 private void btnAceptar_Click(object sender, EventArgs e)
 {
     try
     {
         frm.IVA = int.Parse(txtIVA.Text);
         MessageBox.Show("Se ha modificado el I.V.A. correctamente.", "HS FIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (FormatException ex)
     {
         FuncionesGenerales.MensajeError("No se ha modificado el valor del I.V.A. El número dado no es válido.", ex);
     }
     catch (OverflowException ex)
     {
         FuncionesGenerales.MensajeError("No se ha modificado el valor del I.V.A. El número dado excede el valor máxico.", ex);
     }
     catch (ArgumentNullException ex)
     {
         FuncionesGenerales.MensajeError("No se ha modificado el valor del I.V.A. El argumento dado es nulo.", ex);
     }
     catch (Exception ex)
     {
         FuncionesGenerales.MensajeError("No se ha modificado el valor del I.V.A. Ha ocurrido un error genérico.", ex);
     }
 }
Пример #5
0
 private void btnCobrar_Click(object sender, EventArgs e)
 {
     if (VerificarDatos())
     {
         if (configurado)
         {
             if (FuncionesGenerales.Mensaje(this, Mensajes.Pregunta, "¿Los datos ingresados son correctos?", "Admin CSY") == System.Windows.Forms.DialogResult.Yes)
             {
                 try
                 {
                     NuevaCompra();
                     this.configurado = false;
                     FuncionesGenerales.Mensaje(this, Mensajes.Exito, "¡Se ha registrado la compra correctamente!", "Admin CSY");
                     this.Close();
                 }
                 catch (MySqlException ex)
                 {
                     FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al insertar la compra. No se ha podido conectar con la base de datos.", "Admin CSY", ex);
                 }
                 catch (Exception ex)
                 {
                     FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al insertar la compra.", "Admin CSY", ex);
                 }
             }
         }
         else
         {
             FuncionesGenerales.Mensaje(this, Mensajes.Alerta, "No se ha configurado la informacion de pago", "Admin CSY");
         }
     }
 }
 /// <summary>
 /// LEER TIMER
 /// </summary>
 private void LeerTimer()
 {
     try
     {
         //===========================================================
         // ESTADOS
         //===========================================================
         List <Item_Seleccion> Lista = new List <Item_Seleccion>();
         Lista.Add(new Item_Seleccion {
             Id = 0, Nombre = "SIN TIMER"
         });
         Lista.Add(new Item_Seleccion {
             Id = 5000, Nombre = "5 SEGUNDOS"
         });
         Lista.Add(new Item_Seleccion {
             Id = 10000, Nombre = "10 SEGUNDOS"
         });
         Lista.Add(new Item_Seleccion {
             Id = 15000, Nombre = "15 SEGUNDOS"
         });
         FuncionesGenerales.CDDLCombos(Lista, DDL_TIMER);
     }
     catch
     {
         throw;
     }
 }
Пример #7
0
 private void CalcularTotales()
 {
     try
     {
         decimal tot = 0M, efe = 0M, vou = 0M;
         foreach (DataGridViewRow dr in dgvVentas.Rows)
         {
             tot += (decimal)dr.Cells[3].Value;
             if (dr.Cells[4].Value.ToString() == "Efectivo")
             {
                 efe += (decimal)dr.Cells[3].Value;
             }
             else if (dr.Cells[4].Value.ToString() == "Crédito" || dr.Cells[4].Value.ToString() == "Débito")
             {
                 vou += (decimal)dr.Cells[3].Value;
             }
         }
         lblTotal.Text    = tot.ToString("C2");
         lblVentas.Text   = dgvVentas.RowCount.ToString();
         lblEfectivo.Text = efe.ToString("C2");
         lblVouchers.Text = vou.ToString("C2");
     }
     catch (Exception ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al calcular los totales.", "Admin CSY", ex);
     }
 }
Пример #8
0
 private void ObtenerDatosDireccion()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "SELECT * FROM direccion WHERE id=?id";
         sql.Parameters.AddWithValue("?id", idD);
         DataTable dt = ConexionBD.EjecutarConsultaSelect(sql);
         foreach (DataRow dr in dt.Rows)
         {
             lblFCalle.Text   = dr["calle"].ToString();
             lblFNumExt.Text  = dr["num_ext"].ToString();
             lblFNumInt.Text  = dr["num_int"].ToString();
             lblFCP.Text      = dr["cp"].ToString();
             lblFColonia.Text = dr["colonia"].ToString();
             lblFCiudad.Text  = dr["ciudad"].ToString();
             lblFEstado.Text  = dr["estado"].ToString();
         }
     }
     catch (MySqlException ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al mostrar los datos de la dirección fiscal. No se ha podido conectar con la base de datos.", "Admin CSY", ex);
     }
     catch (Exception ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error genérico al mostrar los datos de la dirección fiscal.", "Admin CSY", ex);
     }
 }
Пример #9
0
        /// <summary>
        /// CARGAR GRILLA DE DATOS
        /// </summary>
        private void CARGAR_GRILLA_OBJETO_X_INTERFAZ()
        {
            try
            {
                //===========================================================
                // DECLARACION DE VARIABLES
                //===========================================================
                List <oSP_READ_OBJETO_X_INTERFAZ> Lista = new List <oSP_READ_OBJETO_X_INTERFAZ>();


                //===========================================================
                // LLAMADA A SERVICIO
                //===========================================================
                Lista = V_Global().ObjetoInterfaz;

                if (Lista == null)
                {
                    Lista = new List <oSP_READ_OBJETO_X_INTERFAZ>();
                }

                FuncionesGenerales.Cargar_Grilla(Lista, GRD_ASIGNACION_OBJETO);
            }
            catch
            {
                throw;
            }
        }
Пример #10
0
        private void pcbLogotipo_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "Archivos de imagen (*.jpg; *.jpeg) | *.jpg; *.jpeg";
            ofd.Multiselect      = false;
            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            DialogResult r = ofd.ShowDialog(this);

            if (r == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    pcbLogotipo.Image = new Bitmap(ofd.FileName);
                }
                catch (System.IO.FileNotFoundException ex)
                {
                    FuncionesGenerales.Mensaje(this, Mensajes.Error, "El archivo seleccionado no pudo ser encontrado.", "Admin CSY", ex);
                }
                catch (Exception ex)
                {
                    FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error genérico al tratar de crear el logotipo", "Admin CSY", ex);
                }
            }
        }
Пример #11
0
 private void btnQuitar_Click(object sender, EventArgs e)
 {
     if (FuncionesGenerales.Mensaje(this, Mensajes.Pregunta, "¿Realmente desea quitar éste logotipo?", "Admin CSY") == System.Windows.Forms.DialogResult.Yes)
     {
         pcbLogotipo.Image = null;
     }
 }
Пример #12
0
 private void InsertarLocker()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand
         {
             CommandText = "INSERT INTO locker (numSocio, num,fecha_ini,fecha_fin, estado, create_time, create_user_id) " +
                           "VALUES (?numSocio, ?num,?fecha_ini,?fecha_fin, ?estado, NOW(), ?create_user_id)"
         };
         sql.Parameters.AddWithValue("?numSocio", 0);
         sql.Parameters.AddWithValue("?num", NumeroLocker);
         sql.Parameters.AddWithValue("?fecha_ini", DBNull.Value);
         sql.Parameters.AddWithValue("?fecha_fin", DBNull.Value);
         sql.Parameters.AddWithValue("?estado", EstadoLocker.Desocupado);
         sql.Parameters.AddWithValue("?create_user_id", frmMain.id);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         FuncionesGenerales.MensajeError("No se ha podido crear el locker. No se pudo conectar con la base de datos.", ex);
     }
     catch (Exception ex)
     {
         FuncionesGenerales.MensajeError("No se ha podido crear el locker. Ha ocurrido un error genérico.", ex);
     }
 }
Пример #13
0
 private void UltimoFolio()
 {
     try
     {
         string    sql = "SELECT MAX(id) AS i FROM registro_membresias";
         DataTable dt  = ConexionBD.EjecutarConsultaSelect(sql);
         foreach (DataRow dr in dt.Rows)
         {
             if (dr["i"] != DBNull.Value)
             {
                 ultimoFolio = ((int)dr["i"] + 1).ToString();
             }
             else
             {
                 ultimoFolio = "1";
             }
         }
     }
     catch (MySqlException ex)
     {
         FuncionesGenerales.MensajeError("Ocurrió un error al generar el nuevo folio. No se ha podido conectar con la base de datos.", ex);
     }
     catch (Exception ex)
     {
         FuncionesGenerales.MensajeError("Ocurrió un error al generar el nuevo folio. Ocurrió un error genérico.", ex);
     }
 }
Пример #14
0
 private void LlenarDataGrid()
 {
     try
     {
         dgvProductos.Rows.Clear();
         if (cboTipoPromocion.SelectedIndex == 0)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 dgvProductos.Rows.Add(new object[] { dr["id"], dr["idP"], dr["codigo"], dr["nombre"], dr["precio"], dr["cant"], dr["cant_prod"], dr["unidad"] });
                 Application.DoEvents();
             }
         }
         else if (cboTipoPromocion.SelectedIndex == 1)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 dgvProductos.Rows.Add(new object[] { dr["id"], dr["idP"], dr["codigo"], dr["nombre"], dr["precio"], 0M, 0M, dr["unidad"] });
                 Application.DoEvents();
             }
         }
     }
     catch (Exception ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al mostrar las promociones.", "Admin CSY", ex);
     }
 }
Пример #15
0
 private void EstadoLocker(int id, FrmLockers.EstadoLocker e)
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE locker SET estado=?estado WHERE id=?id";
         sql.Parameters.AddWithValue("?estado", e);
         sql.Parameters.AddWithValue("?id", id);
         ConexionBD.EjecutarConsulta(sql);
         sql.Parameters.Clear();
         sql.CommandText = "UPDATE registro_locker SET autorizacion_user=?user, fecha_autorizacion=NOW() WHERE locker_id=?id";
         sql.Parameters.AddWithValue("?user", frmMain.id);
         sql.Parameters.AddWithValue("?id", id);
         ConexionBD.EjecutarConsulta(sql);
         dgvPendientes.Rows.RemoveAt(dgvPendientes.CurrentRow.Index);
     }
     catch (MySqlException ex)
     {
         FuncionesGenerales.MensajeError("No se ha podido cambiar el estado del locker. Hubo un error al tratar de conectar con la base de datos.", ex);
     }
     catch (Exception ex)
     {
         FuncionesGenerales.MensajeError("No se ha podido cambiar el estado del locker. Ha ocurrido un error genérico.", ex);
     }
 }
Пример #16
0
 public frmNuevaPromocion()
 {
     InitializeComponent();
     cboTipo.SelectedIndex   = 0;
     cboGenero.SelectedIndex = 0;
     FuncionesGenerales.CargarInterfaz(this);
 }
        /// <summary>
        /// LEER PROCESOS
        /// </summary>
        //private void LeerProcesos()
        //{

        //    try
        //    {

        //        PNL_MENSAJE.Visible = false;

        //        //===========================================================
        //        // DECLARACION DE VARIABLES
        //        //===========================================================
        //        List<oSP_READ_EJECUCION_X_PROCESO> LST_REST = new List<oSP_READ_EJECUCION_X_PROCESO>();
        //        SMetodos Servicio = new SMetodos();

        //        //===========================================================
        //        // PARAMETROS DE ENTRADA
        //        //===========================================================
        //        iSP_READ_EJECUCION_X_PROCESO ParametrosInput = new iSP_READ_EJECUCION_X_PROCESO();
        //        ParametrosInput.NRO_INTERFAZ = Convert.ToInt32(DDL_INTERFAZ.SelectedValue);
        //        ParametrosInput.FECHA_CREACION = Convert.ToDateTime(TXT_FECHA_INI.Text);



        //        //===========================================================
        //        // LLAMADA DEL SERVICIO
        //        //===========================================================
        //        LST_REST = Servicio.SP_READ_EJECUCION_X_PROCESO(ParametrosInput);



        //        //===========================================================
        //        // EVALUAR RETORNO
        //        //===========================================================
        //        if (LST_REST == null)
        //        {
        //            DibujarGrillaDatos();
        //            return;
        //        }
        //        if (LST_REST.Count <= 0)
        //        {
        //            DibujarGrillaDatos();
        //            return;
        //        }


        //        FuncionesGenerales.Cargar_Grilla(LST_REST, GRDData);
        //    }
        //    catch (EServiceRestFulException srv)
        //    {
        //        MensajeLOG(srv.Message, "ERRORES DE SERVICIO");
        //    }
        //    catch (System.Exception ex)
        //    {
        //        MensajeLOG(UThrowError.MensajeThrow(ex), "ERRORES DE APLICACIÓN");
        //    }


        //}

        /// <summary>
        /// LEER INTERFAZ POR CLUSTER
        /// </summary>
        private void LEER_INTERFAZ_X_CLUSTER(int ID_CLUSTER)
        {
            try
            {
                //===========================================================
                // DECLARACION DE VARIABLES
                //===========================================================
                SMetodos Servicio           = new SMetodos();
                List <Item_Seleccion> Lista = new List <Item_Seleccion>();

                //===========================================================
                // TRAER LISTA DE EMPRESAS REGISTRADAS EN SISTEMA
                //===========================================================
                List <oSP_READ_INTERFAZ_X_CLUSTER> ListaInterfazEmpresa = new List <oSP_READ_INTERFAZ_X_CLUSTER>();
                ListaInterfazEmpresa = Servicio.SP_READ_INTERFAZ_X_CLUSTER(new iSP_READ_INTERFAZ_X_CLUSTER {
                    ID_CLUSTER = ID_CLUSTER
                });

                foreach (oSP_READ_INTERFAZ_X_CLUSTER item in ListaInterfazEmpresa)
                {
                    Lista.Add(new Item_Seleccion {
                        Id = item.ID_INTERFAZ, Nombre = item.CODIGO_INTERFAZ
                    });
                }

                FuncionesGenerales.CDDLCombos(Lista, DDL_INTERFAZ);

                DDL_INTERFAZ_SelectedIndexChanged(null, null);
            }
            catch
            {
                throw;
            }
        }
Пример #18
0
    public bool logout(string user)
    {
        FuncionesGenerales fgclass = new FuncionesGenerales();

        string        stringQueryLogout_Insertar = @"update usuarios set ultimoCierreSesion = GETDATE() where [ID o MATRICULA] = '{0}' and _active = 1";
        SqlConnection conexionSQL;
        SqlCommand    comandoSQL;
        SqlDataReader lectorSQL;

        conexionSQL = new SqlConnection(connectionString);
        try
        {
            stringQueryLogout_Insertar = string.Format(stringQueryLogout_Insertar, user.ToString().Trim());
            comandoSQL = new SqlCommand(stringQueryLogout_Insertar, conexionSQL);
            conexionSQL.Open();
            lectorSQL = comandoSQL.ExecuteReader();
            conexionSQL.Close();
            lectorSQL.Close();
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #19
0
    /// <summary>
    /// Función que inserta un nuevo miembro en la base de datos.
    /// </summary>
    /// <param name="miembro">Objeto de la clase CMiembro con toda la información del miembro a insertar.</param>
    /// <exception cref="MySql.Data.MySqlClient.MySqlException">Excepción que se lanza cuando ocurre un error con la conexión a la base de datos o con la ejecución de la consulta</exception>
    /// <exception cref="System.Runtime.InteropServices.ExternalException">El tipo de excepción base para todas las excepciones de interoperabilidad COM y excepciones de control de excepciones estructurado (SEH).</exception>
    /// <exception cref="System.ArgumentNullException">Excepción que se produce cuando se pasa una referencia nula a un método que no la acepta como argumento válido.</exception>
    /// <exception cref="System.Exception">Representa los errores que se producen durante la ejecución de una aplicación.</exception>
    /// <returns>Valor booleano que indica si se inserto el miembro correctamente.</returns>
    public bool InsertarMiembro(Socio miembro)
    {
        bool inserto = false;

        try
        {
            MySqlCommand sql = new MySqlCommand();
            sql.CommandText = "INSERT INTO miembros (numSocio, nombre, apellidos, direccion, ciudad, estado, telefono, celular, email, genero, fecha_nac,limite_credito,eliminado, create_time, create_user_id, huella, imagen)" +
                              "VALUES (?numSocio, ?nombre, ?apellidos, ?direccion, ?ciudad, ?estado, ?telefono, ?celular, ?email, ?genero, ?fecha_nac,?limite_credito,?eliminado, NOW(), ?create_user_id, ?huella, ?imagen)";
            sql.Parameters.AddWithValue("?numSocio", miembro.numSocio);
            sql.Parameters.AddWithValue("?nombre", miembro.nombre);
            sql.Parameters.AddWithValue("?apellidos", miembro.apellidos);
            sql.Parameters.AddWithValue("?direccion", miembro.direccion);
            sql.Parameters.AddWithValue("?ciudad", miembro.ciudad);
            sql.Parameters.AddWithValue("?estado", miembro.estado);
            sql.Parameters.AddWithValue("?telefono", miembro.telefono);
            sql.Parameters.AddWithValue("?celular", miembro.celular);
            sql.Parameters.AddWithValue("?email", miembro.email);
            sql.Parameters.AddWithValue("?genero", miembro.genero);
            sql.Parameters.AddWithValue("?fecha_nac", miembro.fechaNacimiento.ToString("yyyy-MM-dd") + " 00:00:00");
            sql.Parameters.AddWithValue("?eliminado", 0);
            sql.Parameters.AddWithValue("?limite_credito", miembro.limiteCredito);
            sql.Parameters.AddWithValue("?create_user_id", miembro.CreateUser);
            if (huella != null)
            {
                sql.Parameters.AddWithValue("?huella", huella);
            }
            else
            {
                sql.Parameters.AddWithValue("?huella", DBNull.Value);
            }
            if (imgMiembro != null)
            {
                sql.Parameters.AddWithValue("@imagen", FuncionesGenerales.ImagenBytes(imgMiembro));
            }
            else
            {
                sql.Parameters.AddWithValue("@imagen", DBNull.Value);
            }
            ConexionBD.EjecutarConsulta(sql);
            inserto = true;
        }
        catch (MySqlException ex)
        {
            throw ex;
        }
        catch (System.Runtime.InteropServices.ExternalException ex)
        {
            throw ex;
        }
        catch (ArgumentNullException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return(inserto);
    }
Пример #20
0
        /// <summary>
        /// LEER GRUPO DE CARGA POR CAMPANA
        /// </summary>
        private void LEER_GRUPO_CARGA(int ID_CLUSTER)
        {
            try
            {
                //===========================================================
                // DECLARACION DE VARIABLES
                //===========================================================
                SMetodos Servicio = new SMetodos();

                //===========================================================
                // TRAER LISTA DE EMPRESAS REGISTRADAS EN SISTEMA
                //===========================================================
                List <oSP_READ_GRUPO_CARGA> ListaGrupoCarga = new List <oSP_READ_GRUPO_CARGA>();
                ListaGrupoCarga = Servicio.SP_READ_GRUPO_CARGA(new iSP_READ_GRUPO_CARGA {
                    ID_CLUSTER = ID_CLUSTER
                });


                if (ListaGrupoCarga == null)
                {
                    V_Global().Grupos = new List <oSP_READ_GRUPO_CARGA>();
                }
                else
                {
                    V_Global().Grupos = ListaGrupoCarga;
                }

                FuncionesGenerales.Cargar_Grilla(ListaGrupoCarga, GRDDataGrupo);
            }
            catch
            {
                throw;
            }
        }
Пример #21
0
 private void frmVentasDiarias_Load(object sender, EventArgs e)
 {
     try
     {
         CargarTrabajadores();
         if (idTrabajadores.Count > 0)
         {
             cboVendedor.SelectedIndex = 0;
         }
         else
         {
             chbTrabajador.Checked = false;
             chbTrabajador.Enabled = false;
             cboVendedor.Enabled   = false;
         }
     }
     catch (MySqlException ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al cargas los trabajadores. No se ha podido conectar a la base de datos. La búsqueda por trabajador estará desactivada.", "Admin CSY", ex);
         chbTrabajador.Enabled = false;
     }
     catch (Exception ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al cargas los trabajadores. La búsqueda por trabajador estará desactivada.", "Admin CSY", ex);
         chbTrabajador.Enabled = false;
     }
 }
Пример #22
0
 private void DatosCuenta(bool origen)
 {
     try
     {
         Cuenta c = new Cuenta(idAux);
         c.ObtenerDatos();
         if (origen)
         {
             lblBancoOrigen.Text  = c.Banco;
             lblCuentaOrigen.Text = c.NumeroCuenta;
             lblSucOrigen.Text    = c.Sucursal;
             lblBenefOrigen.Text  = c.Beneficiario;
             idCuentaOrigen       = idAux;
         }
         else
         {
             lblBancoDestino.Text  = c.Banco;
             lblCuentaDestino.Text = c.NumeroCuenta;
             lblSucDestino.Text    = c.Sucursal;
             lblBenefDestino.Text  = c.Beneficiario;
             idCuentaDestino       = idAux;
         }
     }
     catch (MySqlException ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al mostrar los datos de la cuenta. No se ha podido conectar con la base de datos.", "Admin CSY", ex);
     }
     catch (Exception ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al mostrar los datos de la cuenta.", "Admin CSY", ex);
     }
 }
Пример #23
0
        /// <summary>
        /// Método que verifica la existencia del producto en la venta, en caso de estar registrado, suma la cantidad
        /// dada al producto
        /// </summary>
        /// <param name="id">ID del producto</param>
        /// <param name="cant">Cantidad a añadir al producto</param>
        private bool VerificarProducto(int id, int cant)
        {
            bool existe = false;

            foreach (DataGridViewRow dr in dgvProductos.Rows)
            {
                if (dr.Cells[0].Value.ToString() == id.ToString())
                {
                    int c       = ((int)dr.Cells[4].Value + cant);
                    int cantInv = Inventario.CantidadProducto(id, Config.idSucursal);
                    if (c <= cantInv)
                    {
                        dr.Cells[4].Value = c;
                    }
                    else
                    {
                        FuncionesGenerales.Mensaje(this, Mensajes.Informativo, "La cantidad de productos que tratas de ingresar excede a la cantidad en inventario. La cantidad en inventario de \"" + dr.Cells[2].Value.ToString() + "\" son \"" + cantInv.ToString("0") + "\"", "Admin CSY");
                        dr.Cells[4].Value = cantInv;
                    }
                    existe = true;
                    if (c <= 0)
                    {
                        QuitarProducto(dr);
                    }
                    CalcularTotales();
                    break;
                }
            }
            return(existe);
        }
Пример #24
0
 /// <summary>
 /// Inicia una nueva cotización, y verifica si el formulario es visible, en caso de no serlo, lo muestra primero
 /// y después inicia la nueva cotización
 /// </summary>
 public void NuevaCotizacion()
 {
     VerificarVisible();
     if (c.Abierta)
     {
         if (FuncionesGenerales.Mensaje(this, Mensajes.Pregunta, "¿Realmente desea crear una nueva cotización?\n(Puedes guardar la cotización actual para continuarla posteriormente)", "Admin CSY") == System.Windows.Forms.DialogResult.Yes)
         {
             cboTipoPrecio.SelectedIndex = 0;
             c.IDVendedor = idVendedor;
             c.NuevaCotizacion();
             ControlesHabilitados();
             AsignarCliente(0, "Público en general");
             lblFolio.Text    = c.IDCotizacion.ToString();
             lblSubtotal.Text = lblImpuesto.Text = lblDescuento.Text = lblTotal.Text = "$0.00";
             lblCantDif.Text  = lblCantTot.Text = "0";
             dgvProductos.Rows.Clear();
             CalcularTotales();
         }
     }
     else
     {
         cboTipoPrecio.SelectedIndex = 0;
         c.IDVendedor = idVendedor;
         c.NuevaCotizacion();
         ControlesHabilitados();
         AsignarCliente(0, "Público en general");
         lblFolio.Text    = c.IDCotizacion.ToString();
         lblSubtotal.Text = lblImpuesto.Text = lblDescuento.Text = lblTotal.Text = "$0.00";
         lblCantDif.Text  = lblCantTot.Text = "0";
         dgvProductos.Rows.Clear();
         CalcularTotales();
     }
 }
Пример #25
0
 private void txtBusqueda_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Enter)
     {
         if (txtBusqueda.Text.Trim() != "")
         {
             string[] datos = txtBusqueda.Text.Split(new char[] { '*' }, StringSplitOptions.RemoveEmptyEntries);
             if (datos.Length > 1)
             {
                 try
                 {
                     BusquedaProducto(datos[1].ToString(), int.Parse(datos[0]));
                 }
                 catch (FormatException)
                 {
                     FuncionesGenerales.Mensaje(this, Mensajes.Informativo, "Formato de multiplicador no válido", "Admin CSY");
                 }
             }
             else
             {
                 BusquedaProducto(datos[0].ToString(), 1);
             }
             txtBusqueda.Text = "";
         }
     }
 }
Пример #26
0
 private void InsertarUsuario()
 {
     MySql.Data.MySqlClient.MySqlCommand sql = new MySql.Data.MySqlClient.MySqlCommand();
     sql.CommandText = "INSERT INTO usuarios (userName, password, nivel, imagen, huella,eliminado) " +
                       "VALUES (?userName, ?password, ?nivel, ?imagen, ?huella,?eliminado)";
     sql.Parameters.AddWithValue("?userName", txtNombreUsu.Text);
     sql.Parameters.AddWithValue("?password", Clases.FuncionesGenerales.GetHashString(txtContra.Text));
     sql.Parameters.AddWithValue("?nivel", nivel);
     if (pcbImagenUsuario.Image != null)
     {
         sql.Parameters.AddWithValue("?imagen", FuncionesGenerales.ImagenBytes(pcbImagenUsuario.Image));
     }
     else
     {
         sql.Parameters.AddWithValue("?imagen", DBNull.Value);
     }
     if (huella != null)
     {
         sql.Parameters.AddWithValue("?huella", huella);
     }
     else
     {
         sql.Parameters.AddWithValue("?huella", DBNull.Value);
     }
     sql.Parameters.AddWithValue("?eliminado", 0);
     Clases.ConexionBD.EjecutarConsulta(sql);
 }
Пример #27
0
        private void BuscarVentas(DateTime fechaIni, DateTime fechaFin)
        {
            Mensajes e = new Mensajes(Mensaje);

            try
            {
                MySqlCommand sql = new MySqlCommand();
                sql.CommandText = "SELECT v.id, v.fecha, v.total, v.tipo_pago, SUM(vd.cantidad) AS c, v.create_user_id FROM venta AS v INNER JOIN venta_detallada AS vd ON (v.id=vd.id_venta) WHERE (v.fecha BETWEEN ?fechaIni AND ?fechaFin) GROUP BY v.id";
                sql.Parameters.AddWithValue("?fechaIni", fechaIni.ToString("yyyy/MM/dd") + " 00:00:00");
                sql.Parameters.AddWithValue("?fechaFin", fechaFin.ToString("yyyy/MM/dd") + " 23:59:59");
                dt = ConexionBD.EjecutarConsultaSelect(sql);
            }
            catch (MySqlException)
            {
                tmrEspera.Enabled = false;
                FuncionesGenerales.frmEsperaClose();
                this.Invoke(e, new object[] { "No se encontraron ventas en esas fechas." });
            }
            catch (Exception)
            {
                tmrEspera.Enabled = false;
                FuncionesGenerales.frmEsperaClose();
                this.Invoke(e, new object[] { "No se encontraron ventas en esas fechas." });
            }
        }
Пример #28
0
 private void btnCancelar_Click(object sender, EventArgs e)
 {
     if (Privilegios._CancelarVenta)
     {
         if (dgvVentas.CurrentRow != null)
         {
             if (FuncionesGenerales.Mensaje(this, Mensajes.Pregunta, "¿Realmente desea cancelar esta venta?", "Admin CSY") == System.Windows.Forms.DialogResult.Yes)
             {
                 try
                 {
                     if ((decimal)dgvVentas[6, dgvVentas.CurrentRow.Index].Value > 0)
                     {
                         FuncionesGenerales.Mensaje(this, Mensajes.Informativo, "A la venta se le resto el valor de " + ((decimal)dgvVentas[6, dgvVentas.CurrentRow.Index].Value).ToString("C2") + " dado a que ya se habían devuelto productos con anterioridad.", "Admin CSY");
                     }
                     Venta.CancelarVenta((int)dgvVentas[0, dgvVentas.CurrentRow.Index].Value);
                     MovimientoCaja();
                     FuncionesGenerales.Mensaje(this, Mensajes.Exito, "¡Se ha cancelado correctamente la venta!", "Admin CSY");
                     dgvVentas.Rows.Remove(dgvVentas.CurrentRow);
                 }
                 catch (MySqlException ex)
                 {
                     FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al cancelar la venta. No se ha podido conectar a la base de datos. Vuelva a cargar la lista de ventas para asegurarse de que ésta se haya cancelado.", Config.shrug, ex);
                 }
                 catch (Exception ex)
                 {
                     FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al cancelar la venta. Vuelva a cargar la lista de ventas para asegurarse de que ésta se haya cancelado.", Config.shrug, ex);
                 }
             }
         }
     }
     else
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Alerta, "No tienes los permisos necesarios para realizar ésta acción. Habla con tu administrador para que te asigne los permisos necesarios.", "Admin CSY");
     }
 }
Пример #29
0
 private bool ValidarDatos()
 {
     if (txtCorreo.Text.Trim() == "")
     {
         MessageBox.Show("El campo correo no debe ir vacío. Este dato se tomará para enviar el correo.", "HS FIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     else
     {
         if (!FuncionesGenerales.EsCorreoValido(txtCorreo.Text))
         {
             MessageBox.Show("El correo ingresado no es válido.", "HS FIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return(false);
         }
     }
     if (txtPass.Text.Trim() == "")
     {
         MessageBox.Show("El campo contraseña no debe ir vacío. Este dato se tomará para enviar el correo.", "HS FIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     if (txtPuerto.Text.Trim() == "")
     {
         MessageBox.Show("El campo puerto no debe ir vacío. Este dato servirá para conectar con el servidor de correos.", "HS FIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     if (txtHost.Text.Trim() == "")
     {
         MessageBox.Show("El campo host no puede ir vacío. Este dato servirá para conectar con el servidor de correos.", "HS FIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     return(true);
 }
Пример #30
0
 private void frmDetalleProductoDevolucion_Load(object sender, EventArgs e)
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "SELECT codigo, marca, descripcion1, imagen FROM producto WHERE id=?id";
         sql.Parameters.AddWithValue("?id", id);
         DataTable dt = ConexionBD.EjecutarConsultaSelect(sql);
         foreach (DataRow dr in dt.Rows)
         {
             lblCodigo.Text      = dr["codigo"].ToString();
             lblMarca.Text       = dr["marca"].ToString();
             lblDescripcion.Text = dr["descripcion1"].ToString();
             if (dr["imagen"] != DBNull.Value)
             {
                 pcbProducto.Image = FuncionesGenerales.BytesImagen((byte[])dr["imagen"]);
             }
         }
     }
     catch (MySqlException ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al cargar los datos del producto. No se ha podido conectar con la base de datos.", "Admin CSY", ex);
     }
     catch (Exception ex)
     {
         FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al cargar los datos del producto.", "Admin CSY", ex);
     }
 }