1
0

feat: complete main requirements for lab 2

This commit is contained in:
Rokas Puzonas 2022-03-02 19:43:26 +02:00
parent 4ff290fe72
commit 9efc1dfc6f
23 changed files with 1303 additions and 2 deletions

View File

@ -4,9 +4,11 @@ root=true
charset = utf-8
end_of_line = lf
indent_style = tab
indent_size = 2
insert_final_newline = true
indent_size = 4
insert_final_newline = false
trim_trailing_whitespace = true
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
[*.cs]
indent_style = space

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24", "LD_24\LD_24.csproj", "{C162007D-7F69-4C5B-9FFF-2EB3B94118A8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C162007D-7F69-4C5B-9FFF-2EB3B94118A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C162007D-7F69-4C5B-9FFF-2EB3B94118A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C162007D-7F69-4C5B-9FFF-2EB3B94118A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C162007D-7F69-4C5B-9FFF-2EB3B94118A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8473410E-D9E0-4BA9-A427-A5B2B6302499}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,45 @@
------------------------------------------
| Įtaisai |
------------------------------------------
| ID | Vardas | Kaina |
------------------------------------------
| 0 | Atsuktuvas | 0.99 |
| 1 | Varztas | 0.05 |
| 2 | Laidas | 2.00 |
| 3 | Plaktukas | 2.99 |
------------------------------------------
---------------------------------------------------------------
| Pirkėjai |
---------------------------------------------------------------
| Pavardė | Vardas | Įtaisas | Įtaiso kiekis |
---------------------------------------------------------------
| Petraitis | Petras | 0 | 10 |
| Onaite | Ona | 2 | 15 |
| Jonaitis | Brolis | 1 | 100 |
| Jonaitis | Jonas | 1 | 100 |
---------------------------------------------------------------
Populiariausias produktas: Varztas
Pardavimų kiekis: 200 vnt.
Pardavimų kaina: 10.00 eur.
---------------------------------------------------------------
| Pirkėjai pagal rūšį (Varztas) |
---------------------------------------------------------------
| Pavardė | Vardas | Įtaiso kiekis | Kaina |
---------------------------------------------------------------
| Jonaitis | Brolis | 100 | 5.00 |
| Jonaitis | Jonas | 100 | 5.00 |
---------------------------------------------------------------
------------------------------------------
| Atrinkti įtaisai (n=1, k=10.00) |
------------------------------------------
| ID | Vardas | Kaina |
------------------------------------------
| 0 | Atsuktuvas | 0.99 |
| 1 | Varztas | 0.05 |
| 2 | Laidas | 2.00 |
------------------------------------------

View File

@ -0,0 +1,4 @@
0, Atsuktuvas, 0.99
1, Varztas, 0.05
2, Laidas, 2.00
3, Plaktukas, 2.99

View File

@ -0,0 +1,4 @@
Petraitis, Petras, 0, 10
Onaite, Ona, 2, 15
Jonaitis, Brolis, 1, 100
Jonaitis, Jonas, 1, 100

View File

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
public class Customer
{
public string Surname { get; set; }
public string Name { get; set; }
public string ProductID { get; set; }
public int ProductAmount { get; set; }
public Customer(string surname, string name, string productID, int productAmount)
{
Surname = surname;
Name = name;
ProductID = productID;
ProductAmount = productAmount;
}
public override string ToString()
{
return String.Format("Customer{Name = '{0}'}", Name);
}
public static bool operator <(Customer a, Customer b)
{
if (a.ProductAmount > b.ProductAmount)
{
return true;
}
else if (a.ProductAmount == b.ProductAmount)
{
int surnameCompare = a.Surname.CompareTo(b.Surname);
if (surnameCompare < 0)
{
return true;
}
else if (surnameCompare == 0)
{
return a.Name.CompareTo(b.Name) < 0;
}
}
return false;
}
public static bool operator >(Customer a, Customer b)
{
return !(a < b && a == b);
}
public static bool operator ==(Customer a, Customer b)
{
return a.ProductAmount == b.ProductAmount && a.Name == b.Name && a.Surname == b.Surname;
}
public static bool operator !=(Customer a, Customer b)
{
return !(a == b);
}
}
}

View File

