Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model IEnumerable<AnaliticaProyecto3.Models.Analitica>
- @{
- ViewBag.Title = "Import";}
- <!DOCTYPE html>
- <html>
- <head>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <meta name="viewport" content="width=device-width" />
- <link href="~/Content/indexVisual.css" rel="stylesheet" type="text/css" />
- <title>Import</title>
- </head>
- <body>
- @{
- WebGrid grid = new WebGrid(Model);
- }
- @using (Html.BeginForm("Import", "Analitica", FormMethod.Post, new { enctype = "multipart/form-data" }))
- {
- <input type="file" name="file" id="upload" />
- <input type="submit" value="send" />
- @Html.Hidden("type", "send");
- }
- <div id="gridContent" style=" padding:20px; ">
- <h2>Analiticas</h2>
- @{
- if (grid != null)
- {
- if (Model != null)
- {
- @grid.GetHtml(fillEmptyRows: false,
- htmlAttributes: new { @id = "grid" },
- tableStyle: "webgrid-table",
- headerStyle: "webgrid-header",
- footerStyle: "webgrid-footer",
- mode: WebGridPagerModes.All,
- firstText: "<< Primera",
- previousText: "< Anterior",
- nextText: "Siguiente >",
- lastText: "Última >>",
- columns: new[] {
- grid.Column("NumeroFactura",
- header: "Numero factura",
- format: model=>model.NumeroFactura
- ),
- grid.Column("FechaFactura",
- header: "Fecha Factura",
- format: model=>model.FechaFactura.ToShortDateString()
- ),
- grid.Column("BaseImponible",
- header: "Base Imponible",
- format: model=>model.BaseImponible
- ),
- grid.Column("Cuenta", null, format:
- @<span>
- <span>
- @Html.DropDownList("Cuenta")
- </span>
- </span>),
- public void search()
- {
- IEnumerable<SelectListItem> cuentaNum = db.Analitica.Select(c => new SelectListItem
- {
- Value = c.Cuenta.Nombre,
- Text = c.Cuenta.Nombre,
- });
- IEnumerable<SelectListItem> cuentaDistinct = Enumerable.Empty<SelectListItem>();
- cuentaDistinct = cuentaNum.GroupBy(i => i.Text).Select(i => i.First()).ToList();
- ViewBag.Cuenta = cuentaDistinct;
- public ActionResult Import(HttpPostedFileBase file, string type, string
- page){
- search();
- if (file != null)
- {
- filen = file;
- if (type != null)
- {
- if (type == "send")
- {
- ......
- ......
- if (valid == 1)
- {
- analiticaList.Add(an);
- }
- }
- return View(analiticaList.ToList());
- }
- }
- }
- }
- }
- else
- {
- if (page != null)
- {
- string a = filen.ToString();
- get(filen);
- return View(analiticaList.ToList());
- }
- }
- return View();
- }
- public class Analitica
- {
- [Key]
- public int id { get; set; }
- [ForeignKey("Cuenta")]
- public int CuentaId { get; set; }
- [ForeignKey("Operativo")]
- public int OperativoId { get; set; }
- [ForeignKey("Familia")]
- public string FamiliaId { get; set; }
- public double Importe { get; set; }
- [DataType(DataType.Date)]
- [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
- public System.DateTime FechaFactura { get; set; }
- public string NumeroFactura { get; set; }
- public double BaseImponible { get; set; }
- public string Tipo { get; set; }
- public string Item { get; set; }
- [ForeignKey("ApplicationUserCreate")]
- public string ApplicationUserCreateId { get; set; }
- [ForeignKey("ApplicationUserEdit")]
- public string ApplicationUserEditId { get; set; }
- [DataType(DataType.Date)]
- [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
- public System.DateTime fechaCreacion { get; set; }
- [DataType(DataType.Date)]
- [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
- public System.DateTime fechaEdit { get; set; }
- public virtual Cuenta Cuenta { get; set; }
- public virtual Familia Familia { get; set; }
- public virtual Operativo Operativo { get; set; }
- public virtual ApplicationUser ApplicationUserCreate { get; set; }
- public virtual ApplicationUser ApplicationUserEdit { get; set; }
- }
- public class ApplicationUser : IdentityUser
- {
- }
Add Comment
Please, Sign In to add comment