Advertisement
themkss

Untitled

May 2nd, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI.WebControls;
  7. using System.Web.UI.WebControls.WebParts;
  8.  
  9. namespace LB4_V2
  10. {
  11.     public partial class WebForm1 : System.Web.UI.Page
  12.     {
  13.         /// <summary>
  14.         /// Prints starting data to a Table in the WEB
  15.         /// </summary>
  16.         /// <param name="registerList"></param>
  17.         public void PrintStartDataToTable(List<LibraryRegister> registerList)
  18.         {
  19.             for (int i = 0; i < registerList.Count; i++)
  20.             {
  21.                 TableRow row = new TableRow();
  22.                 TableCell cell1 = new TableCell();
  23.                 TableCell cell2 = new TableCell();
  24.                 TableCell cell3 = new TableCell();
  25.                 cell1.Text = registerList[i].name;
  26.                 cell2.Text = registerList[i].address;
  27.                 cell3.Text = registerList[i].phoneNumber;
  28.                 row.Cells.Add(cell1);
  29.                 row.Cells.Add(cell2);
  30.                 row.Cells.Add(cell3);
  31.  
  32.                 Table1.Rows.Add(row);
  33.  
  34.                 for (int j = 0; j < registerList[i].Count(); j++)
  35.                 {
  36.                     row = new TableRow();
  37.                     TableCell cell4 = new TableCell();
  38.                     TableCell cell5 = new TableCell();
  39.                     TableCell cell6 = new TableCell();
  40.                     TableCell cell7 = new TableCell();
  41.                     TableCell cell8 = new TableCell();
  42.                     TableCell cell9 = new TableCell();
  43.  
  44.                     cell4.Text = registerList[i].Get(j).name;
  45.                     cell5.Text = registerList[i].Get(j).type;
  46.                     cell6.Text = registerList[i].Get(j).publishingPlace;
  47.                     cell7.Text = registerList[i].Get(j).yearOfRelease.ToString();
  48.                     cell8.Text = registerList[i].Get(j).numberOfPages.ToString();
  49.                     cell9.Text = registerList[i].Get(j).edition.ToString();
  50.  
  51.                     row.Cells.Add(cell4);
  52.                     row.Cells.Add(cell5);
  53.                     row.Cells.Add(cell6);
  54.                     row.Cells.Add(cell7);
  55.                     row.Cells.Add(cell8);
  56.                     row.Cells.Add(cell9);
  57.  
  58.                     if (registerList[i].Get(j) is Book)
  59.                     {
  60.                         TableCell cell10 = new TableCell();
  61.                         TableCell cell11 = new TableCell();
  62.  
  63.                         Book book = (Book)registerList[i].Get(j);
  64.  
  65.                         cell10.Text = book.ISBN;
  66.                         cell11.Text = book.author;
  67.  
  68.                         row.Cells.Add(cell10);
  69.                         row.Cells.Add(cell11);
  70.                     }
  71.                     else
  72.                     {
  73.                         if (registerList[i].Get(j) is Journal)
  74.                         {
  75.                             TableCell cell10 = new TableCell();
  76.                             TableCell cell11 = new TableCell();
  77.                             TableCell cell12 = new TableCell();
  78.  
  79.                             Journal journal = (Journal)registerList[i].Get(j);
  80.  
  81.                             cell10.Text = journal.ISBN;
  82.                             cell11.Text = journal.number.ToString();
  83.                             cell12.Text = journal.monthOfRelease.ToString();
  84.  
  85.                             row.Cells.Add(cell10);
  86.                             row.Cells.Add(cell11);
  87.                             row.Cells.Add(cell12);
  88.                         }
  89.                         else
  90.                         {
  91.                             TableCell cell10 = new TableCell();
  92.                             TableCell cell11 = new TableCell();
  93.                             TableCell cell12 = new TableCell();
  94.  
  95.                             Newspaper newspaper = (Newspaper)registerList[i].Get(j);
  96.  
  97.                             cell10.Text = newspaper.date.ToString();
  98.                             cell11.Text = newspaper.number.ToString();
  99.                             cell12.Text = newspaper.MonthAndDayOfRelease;
  100.  
  101.                             row.Cells.Add(cell10);
  102.                             row.Cells.Add(cell11);
  103.                             row.Cells.Add(cell12);
  104.                         }
  105.                     }
  106.                     Table1.Rows.Add(row);
  107.                 }
  108.             }
  109.         }
  110.        
  111.         /// <summary>
  112.         /// Prints specified data to the Table
  113.         /// </summary>
  114.         /// <param name="register"></param>
  115.         public void PrintI(List<LibraryRegister> register)
  116.         {
  117.             for (int i = 0; i < register.Count(); i++)
  118.             {
  119.                 TableRow row = new TableRow();
  120.                 TableCell cell1 = new TableCell();
  121.                 cell1.Text = register[i].name;
  122.                 row.Cells.Add(cell1);
  123.                 Table2.Rows.Add(row);
  124.  
  125.                 for (int j = 0; j < register[i].Count(); j++)
  126.                 {
  127.                     row = new TableRow();
  128.  
  129.                     TableCell cell2 = new TableCell();
  130.                     TableCell cell3 = new TableCell();
  131.  
  132.                     cell2.Text = register[i].Get(j).name;
  133.                     cell3.Text = register[i].Get(j).edition.ToString();
  134.  
  135.                     row.Cells.Add(cell2);
  136.                     row.Cells.Add(cell3);
  137.  
  138.                     Table2.Rows.Add(row);
  139.                 }
  140.             }
  141.         }
  142.  
  143.         /// <summary>
  144.         /// Prints publication data to a table
  145.         /// </summary>
  146.         /// <param name="table"></param>
  147.         /// <param name="publications"></param>
  148.         public static void PrintToTable(Table table, LibraryRegister publications)
  149.         {
  150.             for (int i = 0; i < publications.Count(); i++)
  151.             {
  152.                 TableRow row = new TableRow();
  153.                 TableCell cell4 = new TableCell();
  154.                 TableCell cell5 = new TableCell();
  155.                 TableCell cell6 = new TableCell();
  156.                 TableCell cell7 = new TableCell();
  157.                 TableCell cell8 = new TableCell();
  158.                 TableCell cell9 = new TableCell();
  159.  
  160.                 cell4.Text = publications.Get(i).name;
  161.                 cell5.Text = publications.Get(i).type;
  162.                 cell6.Text = publications.Get(i).publishingPlace;
  163.                 cell7.Text = publications.Get(i).yearOfRelease.ToString();
  164.                 cell8.Text = publications.Get(i).numberOfPages.ToString();
  165.                 cell9.Text = publications.Get(i).edition.ToString();
  166.  
  167.                 row.Cells.Add(cell4);
  168.                 row.Cells.Add(cell5);
  169.                 row.Cells.Add(cell6);
  170.                 row.Cells.Add(cell7);
  171.                 row.Cells.Add(cell8);
  172.                 row.Cells.Add(cell9);
  173.  
  174.                 if (publications.Get(i) is Book)
  175.                 {
  176.                     TableCell cell10 = new TableCell();
  177.                     TableCell cell11 = new TableCell();
  178.  
  179.                     Book book = (Book)publications.Get(i);
  180.  
  181.                     cell10.Text = book.ISBN;
  182.                     cell11.Text = book.author;
  183.  
  184.                     row.Cells.Add(cell10);
  185.                     row.Cells.Add(cell11);
  186.                 }
  187.                 else
  188.                 {
  189.                     if (publications.Get(i) is Journal)
  190.                     {
  191.                         TableCell cell10 = new TableCell();
  192.                         TableCell cell11 = new TableCell();
  193.                         TableCell cell12 = new TableCell();
  194.  
  195.                         Journal journal = (Journal)publications.Get(i);
  196.  
  197.                         cell10.Text = journal.ISBN;
  198.                         cell11.Text = journal.number.ToString();
  199.                         cell12.Text = journal.monthOfRelease.ToString();
  200.  
  201.                         row.Cells.Add(cell10);
  202.                         row.Cells.Add(cell11);
  203.                         row.Cells.Add(cell12);
  204.                     }
  205.                     else
  206.                     {
  207.                         TableCell cell10 = new TableCell();
  208.                         TableCell cell11 = new TableCell();
  209.                         TableCell cell12 = new TableCell();
  210.  
  211.                         Newspaper newspaper = (Newspaper)publications.Get(i);
  212.  
  213.                         cell10.Text = newspaper.date.ToString();
  214.                         cell11.Text = newspaper.number.ToString();
  215.                         cell12.Text = newspaper.MonthAndDayOfRelease;
  216.  
  217.                         row.Cells.Add(cell10);
  218.                         row.Cells.Add(cell11);
  219.                         row.Cells.Add(cell12);
  220.                     }
  221.                 }
  222.                 table.Rows.Add(row);
  223.             }
  224.         }
  225.     }
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement