Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Compra           compra      = new Compra();
            List <Ubicacion> ubicaciones = new List <Ubicacion>();

            foreach (var u in UbicacionesListView.CheckedItems)
            {
                Ubicacion ubi = (Ubicacion)((ListViewItem)u).Tag;
                compra.total += ubi.precio;
                ubicaciones.Add(ubi);
            }
            ComprasDao     comprasDao = new ComprasDao();
            SqlTransaction trans      = DatabaseConection.getInstance().BeginTransaction();


            compra.ubicaciones = ubicaciones;
            compra.fechaCompra = Generals.getFecha();
            compra.cantidad    = ubicaciones.Count;
            Cliente clie = new Cliente();

            compra.cli = clie;


            ubicacionesSeleccionadas = ubicaciones;
            try
            {
                comprasDao.insertarCompra(compra, publicacionActual, trans);
                trans.Commit();
                MessageBox.Show("Compra realizada con exito");
            }
            catch (Exception ex) {
                trans.Rollback();
                MessageBox.Show("Ha ocurrido un error al procesar la compra");
            }
        }
Пример #2
0
        public void insertarEmpresaConUsuario(Empresa empresa, String usuario, String contraseña)
        {
            string query = "EXEC [TheBigBangQuery].[InsertarEmpresaConUsuario]" +
                           "@usuario = '" + usuario + "'," +
                           "@contraseña = '" + contraseña + "'," +
                           "@razonSocial = '" + empresa.razonSocial + "'," +
                           "@cuit = '" + empresa.cuit + "'," +
                           "@mail = '" + empresa.mailEmpresa + "'," +
                           "@telefono = '" + empresa.telefonoEmpresa + "'," +
                           "@calle = '" + empresa.direccion.calle + "'," +
                           "@altura = '" + empresa.direccion.numero + "'," +
                           "@piso = '" + empresa.direccion.piso + "'," +
                           "@depto = '" + empresa.direccion.depto + "'," +
                           "@localidad = '" + empresa.direccion.localidad + "'," +
                           "@codigoPostal = '" + empresa.direccion.codigoPostal + "'," +
                           "@ciudad = '" + empresa.direccion.ciudad + "'," +
                           "@fechaCreacion = '" + Generals.getFecha() + "'";

            try
            {
                DatabaseConection.executeNoParamFunction(query);
            }
            catch (SqlException e) {
                throw e;
            }
        }
Пример #3
0
        public IngresarTarjetaForm()
        {
            tarjeta = new Tarjeta();
            InitializeComponent();

            VencimientoDatePicker.Value = Generals.getFecha();
        }
