Advertisement
Guest User

1234

a guest
Dec 8th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.28 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.         Tovar[] MyStorage;
  20.         int Size; //Кол-во различных товаров различных видов
  21.         public Form1()
  22.         {
  23.             InitializeComponent();
  24.             string[] str; //массив строк
  25.                           //считывание данных из файла в массив строк
  26.             str = File.ReadAllLines(@"d:\storage.txt");
  27.             int n = str.Length; //определение количества элементов в массиве
  28.                                 //каждый вопрос в файле занимает 7 строк
  29.             Size = n / 4; //определение количества вопросов в файле
  30.             MyStorage = new Tovar[Size];
  31.             int m = 0;
  32.             //заполнение массива товаров
  33.             for (int j = 0; j < Size; j++)
  34.             {
  35.                 MyStorage[j].Name = str[m]; m++;
  36.                 MyStorage[j].Price = Convert.ToInt32(str[m]); m++;
  37.                 MyStorage[j].Sort = str[m]; m++;
  38.                 MyStorage[j].Amount = Convert.ToInt32(str[m]); m++;
  39.             }
  40.             Label label1 = new Label();
  41.             label1.Text = "Введите минимальную стоимость товара";
  42.             label1.Location = new Point(15, 15);
  43.             label1.Size = new Size(150,15);
  44.             this.Controls.Add(label1);
  45.             TextBox textBox1 = new TextBox();
  46.             textBox1.Location = new Point(15, 40);
  47.             this.Controls.Add(textBox1);
  48.             Button button1 = new Button();
  49.             button1.Text = "ОК";
  50.             button1.Location = new Point(15, 70);
  51.             button1.Click += Button1_Click;
  52.             this.Controls.Add(button1);
  53.         }
  54.  
  55.         private void Button1_Click(object sender, EventArgs e)
  56.         {
  57.            
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement