diff --git a/.editorconfig b/.editorconfig index 3159b2a..d6b91ef 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/DynamicMemory/DynamicMemory.sln b/DynamicMemory/DynamicMemory.sln new file mode 100644 index 0000000..83c90f9 --- /dev/null +++ b/DynamicMemory/DynamicMemory.sln @@ -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 diff --git a/DynamicMemory/LD_24/App_Data/Rezultatai.txt b/DynamicMemory/LD_24/App_Data/Rezultatai.txt new file mode 100644 index 0000000..d4d569d --- /dev/null +++ b/DynamicMemory/LD_24/App_Data/Rezultatai.txt @@ -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 | +------------------------------------------ + diff --git a/DynamicMemory/LD_24/App_Data/U24a.txt b/DynamicMemory/LD_24/App_Data/U24a.txt new file mode 100644 index 0000000..084097c --- /dev/null +++ b/DynamicMemory/LD_24/App_Data/U24a.txt @@ -0,0 +1,4 @@ +0, Atsuktuvas, 0.99 +1, Varztas, 0.05 +2, Laidas, 2.00 +3, Plaktukas, 2.99 \ No newline at end of file diff --git a/DynamicMemory/LD_24/App_Data/U24b.txt b/DynamicMemory/LD_24/App_Data/U24b.txt new file mode 100644 index 0000000..3db7b1a --- /dev/null +++ b/DynamicMemory/LD_24/App_Data/U24b.txt @@ -0,0 +1,4 @@ +Petraitis, Petras, 0, 10 +Onaite, Ona, 2, 15 +Jonaitis, Brolis, 1, 100 +Jonaitis, Jonas, 1, 100 \ No newline at end of file diff --git a/DynamicMemory/LD_24/Code/Customer.cs b/DynamicMemory/LD_24/Code/Customer.cs new file mode 100644 index 0000000..7c80809 --- /dev/null +++ b/DynamicMemory/LD_24/Code/Customer.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/DynamicMemory/LD_24/Code/CustomerList.cs b/DynamicMemory/LD_24/Code/CustomerList.cs new file mode 100644 index 0000000..7652a41 --- /dev/null +++ b/DynamicMemory/LD_24/Code/CustomerList.cs @@ -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 + { + 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 GetEnumerator() + { + CustomerNode current = head; + while (current != null) + { + yield return current.Data; + current = current.Next; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/DynamicMemory/LD_24/Code/CustomerNode.cs b/DynamicMemory/LD_24/Code/CustomerNode.cs new file mode 100644 index 0000000..3ecff7f --- /dev/null +++ b/DynamicMemory/LD_24/Code/CustomerNode.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/DynamicMemory/LD_24/Code/InOutUtils.cs b/DynamicMemory/LD_24/Code/InOutUtils.cs new file mode 100644 index 0000000..5804a4c --- /dev/null +++ b/DynamicMemory/LD_24/Code/InOutUtils.cs @@ -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 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(); + } + } +} \ No newline at end of file diff --git a/DynamicMemory/LD_24/Code/Product.cs b/DynamicMemory/LD_24/Code/Product.cs new file mode 100644 index 0000000..662565e --- /dev/null +++ b/DynamicMemory/LD_24/Code/Product.cs @@ -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); + } + } +} diff --git a/DynamicMemory/LD_24/Code/ProductList.cs b/DynamicMemory/LD_24/Code/ProductList.cs new file mode 100644 index 0000000..f8fc70d --- /dev/null +++ b/DynamicMemory/LD_24/Code/ProductList.cs @@ -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 + { + 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 GetEnumerator() + { + ProductNode current = head; + while (current != null) + { + yield return current.Data; + current = current.Next; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/DynamicMemory/LD_24/Code/ProductNode.cs b/DynamicMemory/LD_24/Code/ProductNode.cs new file mode 100644 index 0000000..950dd18 --- /dev/null +++ b/DynamicMemory/LD_24/Code/ProductNode.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/DynamicMemory/LD_24/Code/TaskUtils.cs b/DynamicMemory/LD_24/Code/TaskUtils.cs new file mode 100644 index 0000000..0a33d58 --- /dev/null +++ b/DynamicMemory/LD_24/Code/TaskUtils.cs @@ -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 productCounter = new Dictionary(); + 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; + } + + } +} diff --git a/DynamicMemory/LD_24/Forma1.aspx b/DynamicMemory/LD_24/Forma1.aspx new file mode 100644 index 0000000..42bf752 --- /dev/null +++ b/DynamicMemory/LD_24/Forma1.aspx @@ -0,0 +1,48 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Forma1.aspx.cs" Inherits="LD_24.Forma1" %> + + + + + + + + +
+ + + +
+ + + +
+ +
+
+ + + +
+
+ +
+ +
+ + +
+ +
+ + +
+
+ +
+
+ + + + + + diff --git a/DynamicMemory/LD_24/Forma1.aspx.cs b/DynamicMemory/LD_24/Forma1.aspx.cs new file mode 100644 index 0000000..0352a5b --- /dev/null +++ b/DynamicMemory/LD_24/Forma1.aspx.cs @@ -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})"); + } + } + } +} \ No newline at end of file diff --git a/DynamicMemory/LD_24/Forma1.aspx.designer.cs b/DynamicMemory/LD_24/Forma1.aspx.designer.cs new file mode 100644 index 0000000..9a40019 --- /dev/null +++ b/DynamicMemory/LD_24/Forma1.aspx.designer.cs @@ -0,0 +1,179 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LD_24 +{ + + + public partial class Forma1 + { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// Label1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label1; + + /// + /// Table1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Table Table1; + + /// + /// Label2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label2; + + /// + /// Table2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Table Table2; + + /// + /// Label3 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label3; + + /// + /// Label4 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label4; + + /// + /// Table3 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Table Table3; + + /// + /// ValidationSummary1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ValidationSummary ValidationSummary1; + + /// + /// Label5 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label5; + + /// + /// TextBox1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox TextBox1; + + /// + /// RegularExpressionValidator1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1; + + /// + /// Label6 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label6; + + /// + /// TextBox2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox TextBox2; + + /// + /// RegularExpressionValidator2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2; + + /// + /// Button1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button Button1; + + /// + /// Label7 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label7; + + /// + /// Table4 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Table Table4; + } +} diff --git a/DynamicMemory/LD_24/Forma1Utils.aspx.cs b/DynamicMemory/LD_24/Forma1Utils.aspx.cs new file mode 100644 index 0000000..d62b903 --- /dev/null +++ b/DynamicMemory/LD_24/Forma1Utils.aspx.cs @@ -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}
"; + + int sales = TaskUtils.CountProductSales(customers, product.ID); + label.Text += $"Pardavimų kiekis: {sales} vnt.
"; + 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); + } + } + } +} \ No newline at end of file diff --git a/DynamicMemory/LD_24/LD_24.csproj b/DynamicMemory/LD_24/LD_24.csproj new file mode 100644 index 0000000..1a3ddb0 --- /dev/null +++ b/DynamicMemory/LD_24/LD_24.csproj @@ -0,0 +1,152 @@ + + + + + Debug + AnyCPU + + + 2.0 + {C162007D-7F69-4C5B-9FFF-2EB3B94118A8} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + LD_24 + LD_24 + v4.6.1 + true + + + + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + true + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + + + + + + + + + + + + + + + + + Forma1.aspx + ASPXCodeBehind + + + Forma1.aspx + + + ASPXCodeBehind + + + + + + + Web.config + + + Web.config + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + + + + True + True + 56191 + / + http://localhost:44355/ + False + False + + + False + + + + + + + + + + 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}. + + + + + \ No newline at end of file diff --git a/DynamicMemory/LD_24/Properties/AssemblyInfo.cs b/DynamicMemory/LD_24/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..53728d5 --- /dev/null +++ b/DynamicMemory/LD_24/Properties/AssemblyInfo.cs @@ -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")] diff --git a/DynamicMemory/LD_24/Web.Debug.config b/DynamicMemory/LD_24/Web.Debug.config new file mode 100644 index 0000000..fae9cfe --- /dev/null +++ b/DynamicMemory/LD_24/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/DynamicMemory/LD_24/Web.Release.config b/DynamicMemory/LD_24/Web.Release.config new file mode 100644 index 0000000..da6e960 --- /dev/null +++ b/DynamicMemory/LD_24/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/DynamicMemory/LD_24/Web.config b/DynamicMemory/LD_24/Web.config new file mode 100644 index 0000000..772f170 --- /dev/null +++ b/DynamicMemory/LD_24/Web.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DynamicMemory/LD_24/packages.config b/DynamicMemory/LD_24/packages.config new file mode 100644 index 0000000..1849141 --- /dev/null +++ b/DynamicMemory/LD_24/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file