@ -0,0 +1,107 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
public class CustomerList : IEnumerable<Customer>
{
private CustomerNode head;
private CustomerNode tail;
public void AddToEnd(Customer customer)
{
CustomerNode node = new CustomerNode(customer);
if (tail != null && head != null)
{
tail.Next = node;
tail = node;
}
else
{
tail = node;
head = node;
}
}
public void AddToStart(Customer customer)
{
CustomerNode node = new CustomerNode(customer);
if (tail != null && head != null)
{
node.Next = head;
head = node;
}
else
{
tail = node;
head = node;
}
}
public Customer Get(int index)
{
int i = 0;
CustomerNode current = head;
while (i < index && current != null)
{
current = head.Next;
i++;
}
return current.Data;
}
public int Count()
{
int count = 0;
CustomerNode current = head;
while (current != null)
{
current = current.Next;
count++;
}
return count;
}
public void Sort()
{
for (CustomerNode nodeA = head; nodeA != null; nodeA = nodeA.Next)
{
CustomerNode min = nodeA;
for (CustomerNode nodeB = nodeA.Next; nodeB != null; nodeB = nodeB.Next)
{
if (nodeB.Data < min.Data)
{
min = nodeB;
}
}
Customer tmp = nodeA.Data;
nodeA.Data = min.Data;
min.Data = tmp;
}
}
public override string ToString()
{
return String.Format("CustomerList{ Count = '{0}' }", Count());
}
public IEnumerator<Customer> GetEnumerator()
{
CustomerNode current = head;
while (current != null)
{
yield return current.Data;
current = current.Next;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
public class CustomerNode
{
public Customer Data { get; set; }
public CustomerNode Next { get; set; }
public CustomerNode(Customer data = null, CustomerNode next = null)
{
Data = data;
Next = next;
}
}
}

View File

@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
public static class InOutUtils
{
private static IEnumerable<string> ReadLines(string filename)
{
using (StreamReader reader = File.OpenText(filename))
{
string line;
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
public static ProductList ReadProducts(string filename)
{
ProductList products = new ProductList();
foreach (string line in ReadLines(filename))
{
string[] parts = line.Split(',');
string id = parts[0].Trim();
string name = parts[1].Trim();
decimal price = decimal.Parse(parts[2].Trim());
products.AddToEnd(new Product(id, name, price));
}
return products;
}
public static CustomerList ReadCustomers(string filename)
{
CustomerList customers = new CustomerList();
foreach (string line in ReadLines(filename))
{
string[] parts = line.Split(',');
string surname = parts[0].Trim();
string name = parts[1].Trim();
string productID = parts[2].Trim();
int productAmount = int.Parse(parts[3].Trim());
customers.AddToEnd(new Customer(surname, name, productID, productAmount));
}
return customers;
}
public static void PrintCustomers(StreamWriter writer, CustomerList customers, string header)
{
writer.WriteLine(new string('-', 63));
writer.WriteLine("| {0, -59} |", header);
writer.WriteLine(new string('-', 63));
writer.WriteLine("| {0, -15} | {1, -15} | {2, 7} | {3, 13} |", "Pavardė", "Vardas", "Įtaisas", "Įtaiso kiekis");
writer.WriteLine(new string('-', 63));
if (customers.Count() > 0)
{
foreach (Customer c in customers)
{
writer.WriteLine("| {0, -15} | {1, -15} | {2, 7} | {3, 13} |", c.Surname, c.Name, c.ProductID, c.ProductAmount);
}
}
else
{
writer.WriteLine("| {0, -59} |", "Nėra");
}
writer.WriteLine(new string('-', 63));
writer.WriteLine();
}
public static void PrintCustomersWithPrices(StreamWriter writer, CustomerList customers, Product product, string header)
{
writer.WriteLine(new string('-', 63));
writer.WriteLine("| {0, -59} |", header);
writer.WriteLine(new string('-', 63));
writer.WriteLine("| {0, -15} | {1, -15} | {2, 13} | {3, 7} |", "Pavardė", "Vardas", "Įtaiso kiekis", "Kaina");
writer.WriteLine(new string('-', 63));
if (customers.Count() > 0)
{
foreach (Customer c in customers)
{
writer.WriteLine("| {0, -15} | {1, -15} | {2, 13} | {3, 7:f2} |", c.Surname, c.Name, c.ProductAmount, c.ProductAmount *product.Price);
}
}
else
{
writer.WriteLine("| {0, -59} |", "Nėra");
}
writer.WriteLine(new string('-', 63));
writer.WriteLine();
}
public static void PrintProducts(StreamWriter writer, ProductList products, string header)
{
writer.WriteLine(new string('-', 42));
writer.WriteLine("| {0, -38} |", header);
writer.WriteLine(new string('-', 42));
writer.WriteLine("| {0, -5} | {1, -20} | {2, 7} |", "ID", "Vardas", "Kaina");
writer.WriteLine(new string('-', 42));
if (products.Count() > 0)
{
foreach (Product c in products)
{
writer.WriteLine("| {0, -5} | {1, -20} | {2, 7} |", c.ID, c.Name, c.Price);
}
}
else
{
writer.WriteLine("| {0, -38} |", "Nėra");
}
writer.WriteLine(new string('-', 42));
writer.WriteLine();
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
public class Product
{
public string ID { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public Product(string iD, string name, decimal price)
{
ID = iD;
Name = name;
Price = price;
}
public override string ToString()
{
return String.Format("Product{ID = '{0}'}", ID);
}
}
}

View File

@ -0,0 +1,88 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
public class ProductList : IEnumerable<Product>
{
private ProductNode head;
private ProductNode tail;
public void AddToEnd(Product product)
{
ProductNode node = new ProductNode(product);
if (tail != null && head != null)
{
tail.Next = node;
tail = node;
}
else
{
tail = node;
head = node;
}
}
public void AddToStart(Product product)
{
ProductNode node = new ProductNode(product);
if (tail != null && head != null)
{
node.Next = head;
head = node;
}
else
{
tail = node;
head = node;
}
}
public Product Get(int index)
{
int i = 0;
ProductNode current = head;
while (i < index && current != null)
{
current = head.Next;
i++;
}
return current.Data;
}
public int Count()
{
int count = 0;
ProductNode current = head;
while (current != null)
{
current = current.Next;
count++;
}
return count;
}
public override string ToString()
{
return String.Format("ProductList{ Count = '{0}' }", Count());
}
public IEnumerator<Product> GetEnumerator()
{
ProductNode current = head;
while (current != null)
{
yield return current.Data;
current = current.Next;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
public class ProductNode
{
public Product Data { get; set; }
public ProductNode Next { get; set; }
public ProductNode(Product data = null, ProductNode next = null)
{
Data = data;
Next = next;
}
}
}

View File

@ -0,0 +1,107 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace LD_24.Code
{
public static class TaskUtils
{
public static string FindMostPopularProduct(CustomerList customers)
{
Dictionary<string, int> productCounter = new Dictionary<string, int>();
foreach (Customer customer in customers)
{
if (!productCounter.ContainsKey(customer.ProductID))
{
productCounter.Add(customer.ProductID, 1);
}
else
{
productCounter[customer.ProductID]++;
}
}
string mostPopularProduct = null;
int mostPopularCount = 0;
foreach (string product in productCounter.Keys)
{
int count = productCounter[product];
if (count > mostPopularCount)
{
mostPopularCount = count;
mostPopularProduct = product;
}
}
return mostPopularProduct;
}
public static int CountProductSales(CustomerList customers, string product)
{
int sales = 0;
foreach (Customer customer in customers)
{
if (customer.ProductID == product)
{
sales += customer.ProductAmount;
}
}
return sales;
}
public static CustomerList FilterByProduct(CustomerList customers, string product)
{
CustomerList filtered = new CustomerList();
foreach (Customer customer in customers)
{
if (customer.ProductID == product)
{
filtered.AddToEnd(customer);
}
}
return filtered;
}
public static Product FindByID(ProductList products, string id)
{
foreach (Product product in products)
{
if (product.ID == id)
{
return product;
}
}
return null;
}
public static ProductList FilterByMaxPrice(ProductList products, decimal maxPrice)
{
ProductList filtered = new ProductList();
foreach (Product product in products)
{
if (product.Price < maxPrice)
{
filtered.AddToEnd(product);
}
}
return filtered;
}
public static ProductList FilterByMinQuantitySold(ProductList products, CustomerList customers, decimal minSold)
{
ProductList filtered = new ProductList();
foreach (Product product in products)
{
int sold = CountProductSales(customers, product.ID);
if (sold >= minSold)
{
filtered.AddToEnd(product);
}
}
return filtered;
}
}
}

View File

@ -0,0 +1,48 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Forma1.aspx.cs" Inherits="LD_24.Forma1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Įtaisai:"></asp:Label>
<asp:Table ID="Table1" runat="server" BackColor="#FFFFCC" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" GridLines="Both">
</asp:Table>
<br />
<asp:Label ID="Label2" runat="server" Text="Pirkėjai:"></asp:Label>
<asp:Table ID="Table2" runat="server" BackColor="#FFFFCC" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" GridLines="Both">
</asp:Table>
<br />
<asp:Label ID="Label3" runat="server"></asp:Label>
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="Pirkėjai pagal rūšį:"></asp:Label>
<asp:Table ID="Table3" runat="server" BackColor="#FFFFCC" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" GridLines="Both">
</asp:Table>
<br />
<hr />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" />
<br />
<asp:Label ID="Label5" runat="server" Text="n:"></asp:Label>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Tiktais teigiami sveiki skaičiai yra galimi" ForeColor="Red" ValidationExpression="\d+"></asp:RegularExpressionValidator>
<br />
<asp:Label ID="Label6" runat="server" Text="k:"></asp:Label>
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="Tiktais teigiami skaičiai yra galimi" ForeColor="Red" ValidationExpression="\d+(\.\d+)?"></asp:RegularExpressionValidator>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Atrinkti" OnClick="Button1_Click" />
<br />
<br />
<asp:Label ID="Label7" runat="server" Text="Atrinkti įtaisai:"></asp:Label>
<asp:Table ID="Table4" runat="server" BackColor="#FFFFCC" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" GridLines="Both">
</asp:Table>
</form>
</body>
</html>

View File

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LD_24.Code;
namespace LD_24
{
public partial class Forma1 : System.Web.UI.Page
{
private const string targetProductID = "1";
private const string inputFileA = "App_Data/U24a.txt";
private const string inputFileB = "App_Data/U24b.txt";
private const string outputFilename = "App_Data/Rezultatai.txt";
private ProductList Products;
private CustomerList Customers;
private Product PopularProduct;
private Product TargetProduct;
private CustomerList CustomersByTargetProduct;
protected void Page_Load(object sender, EventArgs e)
{
Products = InOutUtils.ReadProducts(Server.MapPath(inputFileA));
Customers = InOutUtils.ReadCustomers(Server.MapPath(inputFileB));
ShowProducts(Table1, Products);
ShowCustomers(Table2, Customers);
string popularProductID = TaskUtils.FindMostPopularProduct(Customers);
PopularProduct = null;
if (popularProductID != null)
{
PopularProduct = TaskUtils.FindByID(Products, popularProductID);
}
TargetProduct = TaskUtils.FindByID(Products, targetProductID);
CustomersByTargetProduct = TaskUtils.FilterByProduct(Customers, targetProductID);
CustomersByTargetProduct.Sort();
ShowMostPopularProduct(Label3, Customers, PopularProduct);
Label4.Text = $"Pirkėjai pagal rūšį ({TargetProduct.Name}):";
ShowCustomersByProduct(Table3, CustomersByTargetProduct, TargetProduct);
}
protected void Button1_Click(object sender, EventArgs e)
{
int n = int.Parse(TextBox1.Text);
decimal k = decimal.Parse(TextBox2.Text);
ProductList filteredProducts = TaskUtils.FilterByMinQuantitySold(TaskUtils.FilterByMaxPrice(Products, k), Customers, n);
ShowProducts(Table4, filteredProducts);
using (StreamWriter writer = new StreamWriter(Server.MapPath(outputFilename)))
{
InOutUtils.PrintProducts(writer, Products, "Įtaisai");
InOutUtils.PrintCustomers(writer, Customers, "Pirkėjai");
writer.Write("Populiariausias produktas: ");
if (PopularProduct == null)
{
writer.WriteLine("Nėra");
}
else
{
writer.WriteLine(PopularProduct.Name);
int sales = TaskUtils.CountProductSales(Customers, PopularProduct.ID);
writer.WriteLine($"Pardavimų kiekis: {sales} vnt.");
writer.WriteLine($"Pardavimų kaina: {sales * PopularProduct.Price:f2} eur.");
}
writer.WriteLine();
InOutUtils.PrintCustomersWithPrices(writer, CustomersByTargetProduct, TargetProduct, $"Pirkėjai pagal rūšį ({TargetProduct.Name})");
InOutUtils.PrintProducts(writer, filteredProducts, $"Atrinkti įtaisai (n={n}, k={k:f2})");
}
}
}
}

View File

@ -0,0 +1,179 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LD_24
{
public partial class Forma1
{
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// Label1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label1;
/// <summary>
/// Table1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Table Table1;
/// <summary>
/// Label2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label2;
/// <summary>
/// Table2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Table Table2;
/// <summary>
/// Label3 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label3;
/// <summary>
/// Label4 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label4;
/// <summary>
/// Table3 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Table Table3;
/// <summary>
/// ValidationSummary1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
/// <summary>
/// Label5 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label5;
/// <summary>
/// TextBox1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox TextBox1;
/// <summary>
/// RegularExpressionValidator1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
/// <summary>
/// Label6 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label6;
/// <summary>
/// TextBox2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox TextBox2;
/// <summary>
/// RegularExpressionValidator2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
/// <summary>
/// Button1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button Button1;
/// <summary>
/// Label7 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label7;
/// <summary>
/// Table4 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Table Table4;
}
}

View File

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LD_24.Code;
namespace LD_24
{
public partial class Forma1 : System.Web.UI.Page
{
public void ShowProducts(Table table, ProductList products)
{
table.Rows.Clear();
TableRow header = new TableRow();
header.Cells.Add(new TableCell { Text = "ID" });
header.Cells.Add(new TableCell { Text = "Vardas" });
header.Cells.Add(new TableCell { Text = "Kaina, eur." });
table.Rows.Add(header);
foreach (Product product in products)
{
TableRow row = new TableRow();
row.Cells.Add(new TableCell { Text = product.ID });
row.Cells.Add(new TableCell { Text = product.Name });
row.Cells.Add(new TableCell { Text = product.Price.ToString() });
table.Rows.Add(row);
}
}
public void ShowCustomers(Table table, CustomerList customers)
{
table.Rows.Clear();
TableRow header = new TableRow();
header.Cells.Add(new TableCell { Text = "Pavardė" });
header.Cells.Add(new TableCell { Text = "Vardas" });
header.Cells.Add(new TableCell { Text = "Įtaisas" });
header.Cells.Add(new TableCell { Text = "Įtaiso kiekis, vnt." });
table.Rows.Add(header);
foreach (Customer customer in customers)
{
TableRow row = new TableRow();
row.Cells.Add(new TableCell { Text = customer.Surname });
row.Cells.Add(new TableCell { Text = customer.Name });
row.Cells.Add(new TableCell { Text = customer.ProductID.ToString() });
row.Cells.Add(new TableCell { Text = customer.ProductAmount.ToString() });
table.Rows.Add(row);
}
}
public void ShowMostPopularProduct(Label label, CustomerList customers, Product product)
{
label.Text = "Populiariausias produktas: ";
if (product == null)
{
label.Text = "Nėra";
return;
}
label.Text += $"{product.Name}<br />";
int sales = TaskUtils.CountProductSales(customers, product.ID);
label.Text += $"Pardavimų kiekis: {sales} vnt.<br />";
label.Text += $"Pardavimų kaina: {sales*product.Price:f2} eur.";
}
public void ShowCustomersByProduct(Table table, CustomerList customers, Product product)
{
table.Rows.Clear();
TableRow header = new TableRow();
header.Cells.Add(new TableCell { Text = "Pavardė" });
header.Cells.Add(new TableCell { Text = "Vardas" });
header.Cells.Add(new TableCell { Text = "Įtaisas kiekis, vnt." });
header.Cells.Add(new TableCell { Text = "Kaina, eur." });
table.Rows.Add(header);
foreach (Customer customer in customers)
{
TableRow row = new TableRow();
row.Cells.Add(new TableCell { Text = customer.Surname });
row.Cells.Add(new TableCell { Text = customer.Name });
row.Cells.Add(new TableCell { Text = customer.ProductAmount.ToString() });
row.Cells.Add(new TableCell { Text = (Math.Round(customer.ProductAmount*product.Price, 2)).ToString() });
table.Rows.Add(row);
}
}
}
}

View File

@ -0,0 +1,152 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C162007D-7F69-4C5B-9FFF-2EB3B94118A8}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LD_24</RootNamespace>
<AssemblyName>LD_24</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort>
</IISExpressSSLPort>
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="App_Data\Rezultatai.txt" />
<Content Include="App_Data\U24b.txt" />
<Content Include="App_Data\U24a.txt" />
<Content Include="Forma1.aspx" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Code\Customer.cs" />
<Compile Include="Code\CustomerList.cs" />
<Compile Include="Code\CustomerNode.cs" />
<Compile Include="Code\InOutUtils.cs" />
<Compile Include="Code\Product.cs" />
<Compile Include="Code\ProductList.cs" />
<Compile Include="Code\ProductNode.cs" />
<Compile Include="Code\TaskUtils.cs" />
<Compile Include="Forma1.aspx.cs">
<DependentUpon>Forma1.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Forma1.aspx.designer.cs">
<DependentUpon>Forma1.aspx</DependentUpon>
</Compile>
<Compile Include="Forma1Utils.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>56191</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:44355/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
<servers defaultServer="SelfHostServer">
<server name="SelfHostServer" exePath="" cmdArgs="" url="http://localhost:44355/" workingDir="" />
</servers>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LD_24")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LD_24")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c162007d-7f69-4c5b-9fff-2eb3b94118a8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" />
<globalization fileEncoding="utf-8" />
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
</configuration>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net461" />
</packages>