public void GuardarArchivo(DetalleOrdenServicio detalle)
        {
            FileStream   fileStream = new FileStream(ruta, FileMode.Append);
            StreamWriter writer     = new StreamWriter(fileStream);

            writer.WriteLine(detalle.ToString());
            writer.Close();
            fileStream.Close();
        }
 public void Eliminar(DetalleOrdenServicio detalle)
 {
     using (var command = _connection.CreateCommand())
     {
         command.CommandText = "delete from DetalleOrden where CodigoDetalle=@CodigoDetalle";
         command.Parameters.AddWithValue("@CodigoDetalle", detalle.CodigoDetalle);
         command.ExecuteNonQuery();
     }
 }
 public void EliminarTodoDetalle(DetalleOrdenServicio detalle)
 {
     using (var command = _connection.CreateCommand())
     {
         command.CommandText = "delete from DetalleOrden where NumeroOrden=@NumeroOrden";
         command.Parameters.AddWithValue("@NumeroOrden", detalle.OrdenDeServicio.NumeroOrden);
         command.ExecuteNonQuery();
     }
 }
Example #4
0
 public string GuardarArchivo(DetalleOrdenServicio detalle)
 {
     try
     {
         repo.GuardarArchivo(detalle);
         return("El producto ha sido añadido al carrito con exito!");
     }
     catch (Exception e)
     {
         return("Error de Datos: " + e.Message);
     }
 }
 public void Guardar(DetalleOrdenServicio detalles)
 {
     using (var command = _connection.CreateCommand())
     {
         command.CommandText = "INSERT INTO DetalleOrden (CodigoDetalle, NumeroOrden, Codigo, ServicioProducto, Cantidad, Precio, SubTotal, IVA, Total)VALUES (@CodigoDetalle, @NumeroOrden, @Codigo, @ServicioProducto, @Cantidad, @Precio, @SubTotal, @IVA, @Total)";
         command.Parameters.AddWithValue("@CodigoDetalle", detalles.CodigoDetalle);
         command.Parameters.AddWithValue("@NumeroOrden", detalles.OrdenDeServicio.NumeroOrden);
         command.Parameters.AddWithValue("@Codigo", detalles.Producto.CodigoProducto);
         command.Parameters.AddWithValue("@ServicioProducto", detalles.Producto.NombreProducto);
         command.Parameters.AddWithValue("@Cantidad", detalles.Cantidad);
         command.Parameters.AddWithValue("@Precio", detalles.ValorUnitario);
         command.Parameters.AddWithValue("@SubTotal", detalles.SubTotal);
         command.Parameters.AddWithValue("@IVA", detalles.Producto.PorcentajeIVA);
         command.Parameters.AddWithValue("@Total", detalles.Total);
         command.ExecuteNonQuery();
     }
 }
 public void Modificar(DetalleOrdenServicio detalle)
 {
     using (var command = _connection.CreateCommand())
     {
         command.CommandText = "UPDATE DetalleOrden SET NumeroOrden = @NumeroOrden, Codigo = @Codigo, ServicioProducto = @ServicioProducto, Cantidad = @Cantidad, Precio = @Precio, SubTotal = @SubTotal, IVA = @IVA, Total = @Total WHERE CodigoDetalle = @CodigoDetalle";
         command.Parameters.AddWithValue("@CodigoDetalle", detalle.CodigoDetalle);
         command.Parameters.AddWithValue("@NumeroOrden", detalle.OrdenDeServicio.NumeroOrden);
         command.Parameters.AddWithValue("@Codigo", detalle.Producto.CodigoProducto);
         command.Parameters.AddWithValue("@ServicioProducto", detalle.Producto.NombreProducto);
         command.Parameters.AddWithValue("@Cantidad", detalle.Cantidad);
         command.Parameters.AddWithValue("@Precio", detalle.ValorUnitario);
         command.Parameters.AddWithValue("@SubTotal", detalle.SubTotal);
         command.Parameters.AddWithValue("@IVA", detalle.Producto.PorcentajeIVA);
         command.Parameters.AddWithValue("@Total", detalle.Total);
         command.ExecuteNonQuery();
     }
 }
        public List <DetalleOrdenServicio> Consultar()
        {
            SqlDataReader reader;
            List <DetalleOrdenServicio> detalles = new List <DetalleOrdenServicio>();

            using (var command = _connection.CreateCommand())
            {
                command.CommandText = "Select * from DetalleOrden";
                reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        DetalleOrdenServicio detalle = Mapear(reader);
                        detalles.Add(detalle);
                    }
                }
            }
            return(detalles);
        }
