Заполнение переменных класса из TextBox - вопрос №3140887

Необходимо заполнить класс из textbox, то есть я ввожу скажем имя класса TSupplier(поставщик), и оно заполняет класс TSupplierr переменную supplier_name. Не уверен, что код самих классов удачно переделан из C++ в C#, но программа запускается. Имеется 2 формы:
Первая форма — 1 кнопка «Заполнить поставку» с переходом на вторую форму
Вторая форма — поля для заполнения:
Имя поставщика (TSupplier supplier_name)
Имя материала (TMaterial mat_name)
Имя рабочего (TWorkman w_name)


Как я понял, должна вызываться функция set_name во всех случаях.
Но к сожалению из за незнания синтаксиса не могу реализовать.
Желательно подробные советы, где что и почему

 

  1. usingSystem;
  2. usingSystem.Collections.Generic;
  3. usingSystem.Linq;
  4. usingSystem.Threading.Tasks;
  5. usingSystem.Windows.Forms;
  6.  
  7. namespaceSklad
  8. {
  9.     staticclassProgram
  10.     {
  11.         [STAThread]
  12.         staticvoidMain()
  13.         {
  14.             Application.EnableVisualStyles();
  15.             Application.SetCompatibleTextRenderingDefault(false);
  16.             Application.Run(newForm1());
  17.         }
  18. classTSupplier {
  19.     intid;
  20.     stringname;
  21.     voidset_name(stringsupplier_name)
  22.     {
  23.         name =supplier_name;
  24.     }
  25.  
  26.     stringget_name(){returnname;}
  27.  
  28.     voidset_id(intsupplier_id)
  29.     {
  30.         id =supplier_id;
  31.     }
  32.  
  33.     intget_id(){returnid;}
  34.  
  35.  
  36. };
  37.  
  38. classTMaterial {
  39.     inttotal;
  40.     stringclassi;
  41.     intid;
  42.     stringname;
  43.     voidset_total(intmat_total)
  44.     {
  45.         total =mat_total;
  46.     }
  47.  
  48.     intget_total(){returntotal;}
  49.  
  50.     voidset_name(stringmat_name)
  51.     {
  52.         name =mat_name;
  53.     }
  54.  
  55.     stringget_name(){returnname;}
  56.  
  57.     voidset_id(intmat_id)
  58.     {
  59.         id =mat_id;
  60.     }
  61.  
  62.     intget_id(){returnid;}
  63.  
  64.     voidset_classi(stringmat_class)
  65.     {
  66.         classi =mat_class;
  67.     }
  68.     stringget_class(){returnclassi;}
  69. };
  70.  
  71. classTWorkman{
  72.     intid;
  73.     stringname;
  74.     voidset_id(intw_id)
  75.     {
  76.         id =w_id;
  77.     }
  78.     intget_id(){returnid;}
  79.  
  80.     voidset_name(stringw_name)
  81.     {
  82.         name =w_name;
  83.     }
  84.     stringget_name(){returnname;}
  85.  
  86. };
  87.  
  88. classTStorekeeper{
  89.     intid;
  90.     stringname;
  91.  
  92.     voidset_name(stringstorek_name)
  93.     {
  94.         name =storek_name;
  95.     }
  96.     stringget_name(){returnname;}
  97.  
  98.     voidset_id(intstorek_id)
  99.     {
  100.         id =storek_id;
  101.     }
  102.     intget_id(){returnid;}
  103.  
  104. };
  105.  
  106. classTSupply{
  107.  
  108.     intid;
  109.     TMaterial material;
  110.     TSupplier supplier;
  111.     TWorkman workman;
  112.  
  113.     voidset_id(ints_id)
  114.     {
  115.         id =s_id;
  116.     }
  117.     intget_id(){returnid;}
  118.  
  119.     voidset_supplier(TSupplier supplierr)
  120.     {
  121.         this.supplier=supplierr;
  122.     }
  123.  
  124.     voidset_workman(TWorkman workmann)
  125.     {
  126.         this.workman=workmann;
  127.     }
  128.  
  129.     voidset_material(TMaterial materiall)
  130.     {
  131.         this.material=materiall;
  132.     }
  133. };
  134.  
  135. classTStockpilling{
  136.     intid;
  137.     TSupply sup;
  138.     TStorekeeper strkpr;
  139.     stringdate;
  140.     TMaterial mat;
  141.  
  142.     voidset_id(intStP_id)
  143.     {
  144.         id =StP_id;
  145.     }
  146.  
  147.     voidset_date(stringstockpilling_date)
  148.     {
  149.         date =stockpilling_date;
  150.     }
  151.     voidset_supply(TSupply SP)
  152.     {
  153.         this.sup=SP;
  154.     }
  155.     voidset_storekeeper(TStorekeeper storekeeper)
  156.     {
  157.         this.strkpr=storekeeper;
  158.     }
  159.  
  160.     voidget_date()
  161.     {
  162.         Console.WriteLine(" Дата: {date} ");
  163.     }
  164.     voidget_id()
  165.     {
  166.         Console.WriteLine(" ID оприходования: {id} ");
  167.     }
  168.     voidget_strkpr()
  169.     {
  170.         Console.WriteLine(" Имя кладовщика: {strkpr.name} ");
  171.     }
  172.     voidget_nmat()
  173.     {
  174.         Console.WriteLine(" Материал: {sup.material.name} ");
  175.     }
  176.     voidget_nsupplier()
  177.     {
  178.         Console.WriteLine(" Имя поставщика: {sup.supplier.name} ");
  179.     }
  180.  
  181.  
  182.     voidget_info_spg()
  183.     {
  184.         get_date();
  185.         get_id();
  186.         get_strkpr();
  187.         get_nmat();
  188.         get_nsupplier();
  189.     }
  190. };
  191. }
  192. }


изображение из вопроса

24.01.19
0 ответов
Ответов пока нет
Посмотреть всех экспертов из раздела Технологии > .Net/C#
Пользуйтесь нашим приложением Доступно на Google Play Загрузите в App Store