コード例 #1
0
        /// <summary>
        /// Función que inserta un nuevo registro de los trabajadores
        /// </summary>
        /// <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.Exception">Representa los errores que se producen durante la ejecución de una aplicación.</exception>
        /// <returns>Valor booleano que indica si se efectuo el registro</returns>
        public bool InsetarRegiostroTrabajadores()
        {
            bool registro = false;

            try
            {
                if (Validar())
                {
                    MySqlCommand sql = new MySqlCommand();
                    sql.CommandText = "INSERT INTO registro_trabajadores " +
                                      "(numTrabajador,fecha_modificacion,usuario) VALUES" +
                                      "(?,?,?)";
                    sql.Parameters.AddWithValue("@numTrabajador", NumeroTrabajador);
                    sql.Parameters.AddWithValue("@fecha_modificacion", FechaModificacion);
                    sql.Parameters.AddWithValue("@usuario", Usuario);
                    ConexionBD.EjecutarConsulta(sql);
                }
                registro = true;
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(registro);
        }
コード例 #2
0
 /// <summary>
 /// Función que inserta un nuevo registro de membresías con el valor dados en las propiedades de la clase
 /// </summary>
 /// <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.Exception">Representa los errores que se producen durante la ejecución de una aplicación.</exception>
 public void InsertarRegistroMembresias()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "INSERT INTO registro_membresias (membresia_id, fecha_fin, fecha_ini, tipo, descripcion, tipo_pago, precio, terminacion, folio_remision, folio_ticket, create_user_id, create_time) " +
                           "VALUES (?membresia_id, ?fecha_fin, ?fecha_ini, ?tipo, ?descripcion, ?tipo_pago, ?precio, ?terminacion, ?folio_remision, ?folio_ticket, ?create_user_id, NOW())";
         sql.Parameters.AddWithValue("?membresia_id", this.IDMembresia);
         sql.Parameters.AddWithValue("?fecha_fin", this.FechaFin);
         sql.Parameters.AddWithValue("?fecha_ini", this.FechaInicio);
         sql.Parameters.AddWithValue("?tipo", this.Tipo);
         sql.Parameters.AddWithValue("?descripcion", this.Descripcion);
         sql.Parameters.AddWithValue("?tipo_pago", this.TipoPago);
         sql.Parameters.AddWithValue("?precio", this.Precio);
         sql.Parameters.AddWithValue("?terminacion", this.Terminacion);
         sql.Parameters.AddWithValue("?folio_remision", this.FolioRemision);
         sql.Parameters.AddWithValue("?folio_ticket", this.FolioTicket);
         sql.Parameters.AddWithValue("?create_user_id", this.CreateUser);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
 public static void CrearEstadoCaja()
 {
     try
     {
         string    sqlc = "SELECT COUNT(estado) AS c FROM estado_caja";
         DataTable dt   = ConexionBD.EjecutarConsultaSelect(sqlc);
         foreach (DataRow dr in dt.Rows)
         {
             if (int.Parse(dr["c"].ToString()) <= 0)
             {
                 try
                 {
                     string sql = "INSERT INTO estado_caja (estado) VALUES (0)";
                     ConexionBD.EjecutarConsulta(sql);
                 }
                 catch (Exception ex)
                 {
                     throw new CajaException(ex.Message);
                 }
             }
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #4
0
 /// <summary>
 /// Función que edita la membresia de determinado socio
 /// </summary>
 /// <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.Exception">Representa los errores que se producen durante la ejecución de una aplicación.</exception>
 public void EditarMembresia()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE membresias SET fecha_ini=?fecha_ini, fecha_fin=?fecha_fin, " +
                           "estado=?estado, id_promocion=?id_promocion, update_time=NOW(), update_user_id=?update_user_id WHERE id=?id";
         sql.Parameters.AddWithValue("?fecha_ini", FechaInicio);
         sql.Parameters.AddWithValue("?fecha_fin", FechaFin);
         sql.Parameters.AddWithValue("?estado", Estado);
         if (IDPromocion <= 0)
         {
             sql.Parameters.AddWithValue("?id_promocion", DBNull.Value);
         }
         else
         {
             sql.Parameters.AddWithValue("?id_promocion", IDPromocion);
         }
         sql.Parameters.AddWithValue("?update_user_id", UpdateUser);
         sql.Parameters.AddWithValue("?id", IDMembresia);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #5
0
 public static void DesactivarLockers()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE locker SET estado=?estado WHERE DATE_FORMAT(fecha_fin, '%Y-%m-%d')<?fecha_fin";
         sql.Parameters.AddWithValue("?estado", frmLockers.EstadoLocker.Desocupado);
         sql.Parameters.AddWithValue("?fecha_fin", DateTime.Now.ToString("yyyy-MM-dd"));
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (FormatException ex)
     {
         throw ex;
     }
     catch (ArgumentOutOfRangeException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #6
0
 /// <summary>
 /// Función que edita un producto con la información dada en las propiedades de la clase.
 /// </summary>
 /// <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.Exception">Representa los errores que se producen durante la ejecución de una aplicación.</exception>
 public void EditarProducto()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE producto SET nombre=?nombre, marca=?marca, descripcion=?descripcion, unidad=?unidad, " +
                           "cant=?cant, cant_alm=?cant_alm, costo=?costo, precio=?precio, control_stock=?control_stock, update_time=NOW(), update_user_id=?update_user_id WHERE id=?id";
         sql.Parameters.AddWithValue("?nombre", Nombre);
         sql.Parameters.AddWithValue("?marca", Marca);
         sql.Parameters.AddWithValue("?descripcion", Descripcion);
         sql.Parameters.AddWithValue("?unidad", Unidad);
         sql.Parameters.AddWithValue("?cant", Cantidad);
         sql.Parameters.AddWithValue("?cant_alm", CantidadAlmacen);
         sql.Parameters.AddWithValue("?costo", Costo);
         sql.Parameters.AddWithValue("?precio", Precio);
         sql.Parameters.AddWithValue("?control_stock", ControlStock);
         sql.Parameters.AddWithValue("?update_user_id", frmMain.id);
         sql.Parameters.AddWithValue("?id", ID);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #7
0
 /// <summary>
 /// Función que inserta un producto en la base de datos con la información que se encuentran en las propiedades de la clase.
 /// </summary>
 /// <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.Exception">Representa los errores que se producen durante la ejecución de una aplicación.</exception>
 /// <returns>Valor que indica si el producto se inserto correctamente</returns>
 public bool InsertarProducto()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "INSERT INTO producto (id, nombre, marca, descripcion, unidad, cant, cant_alm, costo, precio, control_stock, create_time, create_user_id) " +
                           "VALUES (?id, ?nombre, ?marca, ?descripcion, ?unidad, ?cant, ?cant_alm, ?costo, ?precio, ?control_stock, NOW(), ?create_user_id)";
         sql.Parameters.AddWithValue("?id", ID);
         sql.Parameters.AddWithValue("?nombre", Nombre);
         sql.Parameters.AddWithValue("?marca", Marca);
         sql.Parameters.AddWithValue("?descripcion", Descripcion);
         sql.Parameters.AddWithValue("?unidad", Unidad);
         sql.Parameters.AddWithValue("?cant", Cantidad);
         sql.Parameters.AddWithValue("?cant_alm", CantidadAlmacen);
         sql.Parameters.AddWithValue("?costo", Costo);
         sql.Parameters.AddWithValue("?precio", Precio);
         sql.Parameters.AddWithValue("?control_stock", ControlStock);
         sql.Parameters.AddWithValue("?create_user_id", frmMain.id);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(true);
 }
コード例 #8
0
 public void ReiniciarInventario()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE inventario SET cant=0";
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #9
0
 public static void CambiarEstadoCaja(bool estado)
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE estado_caja SET estado=?estado";
         sql.Parameters.AddWithValue("?estado", estado);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #10
0
 /// <summary>
 /// Función que elimina un producto de la base de datos
 /// </summary>
 /// <param name="id">ID del producto a eliminar</param>
 /// <exception cref="MySql.Data.MySqlClient.MySqlException"></exception>
 /// <exception cref="System.Exception"></exception>
 public void EliminarProducto(string id)
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "DELETE FROM producto WHERE id=?id";
         sql.Parameters.AddWithValue("?id", id);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #11
0
 public void ModificarCantidadInventario(int id, int cant, int idSuc)
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE inventario SET cant=?cant WHERE id_producto=?id";
         sql.Parameters.AddWithValue("?cant", cant);
         sql.Parameters.AddWithValue("?id", id);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #12
0
 /// <summary>
 /// Método que cambia el estado de un usuario a eliminado
 /// </summary>
 /// <param name="id">ID del usuario a eliminar</param>
 /// <param name="estado">true para eliminar, false para restablecer</param>
 public static void CambiarEstadoEliminadoUsuario(int id, bool estado)
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE usuario SET eliminado=?eliminado WHERE id=?id";
         sql.Parameters.AddWithValue("?eliminado", estado);
         sql.Parameters.AddWithValue("?id", id);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #13
0
        /// <summary>
        /// Función que agrega una nueva membresia a la tabla membresias
        /// </summary>
        /// <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.Exception">Representa los errores que se producen durante la ejecución de una aplicación.</exception>
        /// <returns>Último ID agregado</returns>
        public int InsertarMembresia()
        {
            int idMem = 0;

            try
            {
                MySqlCommand sql = new MySqlCommand();
                sql.CommandText = "INSERT INTO membresias (numSocio, fecha_ini, fecha_fin, estado, id_promocion, create_time, create_user_id) " +
                                  "VALUES (?numSocio, ?fecha_ini, ?fecha_fin, ?estado, ?id_promocion, NOW(), ?create_user_id)";
                sql.Parameters.AddWithValue("?numSocio", NumeroSocio);
                sql.Parameters.AddWithValue("?fecha_ini", FechaInicio);
                sql.Parameters.AddWithValue("?fecha_fin", FechaFin);
                sql.Parameters.AddWithValue("?estado", Estado);
                if (IDPromocion <= 0)
                {
                    sql.Parameters.AddWithValue("?id_promocion", DBNull.Value);
                }
                else
                {
                    sql.Parameters.AddWithValue("?id_promocion", IDPromocion);
                }
                sql.Parameters.AddWithValue("?create_user_id", CreateUser);
                ConexionBD.EjecutarConsulta(sql);
                sql.Parameters.Clear();
                sql.CommandText = "SELECT MAX(id) AS i FROM membresias";
                DataTable dt = ConexionBD.EjecutarConsultaSelect(sql);
                foreach (DataRow dr in dt.Rows)
                {
                    idMem = (int)dr["i"];
                }
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(idMem);
        }
コード例 #14
0
 /// <summary>
 /// Método que inserta un nuevo movimiento en la base de datos con los datos de las propiedades
 /// </summary>
 public void InsertarMovimiento()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "INSERT INTO boveda (efectivo, descripcion, tipo_movimiento, create_user, create_time) " +
                           "VALUES (?efectivo, ?descripcion, ?tipo_movimiento, ?create_user, NOW())";
         sql.Parameters.AddWithValue("?efectivo", efectivo);
         sql.Parameters.AddWithValue("?descripcion", descripcion);
         // sql.Parameters.AddWithValue("?tipo_movimiento", tipoMovimiento);
         sql.Parameters.AddWithValue("?create_user", Usuario.IDUsuarioActual);
         ConexionBD.EjecutarConsulta(sql);
         Totales();
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #15
0
 public void Editar()
 {
     try
     {
         MySqlCommand sql = new MySqlCommand();
         sql.CommandText = "UPDATE inventario SET id_producto=?id_producto, id_sucursal=?id_sucursal, cant=?cant, " +
                           "precio=?precio,  update_user=?update_user, update_time=NOW() WHERE id=?id";
         sql.Parameters.AddWithValue("?id_producto", idProducto);
         sql.Parameters.AddWithValue("?id_sucursal", idSucursal);
         sql.Parameters.AddWithValue("?cant", cantidad);
         sql.Parameters.AddWithValue("?precio", precio);
         sql.Parameters.AddWithValue("?update_user", Usuario.IDUsuarioActual);
         sql.Parameters.AddWithValue("?id", id);
         ConexionBD.EjecutarConsulta(sql);
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }