Guest User

Untitled

a guest
Jun 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. @model IEnumerable<AnaliticaProyecto3.Models.Analitica>
  2. @{
  3. ViewBag.Title = "Import";}
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  8. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  9. <meta name="viewport" content="width=device-width" />
  10. <link href="~/Content/indexVisual.css" rel="stylesheet" type="text/css" />
  11. <title>Import</title>
  12. </head>
  13. <body>
  14. @{
  15. WebGrid grid = new WebGrid(Model);
  16. }
  17.  
  18. @using (Html.BeginForm("Import", "Analitica", FormMethod.Post, new { enctype = "multipart/form-data" }))
  19. {
  20. <input type="file" name="file" id="upload" />
  21. <input type="submit" value="send" />
  22. @Html.Hidden("type", "send");
  23.  
  24. }
  25.  
  26. <div id="gridContent" style=" padding:20px; ">
  27.  
  28. <h2>Analiticas</h2>
  29. @{
  30. if (grid != null)
  31. {
  32. if (Model != null)
  33. {
  34. @grid.GetHtml(fillEmptyRows: false,
  35. htmlAttributes: new { @id = "grid" },
  36. tableStyle: "webgrid-table",
  37. headerStyle: "webgrid-header",
  38. footerStyle: "webgrid-footer",
  39. mode: WebGridPagerModes.All,
  40. firstText: "<< Primera",
  41. previousText: "< Anterior",
  42. nextText: "Siguiente >",
  43. lastText: "Última >>",
  44. columns: new[] {
  45. grid.Column("NumeroFactura",
  46. header: "Numero factura",
  47. format: model=>model.NumeroFactura
  48. ),
  49. grid.Column("FechaFactura",
  50. header: "Fecha Factura",
  51. format: model=>model.FechaFactura.ToShortDateString()
  52. ),
  53. grid.Column("BaseImponible",
  54. header: "Base Imponible",
  55. format: model=>model.BaseImponible
  56. ),
  57.  
  58. grid.Column("Cuenta", null, format:
  59. @<span>
  60. <span>
  61. @Html.DropDownList("Cuenta")
  62. </span>
  63. </span>),
  64.  
  65. public void search()
  66. {
  67. IEnumerable<SelectListItem> cuentaNum = db.Analitica.Select(c => new SelectListItem
  68. {
  69. Value = c.Cuenta.Nombre,
  70. Text = c.Cuenta.Nombre,
  71.  
  72. });
  73. IEnumerable<SelectListItem> cuentaDistinct = Enumerable.Empty<SelectListItem>();
  74. cuentaDistinct = cuentaNum.GroupBy(i => i.Text).Select(i => i.First()).ToList();
  75. ViewBag.Cuenta = cuentaDistinct;
  76.  
  77. public ActionResult Import(HttpPostedFileBase file, string type, string
  78. page){
  79. search();
  80. if (file != null)
  81. {
  82. filen = file;
  83.  
  84. if (type != null)
  85. {
  86. if (type == "send")
  87. {
  88. ......
  89. ......
  90. if (valid == 1)
  91. {
  92. analiticaList.Add(an);
  93. }
  94. }
  95. return View(analiticaList.ToList());
  96.  
  97. }
  98. }
  99. }
  100.  
  101.  
  102. }
  103. }
  104. else
  105. {
  106. if (page != null)
  107. {
  108. string a = filen.ToString();
  109. get(filen);
  110. return View(analiticaList.ToList());
  111. }
  112. }
  113. return View();
  114. }
  115.  
  116. public class Analitica
  117. {
  118. [Key]
  119. public int id { get; set; }
  120. [ForeignKey("Cuenta")]
  121. public int CuentaId { get; set; }
  122. [ForeignKey("Operativo")]
  123. public int OperativoId { get; set; }
  124. [ForeignKey("Familia")]
  125. public string FamiliaId { get; set; }
  126. public double Importe { get; set; }
  127. [DataType(DataType.Date)]
  128. [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
  129. public System.DateTime FechaFactura { get; set; }
  130. public string NumeroFactura { get; set; }
  131. public double BaseImponible { get; set; }
  132. public string Tipo { get; set; }
  133. public string Item { get; set; }
  134. [ForeignKey("ApplicationUserCreate")]
  135. public string ApplicationUserCreateId { get; set; }
  136. [ForeignKey("ApplicationUserEdit")]
  137. public string ApplicationUserEditId { get; set; }
  138. [DataType(DataType.Date)]
  139. [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
  140. public System.DateTime fechaCreacion { get; set; }
  141. [DataType(DataType.Date)]
  142. [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
  143. public System.DateTime fechaEdit { get; set; }
  144. public virtual Cuenta Cuenta { get; set; }
  145. public virtual Familia Familia { get; set; }
  146. public virtual Operativo Operativo { get; set; }
  147. public virtual ApplicationUser ApplicationUserCreate { get; set; }
  148. public virtual ApplicationUser ApplicationUserEdit { get; set; }
  149.  
  150. }
  151. public class ApplicationUser : IdentityUser
  152. {
  153. }
Add Comment
Please, Sign In to add comment