Advertisement
Guest User

1

a guest
Dec 8th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.36 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using System.IO;
  5.  
  6. namespace Storage
  7. {
  8.     struct Tovar
  9.     {
  10.         public string Name; //наименование
  11.         public double Price; //Стоимость
  12.         public string Sort; //Сорт
  13.         public int Amount; //Количество
  14.     }
  15.  
  16.    
  17.     public partial class Form1 : Form
  18.     {
  19.         public void InitElements()
  20.         {
  21.             Label label1 = new Label();
  22.             label1.Text = "Введите минимальную стоимость товара";
  23.             label1.Location = new Point(15, 15);
  24.             label1.Size = new Size(150, 15);
  25.             this.Controls.Add(label1);
  26.             TextBox textBox1 = new TextBox();
  27.             textBox1.Location = new Point(15, 40);
  28.             this.Controls.Add(textBox1);
  29.             Button button1 = new Button();
  30.             button1.Text = "ОК";
  31.             button1.Location = new Point(15, 70);
  32.             button1.Click += Button1_Click;
  33.             this.Controls.Add(button1);
  34.         }
  35.         Tovar[] MyStorage;
  36.         int Size; //Кол-во различных товаров различных видов
  37.         int MinPrice;
  38.         public Form1()
  39.         {
  40.             InitializeComponent();
  41.             string[] str; //массив строк
  42.                           //считывание данных из файла в массив строк
  43.             str = File.ReadAllLines(@"d:\storage.txt");
  44.             int n = str.Length; //определение количества элементов в массиве
  45.                                 //каждый вопрос в файле занимает 7 строк
  46.             Size = n / 4; //определение количества вопросов в файле
  47.             MyStorage = new Tovar[Size];
  48.             int m = 0;
  49.             //заполнение массива товаров
  50.             for (int j = 0; j < Size; j++)
  51.             {
  52.                 MyStorage[j].Name = str[m]; m++;
  53.                 MyStorage[j].Price = Convert.ToInt32(str[m]); m++;
  54.                 MyStorage[j].Sort = str[m]; m++;
  55.                 MyStorage[j].Amount = Convert.ToInt32(str[m]); m++;
  56.             }
  57.  
  58.         }
  59.  
  60.         private void Button1_Click(object sender, EventArgs e)
  61.         {
  62.            
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement