public static void eliminarFactura(int id) { factura fact = new factura(); fact.idfactura = id; CatalogoFacturas.removeFactura(fact); }
public static bool agregarFacturaExtraordinaria(edificio edificio, unidad unidad, string ID, DateTime fecha, object Provedor, object TipoGasto, object Sector) { factura fact = new factura(); fact.dir_edificio = edificio.direccion; fact.id_unidad = unidad.id_unidad; fact.numero_factura = ID; fact.fecha = fecha; fact.razon_provedor = ((provedor)Provedor).razon_social; fact.id_tipogasto = ((tipo_gasto)TipoGasto).idtipo_gasto; fact.id_sector = ((sector)Sector).idsector; CatalogoFacturas.addFactura(fact); return true; }
public static void addFactura(factura fact) { try { admEntities db = Datos.getDB(); db.factura.Add(fact); db.SaveChanges(); } catch (Exception e) { Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message); throw e; } }
public static void agregarFactura(edificio edificio, string numeroFactura, DateTime fecha, object Provedor, object TipoGasto, object Sector, string detalle, string importe) { factura fact = new factura(); fact.dir_edificio = edificio.direccion; fact.numero_factura = numeroFactura; fact.fecha = fecha; fact.importe = double.Parse(importe); fact.detalle = detalle; if (((provedor)Provedor).razon_social != "Ninguno") { fact.razon_provedor = ((provedor)Provedor).razon_social; } fact.id_tipogasto = ((tipo_gasto)TipoGasto).idtipo_gasto; fact.id_sector = ((sector)Sector).idsector; CatalogoFacturas.addFactura(fact); }
public static void addFacturas(List<FactUI> facturas, string edificio, DateTime periodo) { try { admEntities db = Datos.getDB(); //List<factura> facturasExistentes = db.factura.ToList(); //foreach (FactUI f in facturas) //{ // bool update = false; // foreach (factura fEx in facturasExistentes) // { // if (f.id != null) // { // if (fEx.idfactura == int.Parse(f.id)) // { // fEx.detalle = f.detalle; // fEx.fecha = DateTime.Parse(f.fecha); // fEx.id_sector = f.sector.idsector; // fEx.id_tipogasto = f.gasto.idtipo_gasto; // fEx.importe = double.Parse(f.importe); // fEx.numero_factura = f.nroFactura; // if (f.provedor != null) // fEx.razon_provedor = f.provedor.razon_social; // db.Entry(fEx).State = System.Data.EntityState.Modified; // update = true; // break; // } // } // } // if (update == false) // { // factura fact = new factura(); // fact.dir_edificio = f.edificio; // fact.fecha = DateTime.Parse(f.fecha); // fact.id_sector = f.sector.idsector; // fact.id_tipogasto = f.gasto.idtipo_gasto; // fact.importe = double.Parse(f.importe); // fact.numero_factura = f.nroFactura; // if (f.provedor != null) // fact.razon_provedor = f.provedor.razon_social; // fact.detalle = f.detalle; // db.factura.Add(fact); // } //} List<factura> facturasExistentes = db.factura.Where(x => x.dir_edificio == edificio && x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year).ToList(); foreach (factura f in facturasExistentes) db.factura.Remove(f); if (facturas.First().sector == null) { db.SaveChanges(); return; } foreach (FactUI f in facturas) { factura fact = new factura(); fact.dir_edificio = f.edificio; fact.fecha = DateTime.Parse(f.fecha); fact.id_sector = f.sector.idsector; fact.id_tipogasto = f.gasto.idtipo_gasto; fact.importe = double.Parse(f.importe); fact.numero_factura = f.nroFactura; if (f.provedor != null) fact.razon_provedor = f.provedor.razon_social; fact.detalle = f.detalle; db.factura.Add(fact); } db.SaveChanges(); } catch (Exception e) { Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message); throw e; } }
public static void removeFactura(factura fact) { try { admEntities db = Datos.getDB(); var f = db.factura.SingleOrDefault(x => x.idfactura == fact.idfactura); if (f != null) { db.factura.Remove(f); db.SaveChanges(); } } catch (Exception e) { Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message); throw e; } }