Example #8
0
        private DetalleOrdenServicio MapearDetalles()
        {
            detalleOrden = new DetalleOrdenServicio();

            detalleOrden.Producto                    = producto;
            detalleOrden.OrdenDeServicio             = servi;
            detalleOrden.CodigoDetalle               = TxtCodigoDetalle.Text.Trim();
            detalleOrden.OrdenDeServicio.NumeroOrden = TxtNumeroOrden.Text.Trim();
            detalleOrden.Producto.CodigoProducto     = TxtCodigoProducto.Text;
            detalleOrden.Producto.NombreProducto     = TxtServicioProducto.Text;
            detalleOrden.ValorUnitario               = float.Parse(TxtPrecio.Text);
            detalleOrden.Cantidad                    = float.Parse(TxtCantidad.Text);
            detalleOrden.SubTotal                    = detalleOrden.CalcularSubtotal();
            detalleOrden.Producto.PorcentajeIVA      = float.Parse(TxtIva.Text);
            detalleOrden.Total = detalleOrden.Calculartotal();
            TxtTotal.Text      = detalleOrden.Total.ToString();
            TxtSubTotal.Text   = detalleOrden.SubTotal.ToString();

            return(detalleOrden);
        }
        private DetalleOrdenServicio Mapear(SqlDataReader reader)
        {
            if (!reader.HasRows)
            {
                return(null);
            }
            DetalleOrdenServicio detalle = new DetalleOrdenServicio();

            detalle.CodigoDetalle = (string)reader["CodigoDetalle"];
            detalle.OrdenDeServicio.NumeroOrden = (string)reader["NumeroOrden"];
            detalle.Producto.CodigoProducto     = (string)reader["Codigo"];
            detalle.Producto.NombreProducto     = (string)reader["ServicioProducto"];
            detalle.Producto.Cantidad           = float.Parse(reader["Cantidad"].ToString());
            detalle.Producto.Precio             = float.Parse(reader["Precio"].ToString());
            detalle.Producto.SubTotal           = float.Parse(reader["SubTotal"].ToString());
            detalle.Producto.PorcentajeIVA      = float.Parse(reader["IVA"].ToString());
            detalle.Producto.Total = float.Parse(reader["Total"].ToString());


            return(detalle);
        }
Example #10
0
 public string Modificar(DetalleOrdenServicio detalleorden)
 {
     try
     {
         conexion.Open();
         var detalleviejo = repository.Buscar(detalleorden.CodigoDetalle);
         if (detalleviejo != null)
         {
             repository.Modificar(detalleorden);
             conexion.Close();
             return($"El producto {detalleorden.Producto.NombreProducto} se ha actualizado satisfactoriamente.");
         }
         else
         {
             return($"Lo sentimos, {detalleorden.CodigoDetalle} no se encuentro el producto.");
         }
     }
     catch (Exception e)
     {
         return($"Error de la Aplicación: {e.Message}");
     }
     finally { conexion.Close(); }
 }
Example #11
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            DetalleOrdenServicioService service = new DetalleOrdenServicioService();
            DetalleOrdenServicio        detalle = MapearDetalles();

            AñadirATabla();
            string mensaje = service.GuardarArchivo(detalle);

            MessageBox.Show(mensaje, "Mensaje de confirmación", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            LimpiarCajas();
            double total    = 0;
            double subtotal = 0;

            foreach (DataGridViewRow row in DgvDetalleServicio.Rows)
            {
                total    += Convert.ToDouble(row.Cells["Total"].Value);
                subtotal += Convert.ToDouble(row.Cells["SubTotal"].Value);
            }
            TxtTotalOrden.Text    = Convert.ToString(total);
            TxtSubTotalOrden.Text = Convert.ToString(subtotal);

            TxtDeuda.Text = Convert.ToString(total);
        }
Example #12
0
        private void Actualizar()
        {
            var respuesta = MessageBox.Show("¿Está seguro de actualizar el producto?", "Mensaje de actualización", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (respuesta == DialogResult.Yes)
            {
                DetalleOrdenServicio detalle = MapearDetalles();
                string mensaje = detalleService.Modificar(detalle);
                MessageBox.Show(mensaje, "Actualizar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DgvDetalleServicio.Rows.Remove(DgvDetalleServicio.CurrentRow);
                AñadirATabla();
                double total    = 0;
                double subtotal = 0;

                foreach (DataGridViewRow row in DgvDetalleServicio.Rows)
                {
                    total    += Convert.ToDouble(row.Cells["Total"].Value);
                    subtotal += Convert.ToDouble(row.Cells["SubTotal"].Value);
                }
                TxtTotalOrden.Text    = Convert.ToString(total);
                TxtSubTotalOrden.Text = Convert.ToString(subtotal);
                LimpiarCajas();
            }
        }
Example #13
0
        public FrmOrdenServicio()
        {
            InitializeComponent();

            var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            service         = new OrdenServicioService(connectionString);
            productoService = new ProductoService(connectionString);
            detalleService  = new DetalleOrdenServicioService(connectionString);
            servi           = new OrdenDeServicio();
            producto        = new Producto();
            detalleOrden    = new DetalleOrdenServicio();
            orden           = new OrdenDeServicio();
            DgvDetalleServicio.AllowUserToAddRows = false;
            DgvDetalleServicio.ColumnCount        = 8;
            DgvDetalleServicio.Columns[0].Name    = "CodigoDetalle";
            DgvDetalleServicio.Columns[1].Name    = "CodigoProducto";
            DgvDetalleServicio.Columns[2].Name    = "Nombre";
            DgvDetalleServicio.Columns[3].Name    = "Cantidad";
            DgvDetalleServicio.Columns[4].Name    = "Precio";
            DgvDetalleServicio.Columns[5].Name    = "SubTotal";
            DgvDetalleServicio.Columns[6].Name    = "Porcentaje IVA";
            DgvDetalleServicio.Columns[7].Name    = "Total";
        }