Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace LB4_V2
- {
- public partial class WebForm1 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Label1.Visible = false;
- Label2.Visible = false;
- Label3.Visible = false;
- Label4.Visible = false;
- Label5.Visible = false;
- Label6.Visible = false;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string CFd = Server.MapPath("App_Data");
- string CFr1 = Server.MapPath("Rezultatai/Rezultatai.txt");
- string CFr2 = Server.MapPath("Rezultatai/RetiLeidiniai.csv");
- string CFr3 = Server.MapPath("Rezultatai/Nenauji.csv");
- string CFr4 = Server.MapPath("Rezultatai/Technologija.csv");
- if (!Directory.Exists(CFd))
- {
- throw new Exception(string.Format("Nėra tokio nurodyto aplankalo - {0}", CFd));
- }
- try
- {
- if (File.Exists(CFr1))
- {
- File.Delete(CFr1);
- }
- if (File.Exists(CFr2))
- {
- File.Delete(CFr2);
- }
- if (File.Exists(CFr3))
- {
- File.Delete(CFr3);
- }
- if (File.Exists(CFr4))
- {
- File.Delete(CFr4);
- }
- List<LibraryRegister> list = InOut.ReadData(CFd);
- InOut.PrintStartData(CFr1, "Pradiniai duomenys", list);
- PrintStartDataToTable(list);
- Label1.Visible = true;
- // 1
- List<LibraryRegister> publications1 = TaskUtils.FindHighestEdition(list);
- if (publications1.Count > 0)
- {
- InOut.PrintData(CFr1, "Didžiausiu tiražu išleisti knyga, žurnalas ir laikraštis", publications1);
- Label2.Visible = true;
- PrintI(publications1);
- }
- else
- {
- StreamWriter sw = new StreamWriter(CFr1, true);
- sw.WriteLine("Didžiausiu tiražu išleistos knygos ar žurnalo nėra.");
- sw.WriteLine();
- sw.Close();
- Label2.Visible = true;
- Label2.Text = "Rezultatų nėra";
- }
- //2
- LibraryRegister publications2 = TaskUtils.OnlyOneLibrary(list);
- if (publications2.Count() > 0)
- {
- Label3.Visible = true;
- InOut.PrintToCSV(CFr2, "Visi leidiniai, kuriuos galime rasti tik viename filiale", publications2);
- PrintToTable(Table3, publications2);
- }
- else
- {
- Label3.Visible = true;
- Label3.Text = "Rezultatų nėra";
- }
- //3
- LibraryRegister publications3 = TaskUtils.NotNew(list);
- if (publications3.Count() > 0)
- {
- publications3.Sort();
- InOut.PrintToCSV(CFr3, "Nenauji leidiniai", publications3);
- Label4.Visible = true;
- PrintToTable(Table4, publications3);
- }
- else
- {
- Label4.Visible = true;
- Label4.Text = "Rezultatų nėra";
- }
- //4
- LibraryRegister publications4 = TaskUtils.FindByPublisher(list, "Technologija");
- if (publications4.Count() == 0)
- {
- StreamWriter sw = new StreamWriter(CFr4);
- sw.WriteLine("Nėra šios leidyklos leidinių");
- sw.Close();
- Label5.Visible = true;
- Label5.Text = "Rezultatų nėra";
- }
- else
- {
- Label5.Visible = true;
- InOut.PrintToCSV(CFr4, ("Leidiniai leidyklos - Technologija"), publications4);
- PrintToTable(Table5, publications4);
- }
- }
- catch(Exception ex)
- {
- Label6.Visible = true;
- Label6.Text = ex.Message;
- StreamWriter sw = new StreamWriter(CFr1);
- sw.WriteLine(ex.Message);
- sw.WriteLine();
- sw.Close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement