public VNotificacionDetalle(DataGridViewRow row)
 {
     InitializeComponent();
     FechaVencimientoLabel.Text = row.Cells[0].Value.ToString();
     DescripcionLabel.Text      = row.Cells[1].Value.ToString();
     if (row.Cells[3].Value.ToString() != "0") //Lote
     {
         NumeroLoteOPresupuestoLabel.Text = row.Cells[3].Value.ToString();
         LoteDTO lote = controladorFachada.BuscarLote(Convert.ToInt32(row.Cells[3].Value));
         FechaCompraLabel.Text          = lote.FechaCompra.ToString();
         CantidadLabel.Text             = lote.CantidadProductos.ToString();
         ProductoLabel.Text             = lote.NombreProducto;
         AdministrarPresupuesto.Visible = false;
     }
     else if (row.Cells[2].Value.ToString() != "0") //Presupuesto
     {
         NumeroLoteOPresupuestoLabel.Text = row.Cells[2].Value.ToString();
         PresupuestoDTO pres = controladorFachada.BuscarPresupuestoDTO(Convert.ToInt32(row.Cells[2].Value));
         FechaCompraLabel.Text = pres.FechaGeneracion.ToString();
         NumeroLote.Text       = "Numero Presupuesto";
         FechaCompra.Text      = "Fecha de Creación";
         Producto.Visible      = false;
         ProductoLabel.Visible = false;
         Cantidad.Visible      = false;
         CantidadLabel.Visible = false;
         EliminarLote.Visible  = false;
     }
 }
Beispiel #2
0
        private void Administrar_Click(object sender, EventArgs e)
        {
            Boolean        seleccion      = false;
            PresupuestoDTO presupuestoDTO = new PresupuestoDTO();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                bool isSelected = Convert.ToBoolean(row.Cells["Cb"].Value);
                if (isSelected)
                {
                    seleccion         = true;
                    presupuestoDTO.Id = Convert.ToInt32(row.Cells[1].Value);
                    presupuestoDTO.FechaGeneracion  = Convert.ToDateTime(row.Cells[2].Value);
                    presupuestoDTO.FechaVencimiento = Convert.ToDateTime(row.Cells[3].Value);
                    presupuestoDTO.IdCliente        = Convert.ToInt32(row.Cells[4].Value);
                    presupuestoDTO.Estado           = row.Cells[5].Value.ToString();
                    presupuestoDTO.Descuento        = Convert.ToDouble(row.Cells[7].Value);
                    presupuestoDTO.Observacion      = row.Cells[8].Value.ToString();
                }
            }
            if (seleccion)
            {
                this.Hide();
                VAdministrarPresupuesto vAdministrarPresupuesto = new VAdministrarPresupuesto(presupuestoDTO);
                vAdministrarPresupuesto.ShowDialog();
                this.Close();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Método que permite agregar un presupuesto pasando sus parámetros para crearlo y guardarlo en db.
 /// </summary>
 /// <param name="presupuesto"></param>
 public int AgregarModificarPresupuesto(PresupuestoDTO pPrespuestoDTO)
 {
     using (var repo = new Repositorio())
     {
         Presupuesto pres         = repo.Presupuestos.Find(pPrespuestoDTO.Id);
         Presupuesto presAAgregar = this.DTOAPresupuesto(pPrespuestoDTO);
         Cliente     cli          = repo.Clientes.Find(pPrespuestoDTO.IdCliente);
         presAAgregar.Cliente = cli;
         if (pres == null)  // Crear presupuesto (si no existe)
         {
             presAAgregar.Estado = EstadoPresupuesto.Presupuestado;
             repo.Presupuestos.Add(presAAgregar);
             repo.SaveChanges();
             return(presAAgregar.Id);
         }
         else  // Modificar Presupuesto (si existe)
         {
             pres.FechaEntrega     = presAAgregar.FechaEntrega;
             pres.FechaEvento      = presAAgregar.FechaEvento;
             pres.FechaVencimiento = presAAgregar.FechaVencimiento;
             pres.FechaGeneracion  = presAAgregar.FechaGeneracion;
             pres.Descuento        = presAAgregar.Descuento;
             pres.Observacion      = presAAgregar.Observacion;
             repo.SaveChanges();
             return(pres.Id);
         }
     }
 }
        /// <summary>
        /// El primer elemento de la tupla indica el idPresupuesto, el segundo indica si se guardó correctamente
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private Tuple <int, Boolean> GuardarPresupuesto(object sender, EventArgs e)
        {
            Boolean Guardado      = false;
            Boolean errorCantidad = false;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells[2].Value.ToString() == "0" && !errorCantidad)
                {
                    errorCantidad = true;
                }
            }


            if (IdCliente == 0)
            {
                MessageBox.Show("Debe seleccionar un cliente");
            }
            else if (dataGridView1.Rows.Count < 1)
            {
                MessageBox.Show("Debe seleccionar al menos un producto");
            }
            else if (errorCantidad)
            {
                MessageBox.Show("Hay al menos un producto que tiene cantidad 0, modifiquelo");
            }
            else if (FechaVencimiento.Date < DateTime.Now.Date)
            {
                MessageBox.Show("Debe seleccionar una fecha de Vencimiento posterior a la seleccionada");
            }
            else if (DescuentoTotal.Text == "")
            {
                DescuentoTotal.Text = "0";
            }
            else
            {
                PresupuestoDTO pre = new PresupuestoDTO();
                pre.FechaGeneracion  = DateTime.Now;
                pre.IdCliente        = IdCliente;
                pre.FechaVencimiento = FechaVencimiento;
                pre.Id          = IdPresupuesto;
                pre.Descuento   = Convert.ToDouble(DescuentoTotal.Text);
                pre.Observacion = Observacion.Text;
                IdPresupuesto   = controladorFachada.AgregarModificarPresupuesto(pre);

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    LineaPresupuestoDTO lin = new LineaPresupuestoDTO();
                    lin.Cantidad            = int.Parse(row.Cells[2].Value.ToString());
                    lin.IdPresupuesto       = IdPresupuesto;
                    lin.IdProducto          = int.Parse(row.Cells[0].Value.ToString());
                    lin.PorcentajeDescuento = double.Parse(row.Cells[4].Value.ToString());
                    lin.Subtotal            = double.Parse(row.Cells[5].Value.ToString());
                    controladorFachada.AgregarLinea(lin);
                }
                Guardado = true;
            }
            return(Tuple.Create(IdPresupuesto, Guardado));
        }
 public VAdministrarPresupuesto(PresupuestoDTO pPresupuestoDTO)
 {
     IdProductos      = new List <int>();
     Filas            = new DataGridView();
     Presupuesto      = pPresupuestoDTO;
     IdCliente        = pPresupuestoDTO.IdCliente;
     FechaVencimiento = pPresupuestoDTO.FechaVencimiento;
     Descuento        = pPresupuestoDTO.Descuento.ToString();
     PObservacion     = pPresupuestoDTO.Observacion;
     IdPresupuesto    = pPresupuestoDTO.Id;
     Notificacion     = false;
     InitializeComponent();
 }
 public VAdministrarPresupuesto(int pIdPresupuesto)
 {
     IdProductos      = new List <int>();
     Filas            = new DataGridView();
     Presupuesto      = controladorFachada.BuscarPresupuestoDTO(pIdPresupuesto);
     IdCliente        = Presupuesto.IdCliente;
     FechaVencimiento = Presupuesto.FechaVencimiento;
     Descuento        = Presupuesto.Descuento.ToString();
     IdPresupuesto    = Presupuesto.Id;
     PObservacion     = Presupuesto.Observacion;
     Notificacion     = true;
     InitializeComponent();
 }
