public static FacturaResponse EditarFactura(FacturaModel request) { var mensajes = new List <Mensaje>(); try { // No tiene errores if (mensajes.Count == 0) { Factura factura = ConfigAutomapper.mapper.Map <Factura>(request); FacturaAccess.EditarFactura(factura); FacturaModel facturaModel = ConfigAutomapper.mapper.Map <FacturaModel>(factura); mensajes.Add(new Mensaje("1", "Registro Modificado Correctamente")); return(new FacturaResponse(facturaModel, true, mensajes)); } else { return(new FacturaResponse(null, false, mensajes)); } } catch (Exception ex) { //Captura de errores mensajes.Add(new Mensaje("Error", ex.Message)); return(new FacturaResponse(null, false, mensajes)); } }
public JsonResult ActualizarFactura(FacturaModel factura) { List <bool> ingresado = new List <bool>(); ingresado.Add(this.facturaBDD.ActualizarFactura(factura)); return(Json(ingresado)); }
public ActionResult WSFactura() { var config = new MapperConfiguration(cfg => { cfg.CreateMap <t_Tipo, TipoModel>(); }); List <FacturaModel> modelList = new List <FacturaModel>(); IMapper iMapper = config.CreateMapper(); COMPUTERMANAGEMENT_TestEntities _context = new COMPUTERMANAGEMENT_TestEntities(); List <t_Factura> usuariosT = new List <t_Factura>(); usuariosT = _context.t_Factura.ToList(); foreach (t_Factura userActual in usuariosT) { FacturaModel factM = new FacturaModel(); ProveedorModel provM = new ProveedorModel(); provM.IdProveedor = userActual.t_Proveedor.IdProveedor; provM.Proveedor = userActual.t_Proveedor.Proveedor; factM.IdFactura = userActual.IdFactura; factM.Factura = userActual.Factura; factM.Fecha = userActual.Fecha; factM.Garantia = userActual.Garantia; factM.ProveedorM = provM; modelList.Add(factM); } return(Json(modelList, JsonRequestBehavior.AllowGet)); }
public void GenerateInvoice() { var shipping = GenerateShipping(); FacturaModel fact = new FacturaModel(); fact.NIT = "900.656.261.6"; fact.RazonSocial = "TCC S.A.S"; fact.Model = shipping; List <FacturaModel> ord = new List <FacturaModel>(); ord.Add(fact); Factura xtrareport = new Factura(); PdfExportOptions opts = new PdfExportOptions(); try { xtrareport.DataSource = ord; string path = @"C:\Kiosko\temp\test.pdf"; xtrareport.ExportToPdf(path); xtrareport.CreateDocument(false); } catch (Exception e) { } }
public HttpResponseMessage EliminarFacturaProducto([FromBody] FacturaModel request) { var response = FacturaServices.EliminarFacturaProducto(request); HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK, response); return(result); }
public void Fill() { string numeroF = da.Query <string>("select max(reservacionID) + 1 as UltimoID from Reservaciones").SingleOrDefault(); txtNuevaFactura.Text = $"Reservacion #{numeroF}"; datePicker.SelectedDate = DateTime.Now.Date; lbUser.Content = Usuario.Fullname; lbCliente.Content = Cliente.Fullname; Lineas.Clear(); int index = 1; decimal total = 0m; foreach (var rd in Detalles) { FacturaDetalle = new FacturaModel(); FacturaDetalle.Linea = rd; FacturaDetalle.Numero = index; total += rd.Total; Lineas.Add(FacturaDetalle); index++; } lbTotal.Content = total.ToString("C2"); dgNuevaFactura.ItemsSource = Lineas; }
public ActionResult Index() { COMPUTERMANAGEMENT_TestEntities _context = new COMPUTERMANAGEMENT_TestEntities(); List <t_Producto> productoList = new List <t_Producto>(); productoList = _context.t_Producto.ToList(); List <ProductoModel> productoMList = new List <ProductoModel>(); foreach (var element in productoList) { ProductoModel productoActual = new ProductoModel(); TipoModel tipo = new TipoModel(); MarcaModel marca = new MarcaModel(); SistemaOModel sistema = new SistemaOModel(); FacturaModel factura = new FacturaModel(); tipo.Tipo = element.t_Tipo.Tipo.ToString(); marca.Marca = element.t_Marca.Marca.ToString(); sistema.SistemaO = element.t_SistemaO.SistemaO.ToString(); factura.Factura = element.t_Factura.Factura.ToString(); productoActual.Marca = marca; productoActual.Factura = factura; productoActual.Tipo = tipo; productoActual.SistemaO = sistema; productoActual.Modelo = element.Modelo; productoActual.IdProducto = element.IdProducto; productoMList.Add(productoActual); } return(View(productoMList)); }
public async Task <IActionResult> PutFacturaModel(int id, FacturaModel facturaModel) { if (id != facturaModel.IdFactura) { return(BadRequest()); } _context.Entry(facturaModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FacturaModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Factura(FacturaModel model) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <FacturaModel, t_Factura>(); }); IMapper iMapper = config.CreateMapper(); var source = model; var destination = iMapper.Map <FacturaModel, t_Factura>(source); COMPUTERMANAGEMENT_TestEntities _context = new COMPUTERMANAGEMENT_TestEntities(); var addfactura = _context.t_Factura.Add(destination); _context.SaveChanges(); List <FacturaModel> modelList = new List <FacturaModel>(); var data = _context.t_Factura.ToList(); foreach (t_Factura facturaActual in data) { FacturaModel facturaM = new FacturaModel(); ProveedorModel proveedorM = new ProveedorModel(); proveedorM.IdProveedor = facturaActual.t_Proveedor.IdProveedor; proveedorM.Proveedor = facturaActual.t_Proveedor.Proveedor; facturaM.IdFactura = facturaActual.IdFactura; facturaM.Factura = facturaActual.Factura; facturaM.Fecha = facturaActual.Fecha; facturaM.Garantia = facturaActual.Garantia; facturaM.ProveedorM = proveedorM; modelList.Add(facturaM); } return(View("FacturaList", modelList)); }
public void AddFactura(FacturaModel model) { var baseAddress = "http://localhost:8090/factura/agregarfactura"; model.productos = new List <ProductoModel>(); var json = JsonConvert.SerializeObject(model); json = json.Replace("\"[]\"", "[]"); var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress)); http.Accept = "application/json"; http.ContentType = "application/json"; http.Method = "POST"; string parsedContent = json; ASCIIEncoding encoding = new ASCIIEncoding(); Byte[] bytes = encoding.GetBytes(parsedContent); Stream newStream = http.GetRequestStream(); newStream.Write(bytes, 0, bytes.Length); newStream.Close(); var response = http.GetResponse(); var stream = response.GetResponseStream(); var sr = new StreamReader(stream); var content = sr.ReadToEnd(); }
public FacturaModel GetFactura(Int32 FacturaId) { var baseAddress = "http://localhost:8090/factura/listarfactura"; var json = "{\"referenciaPago\": " + FacturaId + "}"; var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress)); http.Accept = "application/json"; http.ContentType = "application/json"; http.Method = "POST"; string parsedContent = json; ASCIIEncoding encoding = new ASCIIEncoding(); Byte[] bytes = encoding.GetBytes(parsedContent); Stream newStream = http.GetRequestStream(); newStream.Write(bytes, 0, bytes.Length); newStream.Close(); var response = http.GetResponse(); var stream = response.GetResponseStream(); var sr = new StreamReader(stream); var content = sr.ReadToEnd(); content = content.Replace("[]", "\"\""); FacturaModel list = JsonConvert.DeserializeObject <FacturaModel>(content); return(list); }
public async Task <ActionResult <FacturaModel> > PostFacturaModel(FacturaModel facturaModel) { _context.Facturas.Add(facturaModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFacturaModel", new { id = facturaModel.IdFactura }, facturaModel)); }
public bool ActualizarFactura(FacturaModel factura) { bool ingresado = false; int resultado = 0; if (factura.ClienteID == 0) { ClienteModel cliente = new ClienteModel(); cliente.NombreCliente = factura.NombreCliente; cliente.CedulaCliente = factura.CedulaCliente; cliente.DireccionCliente = factura.DireccionCliente; cliente.TelefonoCliente = factura.TelefonoCliente; this.IngresarCliente(cliente); cliente = this.ConsultarCliente(factura.CedulaCliente); factura.ClienteID = cliente.ClienteID; } string sentenciaSql = "UPDATE Factura " + "SET FechaFactura = @FechaFactura, SubTotal = @SubTotal, Total = @Total, ClienteID = @ClienteID " + "WHERE FacturaID = @FacturaID "; SqlCommand sentenciaSQL = new SqlCommand(sentenciaSql); sentenciaSQL.Parameters.AddWithValue("@FechaFactura", factura.FechaEmision.Date); sentenciaSQL.Parameters.AddWithValue("@SubTotal", factura.Subtotal); sentenciaSQL.Parameters.AddWithValue("@Total", factura.Total); sentenciaSQL.Parameters.AddWithValue("@ClienteID", factura.ClienteID); sentenciaSQL.Parameters.AddWithValue("@FacturaID", factura.FacturaID); resultado = this.conexion.ComandoModificacion(sentenciaSQL); if (resultado > 0) { List <ParametroModel> listaParametroResultado = informacionGeneral.ObtenerInformacionParametro("finNumFactura"); int numeroFacturaEntero = Int32.Parse(listaParametroResultado[0].Valor) + 1; sentenciaSql = "UPDATE Parametro " + "SET Valor = @Valor " + "WHERE ParametroID = @ParametroID "; sentenciaSQL = new SqlCommand(sentenciaSql); sentenciaSQL.Parameters.AddWithValue("@Valor", numeroFacturaEntero.ToString("D9")); sentenciaSQL.Parameters.AddWithValue("@ParametroID", listaParametroResultado[0].Identificador); resultado = this.conexion.ComandoModificacion(sentenciaSQL); if (resultado > 0) { ingresado = true; } } return(ingresado); }
public async Task <FacturaEntity> PostFacturaAsync(FacturaModel model) { var factura = this._dbContext.Set <FacturaEntity>().Add(this._mapper.Map <FacturaEntity>(model)); await this._dbContext.SaveChangesAsync(); return(factura.Entity); }
public ActionResult Create() { var model = new FacturaModel(); ViewData["Action"] = "Crear Factura"; ViewData["Btn"] = "Crear"; return(PartialView("Edit", model)); }
public async Task <IHttpActionResult> GetFactura(int id) { FacturaModel factura = await _facturasService.GetFactura(id); if (factura == null) { return(NotFound()); } return(Ok(factura)); }
public ActionResult Edit(FacturaModel factura) { RestClient restClient = new RestClient(ConfigurationManager.AppSettings["URLBackend"] + "api/Factura"); RestRequest request = new RestRequest(Method.PUT); request.AddHeader("Content-Type", "application/json"); request.AddJsonBody(factura); var response = restClient.Execute(request); return(RedirectToAction("Index")); }
public ActionResult ImprimirFactura(FacturaDTO miFactura) { //Buscamos la factura en la base: FacturaDTO unaFactura = logicaFactura.BuscarFactura(miFactura.numeroFactura); //Convertimos la FacturaDTO a Facturamodel con el metodo en HerramientasM //Este metodo tambien agregara la descripcion del producto y el nombre del cliente (info importante a la hora de listar) FacturaModel unaFacturaModel = HerramientasM.ConvertirAFacturaModel(unaFactura); //Retornamos la vista parcial: return(View("_ImprimirFactura", unaFacturaModel)); }
private void OnAdaugaFacturaPressed(object sender, EventArgs e) { FacturaModel FModel = new FacturaModel(View.SumaTotala, View.DirectieFactura, View.FacturaAchitata, 0); if (Service.ExecuteInsertFacturaProcedure(FModel, View.Client_Ales_int, View.Contract_Ales_int, View.DataScadenta)) { View.FacturaAdaugataSuccessfull(); } else { View.FacturaAdaugataFailed(); } }
public IActionResult Post([FromBody] FacturaModel model) { ApiResponse <bool> response = new ApiResponse <bool>(); if (facturaService.Registrar(model)) { response.Codigo = Models.Common.CodigoRespuestaEnum.Ok; } else { response.Codigo = Models.Common.CodigoRespuestaEnum.Error; response.Mensaje = "Error al registra la venta"; } return(Ok(response)); }
public JsonResult Crear(FacturaModel fm) { Factura fc = new Factura(); fc.Cantidad = fm.Cantidad; fc.Total = fm.Total; fc.IdFactura = fm.IdFactura * 2; fc.IdProducto = fm.IdProducto; Model1 CE = new Model1(); CE.Factura.Add(fc); CE.SaveChanges(); return(Json(new { OK = "OK" })); }
public static List <FacturaModel> ListaFacturaModel(List <FacturaDTO> unaLista) { /*Este metodo convierte una lista de FacturaDTO en FacturaModel*/ //Creamos la lista resultado List <FacturaModel> resultado = new List <FacturaModel>(); //Para cada FacturaDTO foreach (FacturaDTO unaFactura in unaLista) { //Creamos una FacturaModel y le cargamos los datos FacturaModel miFactura = new FacturaModel() { NumeroFactura = unaFactura.numeroFactura, NumeroCliente = unaFactura.NumeroCliente, Fecha = unaFactura.Fecha, Total = unaFactura.Total, NickUsuario = unaFactura.NickUsuario, //Mostramos a la hora del detalle o del listado el nombre del cliente NombreCliente = NombreCliente(unaFactura.NumeroCliente), ListaDetalle = new List <DetalleFacturaModel>() }; //Ahora le cargamos sus detalles correspondientes foreach (DetalleFacturaDTO d in unaFactura.ListaDetalle) { //Creamos un detalleModel DetalleFacturaModel unDetalle = new DetalleFacturaModel() { Cantidad = d.Cantidad, IdProducto = d.IdProducto, //mostramos a la hora del detalle la descripcion del producto NombreMarca = NombreMarcaProducto(d.IdProducto), SubTotal = d.SubTotal }; //Agregamos el detalle a la factura miFactura.ListaDetalle.Add(unDetalle); } //Agregamos la factura a la lista resultado resultado.Add(miFactura); } //Retornamos la lista resultado return(resultado); }
// GET: Factura/Details/5 public ActionResult Details(int id) { FacturaModel factura = null; RestClient restClient = new RestClient(ConfigurationManager.AppSettings["URLBackend"] + "api/Factura/" + id); RestRequest request = new RestRequest(Method.GET); request.AddHeader("Content-Type", "application/json"); var response = restClient.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { var resp = response.Content; resp = resp.Trim("\"".ToCharArray()); resp = resp.Replace("\\", ""); factura = new List <FacturaModel>(JsonConvert.DeserializeObject <List <FacturaModel> >(resp)).FirstOrDefault(); } return(View(factura)); }
public bool Registrar(FacturaModel model) { bool result = false; using (TiendaJuegosContext context = new TiendaJuegosContext()) { using (var transaction = context.Database.BeginTransaction()) { try { Factura factura = new Factura(); factura.ClienteId = model.ClienteId; factura.Total = (double)model.Detalles.Sum(d => d.Valor); context.Factura.Add(factura); context.SaveChanges(); foreach (DetalleFacturaModel detalle in model.Detalles) { DetalleFactura detalleFactura = new DetalleFactura(); detalleFactura.FacturaId = factura.IdFactura; detalleFactura.ProductoId = detalle.ProductoId; detalleFactura.Cantidad = (byte)detalle.Cantidad; detalleFactura.Valor = (double)detalle.Valor; context.DetalleFactura.Add(detalleFactura); context.SaveChanges(); } transaction.Commit(); result = true; } catch (Exception ex) { transaction.Rollback(); } } } return(result); }
public static FacturaProductosResponse ObtenerFacturaProductos(FacturaModel request) { var mensajes = new List <Mensaje>(); try { List <FacturaProductos> facturaProductos = FacturaAccess.ObtenerFacturaProductos((int)request.Id); List <FacturaProductoModel> facturaProductosModel = ConfigAutomapper.mapper.Map <List <FacturaProductoModel> >(facturaProductos); mensajes.Add(new Mensaje("1", "Consulta Realizada Correctamente")); return(new FacturaProductosResponse(facturaProductosModel, true, mensajes)); } catch (Exception ex) { //Captura de errores mensajes.Add(new Mensaje(null, ex.Message)); return(new FacturaProductosResponse(null, false, mensajes)); } }
public ActionResult MostrarFactura(string numeroFactura) { //Anticipamos un posible error en la base de datos try { //Buscamos la factura en la base: FacturaDTO miFactura = logicaFactura.BuscarFactura(Convert.ToInt32(numeroFactura)); //Convertimos la factura a FacturaModel y ademas le agregamos el nombre de cliente y la descripcion del producto FacturaModel unaFacturaModel = HerramientasM.ConvertirAFacturaModel(miFactura); //Retornamos la vista parcial: return(View("_MostrarFactura", unaFacturaModel)); } catch (Exception unError) { //Podriamos guardar el error //Devolvemos la vista de error return(PartialView("_Error")); } }
public ActionResult FacturaList() { COMPUTERMANAGEMENT_TestEntities _context = new COMPUTERMANAGEMENT_TestEntities(); List <FacturaModel> modelList = new List <FacturaModel>(); var data = _context.t_Factura.ToList(); foreach (t_Factura facturaActual in data) { FacturaModel facturaM = new FacturaModel(); ProveedorModel proveedorM = new ProveedorModel(); proveedorM.IdProveedor = facturaActual.t_Proveedor.IdProveedor; proveedorM.Proveedor = facturaActual.t_Proveedor.Proveedor; facturaM.IdFactura = facturaActual.IdFactura; facturaM.Factura = facturaActual.Factura; facturaM.Fecha = facturaActual.Fecha; facturaM.Garantia = facturaActual.Garantia; facturaM.ProveedorM = proveedorM; modelList.Add(facturaM); } return(View(modelList)); }
public ActionResult Edit(FacturaModel model) { try { if (model.FacturaId > 0) { core.ModifyFactura(model); LocalHelpers.ShowDataUpdateSuccessMessage(); } else { core.AddFactura(model); LocalHelpers.ShowDataInsertSuccessMessage(); } } catch (Exception ex) { LocalHelpers.ShowMessage(ex.Message, MessageType.Error); } return(RedirectToAction("Index")); }
/* * Estas herramientas seran funciones que controlen datos que la logica no puede controlar * Por ejemplo, sessiones, devuelve modelos, Convierte de DTO a MODEL, etc... */ /* ****************************************************** * SECCION HERRAMIENTAS DE FACTURA * ******************************************************/ public static FacturaModel ConvertirAFacturaModel(FacturaDTO miFactura) { //Cargamos nombre y marca del producto y el nombre del cliente FacturaModel unaFacturaModel = new FacturaModel() { Fecha = miFactura.Fecha, NickUsuario = miFactura.NickUsuario, Total = miFactura.Total, NumeroCliente = miFactura.NumeroCliente, NumeroFactura = miFactura.numeroFactura, NombreCliente = NombreCliente(miFactura.NumeroCliente), ListaDetalle = new List <DetalleFacturaModel>() }; //Creamos la lista de detalles vacia List <DetalleFacturaModel> lista = new List <DetalleFacturaModel>(); //Convertimos cada detalle DTO en detalle model agregandole Marca y nombreCliente para que se vea bien en la vista detalles foreach (DetalleFacturaDTO f in miFactura.ListaDetalle) { //Creamos el detalle model DetalleFacturaModel unDetalle = new DetalleFacturaModel() { Cantidad = f.Cantidad, IdProducto = f.IdProducto, SubTotal = f.SubTotal, //Cargamos nombre y marca para que se muestre en la factura NombreMarca = NombreMarcaProducto(f.IdProducto) }; //Agregamos el detalle a la lista de detalles lista.Add(unDetalle); } //Agregamos la lista a la factura unaFacturaModel.ListaDetalle = lista; //Retornamos la Factura return(unaFacturaModel); }
//GET: CrearFactura, crearemos la factura public ActionResult CrearFactura() { //Controlamos que el usuario este logueado if (Session["Logueado"] != null) { //Creamos la factura vacia FacturaModel nuevaFactura = new FacturaModel(); //inicializamos la lista de productos nuevaFactura.ListaDetalle = new List <DetalleFacturaModel>(); //Cargamos la lista de clientes //Como usaremos la base de datos prevenimos un posible error try { //Cargamos la lista de clientes para el dropdown - ListaClientes() es una metodo que esta en este controlador nuevaFactura.ListaClientes = ListaClientes(); //Cargamos la lista de productos para el dropdown - ListaProductos() es una metodo que esta en este controlador nuevaFactura.ListaProductos = ListaProductos(); //Creo una session donde guardare temporalmente mi factura Session.Add("nuevaFactura", nuevaFactura); //Pasamos la factura a la vista para que cargue los selectlist return(View(nuevaFactura)); } catch (Exception unError) { //Podriamos guardar el error en la base //Retornamos la vista de error return(View("Error")); } } else { return(RedirectToAction("Login", "Ingreso")); } }