Пример #4
0
        public int getUltimaPaginaRubros(List <Rubro> rubros)
        {
            string query = "SELECT [TheBigBangQuery].[getUltimaLineaFiltroRubro](@table, @fechaActual)";

            try
            {
                SqlCommand com = new SqlCommand(query);

                DataTable table = new DataTable();
                table.Columns.Add("rub_id", typeof(decimal));

                foreach (Rubro r in rubros)
                {
                    table.Rows.Add(r.id);
                }

                SqlParameter param = new SqlParameter("@table", SqlDbType.Structured);
                param.TypeName = "[TheBigBangQuery].[RubrosList]";
                param.Value    = table;

                com.Parameters.Add(param);
                com.Parameters.AddWithValue("@fechaActual", Generals.getFecha());

                return(DatabaseConection.executeParamFunction <int>(com));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #5
0
        public void insertarFactura(SqlTransaction transaction, string tipoPago, Compra compra, Action <int> resNuevoId)
        {
            string procedure = "[TheBigBangQuery].[insertarNuevaFactura]";

            try {
                SqlCommand command = new SqlCommand(procedure);
                command.Transaction = transaction;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@idCompra", compra.id);
                command.Parameters.AddWithValue("@tipoPago", tipoPago);
                command.Parameters.AddWithValue("@fecha", Generals.getFecha());
                command.Parameters.AddWithValue("@idEmpresa", compra.publicacion.espectaculo.empresa.id);
                SqlParameter param = new SqlParameter("@numeroFactura", SqlDbType.Decimal)
                {
                    Direction = ParameterDirection.Output
                };
                command.Parameters.Add(param);

                DatabaseConection.executeNoParamFunction(command);
                var newId = param.Value;
                int newIdInt;
                if (int.TryParse(newId.ToString(), out newIdInt))
                {
                    resNuevoId(newIdInt);
                }
            }
            catch (Exception ex) {
                throw new SqlInsertException("Error al realizar la rendicion de comisiones", 0);
            }
        }
Пример #6
0
        private void EliminarButton_Click(object sender, EventArgs e)
        {
            try
            {
                ListViewItem item = listaRoles.SelectedItems[0];

                Rol rol = roles.Find(elem => elem.nombre.Equals(item.Text));
                if (item.ForeColor == Color.Gray)
                {
                    // Le quito la baja logica al ROl
                    rol.bajaLogica = Generals.getFechaMinima();
                }
                else
                {
                    // Le agrego la baja logica con la fecha de hoy
                    rol.bajaLogica = Generals.getFecha();
                }
                item.ForeColor = item.ForeColor == Color.Gray ? Color.Black : Color.Gray;
                RolesDao rolesDao = new RolesDao();
                rolesDao.actualizarRol(rol);
            }
            catch (Exception ex) {
                MessageBox.Show("Debe seleccionar algun rol para poder deshabilitarlo/habilitarlo");
            }
        }
Пример #7
0
        public List <Publicacion> filtrarPaginasPorRubro(int pagina, List <Rubro> rubros)
        {
            string             funcion = "SELECT * FROM [TheBigBangQuery].[getPaginaPublicacionesPorFiltroRubros](@pagina, @table, @fechaActual)";
            List <Publicacion> publis  = new List <Publicacion>();
            SqlDataReader      reader  = null;

            try
            {
                SqlCommand command = new SqlCommand(funcion);
                command.CommandText = funcion;

                DataTable table = new DataTable();
                table.Columns.Add("rub_id", typeof(decimal));

                foreach (Rubro r in rubros)
                {
                    table.Rows.Add(r.id);
                }

                SqlParameter param = new SqlParameter("@table", SqlDbType.Structured);
                param.TypeName = "[TheBigBangQuery].[RubrosList]";
                param.Value    = table;

                command.Parameters.AddWithValue("@pagina", pagina);
                command.Parameters.Add(param);
                command.Parameters.AddWithValue("@fechaActual", Generals.getFecha());

                reader = DatabaseConection.executeQuery(command);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Publicacion publi = ParserPublicaciones.parsearPublicacionDelReader(reader);
                        publi.espectaculo.descripcion = reader.IsDBNull(6) ? null : reader.GetSqlString(6).ToString();
                        publi.espectaculo.direccion   = reader.IsDBNull(7) ? null : reader.GetSqlString(7).ToString();
                        publi.gradoPublicacion.nivel  = reader.IsDBNull(8) ? null : reader.GetSqlString(8).ToString();
                        publis.Add(publi);
                    }
                }


                return(publis);
            }
            catch (Exception e)
            {
                throw new DataNotFoundException("No se han encontrado publicaciones pertenecientes a los rubros seleccionados");
            }
            finally {
                if (reader != null & !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
Пример #8
0
        public GenerarPublicacionForm()
        {
            InitializeComponent();
            // Dia Minimo: ayer
            DateTime fecha = Generals.getFecha();

            fechasDeLaPublicacion.Add(fecha);
            this.FechaEventoTimePicker.MinDate = fecha;
            this.FechaEventoTimePicker.Value   = fecha;

            initContent();
        }
Пример #9
0
 public void LimpiarButton_Click(object sender, EventArgs e)
 {
     NombreCliente.Text                = "";
     ApellidoCliente.Text              = "";
     MailCliente.Text                  = "";
     TelefonoCliente.Text              = "";
     CuilCliente.Text                  = "";
     dirDelCliente                     = null;
     FechaNacimientoCliente.Value      = Generals.getFecha();
     DniCliente.Text                   = "";
     ListaTiposDocumento.SelectedIndex = 0;
 }
Пример #10
0
        public int getUltimaPaginaDesc(string desc)
        {
            string query = "SELECT [TheBigBangQuery].[getUltimaLineaFiltroDesc](@desc, @fechaActual)";

            try
            {
                SqlCommand com = new SqlCommand(query);
                com.Parameters.AddWithValue("@desc", desc);
                com.Parameters.AddWithValue("@fechaActual", Generals.getFecha());
                return(DatabaseConection.executeParamFunction <int>(com));
            }
            catch (Exception e) {
                throw e;
            }
        }
Пример #11
0
        public void habilitarODesahabilitarEmpresa(Empresa empresa)
        {
            string query = "UPDATE TheBigBangQuery.Empresa " +
                           "SET empr_dado_baja = " +
                           (empresa.bajaLogica != null ? "'" + Generals.getFecha().ToString("yyyy-dd-MM") + "'" : "NULL") +
                           " WHERE empr_id = 1";

            try
            {
                DatabaseConection.executeNoParamFunction(query);
            }
            catch (SqlException ex) {
                throw ex;
            }
        }
Пример #12
0
        public List <Publicacion> getPublicacionesPorPagina(int pagina, Nullable <int> empresaId = null)
        {
            string             function          = "SELECT * FROM [TheBigBangQuery].[GetPublicacionesPorPaginaSinFiltroDeEmpresa](@pagina, @empresa, @fechaActual)";
            SqlDataReader      reader            = null;
            List <Publicacion> publicacionesList = new List <Publicacion>();

            try
            {
                SqlCommand command = new SqlCommand(function);
                command.CommandText = function;

                command.Parameters.AddWithValue("@pagina", pagina);
                if (empresaId != null)
                {
                    command.Parameters.AddWithValue("@empresa", empresaId);
                }
                else
                {
                    command.Parameters.AddWithValue("@empresa", DBNull.Value);
                }

                command.Parameters.AddWithValue("@fechaActual", Generals.getFecha());

                reader = DatabaseConection.executeQuery(command);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Publicacion publi = ParserPublicaciones.parsearPublicacionDelReader(reader);
                        publi.espectaculo.descripcion = reader.IsDBNull(6) ? null : reader.GetSqlString(6).ToString();
                        publi.espectaculo.direccion   = reader.IsDBNull(7) ? null : reader.GetSqlString(7).ToString();
                        publi.gradoPublicacion.nivel  = reader.IsDBNull(8) ? null : reader.GetSqlString(8).ToString();
                        publicacionesList.Add(publi);
                    }
                }
                return(publicacionesList);
            }
            catch (Exception ex)
            {
                throw new DataNotFoundException("No se han encontrado publicaciones para la pagina seleccionada");
            }
            finally {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
Пример #13
0
 private void VencimientoTextBox_TextChanged(object sender, EventArgs e)
 {
     try {
         DateTime fecha = VencimientoDatePicker.Value;
         if (fecha.CompareTo(Generals.getFecha()) < 0)
         {
             // FECHA ANTERIOR A HOY
             tarjeta.vencimiento = null;
         }
         else
         {
             tarjeta.vencimiento = fecha.ToString("yyyy/MM");
         }
     }
     catch (Exception ex) { }
 }
Пример #14
0
        private void borrarFormulario()
        {
            this.FechaEventoTimePicker.Value           = FechaEventoTimePicker.MinDate;
            this.DireccionTextBox.Text                 = "";
            this.RubroComboBox.SelectedItem            = null;
            this.GradoPublicacionComboBox.SelectedItem = null;
            this.UbicacionesListView.Items.Clear();
            this.textBox1.Text = "";

            this.ubicacionesList.Clear();
            this.fechasDeLaPublicacion.Clear();
            this.fechasDeLaPublicacion.Add(Generals.getFecha());
            direccionPublicacion = "";
            rubro                  = null;
            gradoPublicacion       = null;
            descripcionPublicacion = "";
        }
Пример #15
0
        private void DeshabilitarClienteButton_Click(object sender, EventArgs e)
        {
            ClientesDao clientesDao = new ClientesDao();

            try
            {
                bool isHabilitado = clienteSeleccionado.bajaLogica == null;
                if (!isHabilitado)
                {
                    clienteSeleccionado.bajaLogica = Generals.getFecha();
                }
                clientesDao.habilitarODesabilitarCliente(clienteSeleccionado);
                ((ListViewItem)ListaCliente.SelectedItems[0]).ForeColor = isHabilitado ? Color.Gray : Color.Black;
            }
            catch (Exception ex) {
                Console.Write(ex.Message);
            }
        }
Пример #16
0
        public ListadoForm()
        {
            InitializeComponent();
            estadisticasDao = new EstadisticasDao();

            for (int i = Generals.getFecha().Year + 1; i >= 2000; i--)
            {
                this.AñoComboBox.Items.Add(i.ToString());
            }

            new GradoDePublicacionDao().getGradosDePublicacion().ForEach(elem => {
                this.gradoComboBox.Items.Add(elem);
            });
            this.gradoComboBox.SelectedIndex       = 1;
            this.AñoComboBox.SelectedIndex         = 0;
            this.TrimestreComboBox.SelectedIndex   = 0;
            this.EstadisticaComboBox.SelectedIndex = 0;
        }
Пример #17
0
        public FiltrosForm()
        {
            InitializeComponent();

            rubrosDao = new RubrosDao();

            rubrosDao.getRubros().ForEach(elem => {
                this.RubrosListView.Items.Add(elem, false);
            });

            FechaIDatePicker.MinDate = Generals.getFechaMinima();
            FechaIDatePicker.Value   = Generals.getFecha();
            FechaFDatePicker.MinDate = Generals.getFechaMinima().AddDays(1);
            FechaFDatePicker.Value   = Generals.getFecha().AddDays(1);
            this.DescripcionFilterTextBox.Enabled = true;
            this.FechaIDatePicker.Enabled         = false;
            this.FechaFDatePicker.Enabled         = false;
            this.RubrosListView.Enabled           = false;
        }
Пример #18
0
        public List <Publicacion> filtrarPaginasPorDescripcion(int pagina, string descripcion)
        {
            List <Publicacion> publis;
            SqlDataReader      reader   = null;
            string             function = "SELECT * FROM [TheBigBangQuery].[getPaginaPublicacionesPorFiltroDescripcion](@pag, @desc,@fechaActual)";

            try
            {
                publis = new List <Publicacion>();
                SqlCommand command = new SqlCommand(function);
                command.CommandText = function;

                command.Parameters.AddWithValue("@pag", pagina);
                command.Parameters.AddWithValue("@desc", descripcion);
                command.Parameters.AddWithValue("@fechaActual", Generals.getFecha());

                reader = DatabaseConection.executeQuery(command);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Publicacion publi = ParserPublicaciones.parsearPublicacionDelReader(reader);
                        publi.espectaculo.descripcion = reader.IsDBNull(6) ? null : reader.GetSqlString(6).ToString();
                        publi.espectaculo.direccion   = reader.IsDBNull(7) ? null : reader.GetSqlString(7).ToString();
                        publi.gradoPublicacion.nivel  = reader.IsDBNull(8) ? null : reader.GetSqlString(8).ToString();
                        publis.Add(publi);
                    }
                }
                return(publis);
            }
            catch (Exception e)
            {
                throw new DataNotFoundException("No se han encontrado publicaciones coincidentes con la descripcion ingresada");
            }
            finally {
                if (reader != null & !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
Пример #19
0
 private void DeshabilitarButton_Click(object sender, EventArgs e)
 {
     try
     {
         EmpresasDao empresasDao = new EmpresasDao();
         bool        habilitado  = empresaSeleccionada.bajaLogica == null;
         try
         {
             if (habilitado)
             {
                 empresaSeleccionada.bajaLogica = Generals.getFecha();
             }
             else
             {
                 empresaSeleccionada.bajaLogica = null;
             }
             empresasDao.habilitarODesahabilitarEmpresa(empresaSeleccionada);
             reemplazarEnLista(empresaSeleccionada);
             var empre = empresasList.First(elem => elem.id == empresaSeleccionada.id);
             if (empre != null)
             {
                 ((Empresa)empre).bajaLogica = (habilitado ? (Nullable <DateTime>)Generals.getFecha() : null);
             }
         }
         catch (SqlException ex)
         {
             MessageBoxButtons alert = MessageBoxButtons.OK;
             MessageBox.Show("No se ha podido deshabilitar la empresa seleccionada", "ERROR!", alert);
         }
         catch (Exception ex)
         {
         }
         finally
         {
             ((ListViewItem)EmpresasListView.Items[indexEmpresaSeleccionada]).ForeColor = !habilitado ? Color.Black : Color.Gray;
         }
     }
     catch (Exception ex) {
         MessageBox.Show("Debe seleccionar una empresa para poder habilitarla o deshabilitarla");
     }
 }
Пример #20
0
        public PuntosForm(Cliente cli)
        {
            InitializeComponent();
            cliente = cli;

            actualizarPuntos();

            premiosForm               = new PremiosListForm(cli);
            premiosForm.TopLevel      = false;
            premiosForm.AutoScroll    = true;
            premiosForm.Parent        = this.Parent;
            premiosForm.onCanjePress += this.onCanjePuntos;
            this.PuntosPanel.Controls.Add(premiosForm);
            premiosForm.Show();


            if (cli.puntos == 0)
            {
                // MOSTRARLE AL USUARIO QUE NO TIENE PUNTOS
                this.VencimientoLabel.Visible     = false;
                this.VencimientoTextLabel.Visible = false;
                this.PuntosTextLabel.Text         = "No posee puntos para canjear";
                this.PuntosLabel.Visible          = false;
                premiosForm.CanjearButton.Enabled = false;
            }
            else if (DateTime.Compare((DateTime)cli.vencimientoPuntos, Generals.getFecha()) < 0)
            {
                // PUNTOS VENCIDOS
                premiosForm.CanjearButton.Enabled = false;
                this.VencimientoTextLabel.Text    = "Puntos Vencidos el:";
                this.PuntosLabel.Text             = cliente.puntos.ToString();
                this.VencimientoLabel.Text        = ((DateTime)cliente.vencimientoPuntos).ToShortDateString();
            }
            else
            {
                // MOSTRAR LISTA DE PUNTOS
                this.PuntosLabel.Text      = cliente.puntos.ToString();
                this.VencimientoLabel.Text = ((DateTime)cliente.vencimientoPuntos).ToShortDateString();
            }
        }
Пример #21
0
        private void insertarPublicacionEnDB(Empresa empre)
        {
            SqlTransaction transaction = DatabaseConection.getInstance().BeginTransaction();

            if (espectGenerado == false)
            {
                espec             = new Espectaculo();
                espec.descripcion = descripcionPublicacion;
                espec.direccion   = direccionPublicacion;
                espec.rubro       = rubro;
                espec.empresa     = empre;
                espectGenerado    = true;
                espec.id          = espectaculosDao.insertarEspectaculo(espec, transaction);
            }
            try
            {
                fechasDeLaPublicacion.ForEach(elem =>
                {
                    Publicacion publicacion      = new Publicacion();
                    publicacion.gradoPublicacion = gradoPublicacion;
                    publicacion.fechaEvento      = elem;
                    publicacion.fechaPublicacion = Generals.getFecha();
                    publicacion.estado           = Strings.ESTADO_BORRADOR;
                    publicacion.espectaculo      = espec;
                    publicacion.ubicaciones      = ubicacionesList;

                    controller.insertarPublicacionEnDB(publicacion, transaction);
                });
                transaction.Commit();
                MessageBox.Show("Se ha cargado la publicación");
                borrarFormulario();
                espectGenerado = false;
            }
            catch (SqlInsertException ex)
            {
                transaction.Rollback();
                MessageBox.Show("Ha ocurrido un error al intentar cargar la/s publicacion/es.");
            }
        }
Пример #22
0
 public Cliente getCliente()
 {
     if (getCamposRequeridos().Length == 0)
     {
         cli.nombre          = NombreCliente.Text;
         cli.apellido        = ApellidoCliente.Text;
         cli.mail            = MailCliente.Text;
         cli.documento       = DniCliente.Text.Trim();
         cli.telefono        = TelefonoCliente.Text;
         cli.cuil            = CuilCliente.Text.Trim();
         cli.direccion       = dirDelCliente;
         cli.fechaCreacion   = Generals.getFecha();
         cli.fechaNacimiento = FechaNacimientoCliente.Value;
         cli.TipoDocumento   = ListaTiposDocumento.SelectedItem.ToString();
         return(cli);
     }
     else
     {
         string mensaje = "Los siguientes campos son requeridos:\n\n" + getCamposRequeridos();
         MessageBox.Show(mensaje);
         return(null);
     }
 }
Пример #23
0
        public int getUlitimaPaginaNoFiltro(Nullable <int> empresaId = null)
        {
            string function = "SELECT [TheBigBangQuery].[getLastPaginaPublicacionesSinFiltro](@empresa,@fechaActual)";

            try
            {
                SqlCommand command = new SqlCommand(function);
                if (empresaId == null)
                {
                    command.Parameters.AddWithValue("@empresa", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@empresa", (int)empresaId);
                }
                command.Parameters.AddWithValue("@fechaActual", Generals.getFecha());
                return(DatabaseConection.executeParamFunction <int>(command));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #24
0
        private void DeshabilitarGradoButton_Click(object sender, EventArgs e)
        {
            try
            {
                GradosListView.Items[indexSeleccionado].ForeColor = gradoSeleccionado.bajaLogica == null ? Color.Gray : Color.Black;
                if (gradoSeleccionado.bajaLogica == null)
                {
                    gradoSeleccionado.bajaLogica = Generals.getFecha().Date;
                }
                else
                {
                    gradoSeleccionado.bajaLogica = null;
                }
                dao.habilitarODeshabilitarGrado(gradoSeleccionado);

                GradosListView.BeginUpdate();
                GradosListView.Items.RemoveAt(indexSeleccionado);
                GradosListView.Items.Insert(indexSeleccionado, getItemFromGrado(gradoSeleccionado));
                GradosListView.EndUpdate();
            }
            catch (Exception ex) {
                MessageBox.Show("Debe seleccionar algún grado de publicación para poder habilitarlo o deshabilitarlo");
            }
        }