Beispiel #7
0
        // [TestMethod]
        public void TestAgregarPresupuesto()
        {
            PresupuestoDTO pres = new PresupuestoDTO();

            pres.Id = 12;
            pres.FechaGeneracion  = DateTime.Now;
            pres.FechaVencimiento = new DateTime(2021, 5, 3);
            pres.Estado           = "activo";
            pres.IdCliente        = 1;

            ControladorPresupuesto cont = new ControladorPresupuesto();

            Console.WriteLine("Id del presupuesto agregado es: " + cont.AgregarModificarPresupuesto(pres));
        }
Beispiel #8
0
        private PresupuestoDTO PresupuestoADTO(Presupuesto pre)
        {
            PresupuestoDTO pDTO = new PresupuestoDTO();

            pDTO.Id = pre.Id;
            pDTO.FechaGeneracion  = pre.FechaGeneracion;
            pDTO.FechaVencimiento = pre.FechaVencimiento;
            pDTO.Estado           = pre.Estado;
            pDTO.IdCliente        = pre.Cliente.Id;
            pDTO.Descuento        = pre.Descuento;
            pDTO.Cliente          = pre.Cliente.Nombre + " " + pre.Cliente.Apellido;
            pDTO.Observacion      = pre.Observacion;
            return(pDTO);
        }
Beispiel #9
0
        public PresupuestoDTO BuscarPresupuestoDTO(int pIdPresupuesto)
        {
            Presupuesto    presupuesto = this.BuscarPresupuesto(pIdPresupuesto);
            PresupuestoDTO pres        = new PresupuestoDTO();

            pres.Id               = presupuesto.Id;
            pres.IdCliente        = presupuesto.Cliente.Id;
            pres.Estado           = presupuesto.Estado;
            pres.Descuento        = presupuesto.Descuento;
            pres.FechaGeneracion  = presupuesto.FechaGeneracion;
            pres.FechaVencimiento = presupuesto.FechaVencimiento;
            pres.Cliente          = presupuesto.Cliente.Nombre;
            return(pres);
        }
Beispiel #10
0
        /// <summary>
        /// Este método permite listar todos los presupuestos guardados en BD.
        /// </summary>
        /// <returns></returns>
        public List <PresupuestoDTO> ListarPresupuesto()
        {
            List <Presupuesto>    presupuestos    = new List <Presupuesto>();
            List <PresupuestoDTO> presupuestoDTOs = new List <PresupuestoDTO>();

            using (var repo = new Repositorio())
            {
                presupuestos = repo.Presupuestos.Include("Cliente").OrderByDescending(p => p.Estado == "Presupuestado").ThenByDescending(p => p.Estado == "Seniado").ThenByDescending(p => p.Estado).ThenBy(p => p.Id).ToList();
            }
            foreach (Presupuesto pre in presupuestos)
            {
                PresupuestoDTO pDTO = this.PresupuestoADTO(pre);
                presupuestoDTOs.Add(pDTO);
            }
            return(presupuestoDTOs);
        }
Beispiel #11
0
        public Presupuesto DTOAPresupuesto(PresupuestoDTO pPresupuesto)
        {
            Presupuesto pres = new Presupuesto();
            Repositorio repo = new Repositorio();

            pres.Id = pPresupuesto.Id;
            pres.FechaGeneracion  = pPresupuesto.FechaGeneracion;
            pres.FechaVencimiento = pPresupuesto.FechaVencimiento;
            pres.Descuento        = pPresupuesto.Descuento;
            pres.Observacion      = pPresupuesto.Observacion;
            Cliente cliente = repo.Clientes.Find(pPresupuesto.IdCliente);

            if (cliente == null)
            {
                throw new Exception("Id " + pPresupuesto.IdCliente + " no existe en Clientes");
            }
            pres.Cliente = cliente;
            return(pres);
        }
Beispiel #12
0
        private void buscar_TextChanged(object sender, EventArgs e)
        {
            List <PresupuestoDTO> listaPresupuesto = new List <PresupuestoDTO>();

            if (Listas.Text == Listas.Items[0].ToString())
            {
                //Todos
                listaPresupuesto = controladorFachada.ListarPresupuesto();
            }
            else if (Listas.Text == Listas.Items[1].ToString())
            {
                //Presupuestados
                listaPresupuesto = controladorFachada.ListarPresupuestoPresupuestados();
            }
            else if (Listas.Text == Listas.Items[2].ToString())
            {
                //Señados
                listaPresupuesto = controladorFachada.ListarPresupuestoSeniados();
            }
            else if (Listas.Text == Listas.Items[3].ToString())
            {
                //Vendidos
                listaPresupuesto = controladorFachada.ListarPresupuestoVendidos();
            }
            else
            {
                //Cancelados
                listaPresupuesto = controladorFachada.ListarPresupuestoCancelados();
            }
            try
            {
                var consultaNombreyApellido = from presupuesto in listaPresupuesto where presupuesto.Cliente.ToLower().StartsWith(this.buscar.Text.Trim().ToLower()) select presupuesto;
                var consultaFechaCreacion   = from presupuesto in listaPresupuesto where presupuesto.FechaGeneracion.ToString().StartsWith(this.buscar.Text.Trim().ToLower()) select presupuesto;


                dataGridView1.DataSource = null;
                dataGridView1.Rows.Clear();


                List <PresupuestoDTO> HelpList = new List <PresupuestoDTO>();
                List <PresupuestoDTO> distinct = (consultaNombreyApellido.Concat(consultaFechaCreacion)).GroupBy(p => p.Id).Select(g => g.First()).ToList();

                foreach (var presupuesto in distinct)
                {
                    PresupuestoDTO pres = new PresupuestoDTO()
                    {
                        Id = presupuesto.Id,
                        FechaGeneracion  = presupuesto.FechaGeneracion,
                        Cliente          = presupuesto.Cliente,
                        Descuento        = presupuesto.Descuento,
                        Estado           = presupuesto.Estado,
                        FechaVencimiento = presupuesto.FechaVencimiento,
                        IdCliente        = presupuesto.IdCliente
                    };
                    HelpList.Add(pres);
                }

                dataGridView1.DataSource         = HelpList;
                dataGridView1.Columns[7].Visible = false;

                /*dataGridView1.Columns[0].Width = 25; //CB
                 * dataGridView1.Columns[1].Width = 35; //ID
                 * dataGridView1.Columns[9].Visible = false; //No se ve la columna ACTIVO
                 * dataGridView1.Columns[11].Visible = false; //No se ve la columna CATEGORIAPRODUCTODTO
                 * dataGridView1.Columns[10].Visible = false; //No se ve la columna IDCATEGORIAPRODUCTO
                 * dataGridView1.Columns[8].Visible = false; //No se ve la columna PrecioVenta
                 */
            }


            catch
            {
                throw;
            }
        }
Beispiel #13
0
 /// <summary>
 /// Método que permite agregar un presupuesto pasando sus parámetros para crearlo y guardarlo en db.
 /// </summary>
 /// <param name="presupuesto"></param>
 public int AgregarModificarPresupuesto(PresupuestoDTO pPresupuesotDTO)
 {
     return(controladorPresupuesto.AgregarModificarPresupuesto(pPresupuesotDTO));
 }