Форум программистов, компьютерный форум, киберфорум
C# для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.60/5: Рейтинг темы: голосов - 5, средняя оценка - 4.60
0 / 0 / 0
Регистрация: 24.05.2014
Сообщений: 20
1

Описать структуру с именем AGENCY

24.05.2014, 15:41. Показов 1027. Ответов 5
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
. Помогите пожалуйста срочно!!!! ДО ЗАВТРА нужно сдать
Описать структуру с именем AGENCY, содержащую следующие поля:
• NAME – фамилия и инициалы клиента;
• SEX – пол;
• DATE – дата обращения.
• SUMMA – перечисляемая сумма в сомах.
Написать программу, выполняющую следующие действия:
Программа должна обеспечивать:
• начальное формирование данных о всех клиентах агентства;
• содержать функции сортировки в алфавитном порядке по фамилии и по дате обращения;
• вывод на экран информации о клиенте, фамилия которого введена с клавиатуры;
• если такого клиента нет, выдать соответствующее сообщение.
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
24.05.2014, 15:41
Ответы с готовыми решениями:

Описать структуру с именем PRICE
Здраствуйте, вот такая вот задачка на C#, поможете?) Описать структуру с именем PRICE, содержащую...

Описать структуру с именем Bagage
Ребята, помогите, пожалуйста. Кто может скинуть эту программу С# файликом. Описать структуру с...

Описать структуру с именем STUDENT
Описать структуру с именем STUDENT, содержащую следующие поля: - фамилия и инициалы; - номер...

Описать структуру с именем AEROFLOT
Описать структуру с именем AER0FL0T, содержащую следующие поля: • название пункта назначения...

5
Заблокирован
24.05.2014, 16:18 2
Anisik, реализация консоль или винформ? вместо структур классы использовать нельзя? И начальный текстовый файл предоставьте.
0
Заблокирован
24.05.2014, 16:44 3
Используйте класс как структуру.
C#
1
2
3
4
5
6
public class AGENCY{
public string name {get;set;}
public int sex {get;set;}
public string date {get;set;}
public double summa {get;set;}
}
1
Заблокирован
24.05.2014, 23:53 4
Лучший ответ Сообщение было отмечено Anisik как решение

Решение

Anisik, раз ответ я не получил - тогда на мое усмотрение Вроде бы все пункты выполнил.
По совету Rock_STAR, использую его класс-структуру.

//код программы:
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
 
namespace datetime
{
    public partial class Form1 : Form
    {
        string sex;
        string path = @"F:/AGENCY.txt";
        List<AGENCY> sp = new List<AGENCY>();
        public Form1()
        {
            InitializeComponent();
            radioButton1.Checked = true;
            if(File.Exists(path))
            Read();
            dataGridView1.DataSource = sp;
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = sp.OrderByDescending(a => a.name).ToArray();
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = sp.OrderByDescending(a => a.summa).ToArray();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(textBox2.Text) ||
                    String.IsNullOrEmpty(textBox3.Text))
                    throw new ArgumentException("Все поля обязательны к заполнению!");
                sex = "Male";
                if (!radioButton1.Checked) sex = "Female";
                sp.Add(new AGENCY(textBox2.Text, sex, dateTimePicker1.Value.ToShortDateString(),Convert.ToDouble(textBox3.Text)));
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = sp;
 
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
 
        private void Read()
        {
            try
            {
                string[] text = File.ReadAllLines(path);
                foreach (string strp in text)
                {
                    string[] temp = strp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    sp.Add(new AGENCY(temp[0], temp[1], temp[2], Double.Parse(temp[3])));
 
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
 
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            string str = "";
            foreach (AGENCY q in sp)
                str += String.Format("{0};{1};{2};{3}\r\n", q.name,q.sex,q.date,q.summa);
 
            File.WriteAllText(path, str);
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
            var query = sp.Where(a => a.name == textBox1.Text).ToList();
            if (query.Count != 0)
            {
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = query;
            }       
            else
                MessageBox.Show("Сотрудник с таким ФИО не был найден");
        }
 
 
    }
    public class AGENCY
    {
        public string name { get; set; }
        public string sex { get; set; }
        public string date { get; set; }
        public double summa { get; set; }
 
        public AGENCY(string a, string b, string c, double e)
        {
            name = a;
            sex = b;
            date = c;
            summa = e;
        }
    }
 
}
//код конструктора форм:
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
  partial class Form1
    {
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        /// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 
        #region Код, автоматически созданный конструктором форм Windows
 
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        private void InitializeComponent()
        {
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.button4 = new System.Windows.Forms.Button();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox3 = new System.Windows.Forms.TextBox();
            this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
            this.radioButton1 = new System.Windows.Forms.RadioButton();
            this.radioButton2 = new System.Windows.Forms.RadioButton();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            this.SuspendLayout();
            // 
            // dataGridView1
            // 
            this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridView1.Location = new System.Drawing.Point(194, 29);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.Size = new System.Drawing.Size(275, 221);
            this.dataGridView1.TabIndex = 2;
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(59, 141);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 3;
            this.button1.Text = "Добавить:";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // button2
            // 
            this.button2.Location = new System.Drawing.Point(3, 227);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(75, 23);
            this.button2.TabIndex = 4;
            this.button2.Text = "Фамилии:";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            // 
            // button3
            // 
            this.button3.Location = new System.Drawing.Point(113, 227);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(75, 23);
            this.button3.TabIndex = 5;
            this.button3.Text = "Дате:";
            this.button3.UseVisualStyleBackColor = true;
            this.button3.Click += new System.EventHandler(this.button3_Click);
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(3, 170);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(75, 20);
            this.textBox1.TabIndex = 6;
            // 
            // button4
            // 
            this.button4.Location = new System.Drawing.Point(113, 168);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(75, 23);
            this.button4.TabIndex = 7;
            this.button4.Text = "Найти:";
            this.button4.UseVisualStyleBackColor = true;
            this.button4.Click += new System.EventHandler(this.button4_Click);
            // 
            // textBox2
            // 
            this.textBox2.Location = new System.Drawing.Point(59, 30);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(125, 20);
            this.textBox2.TabIndex = 8;
            // 
            // textBox3
            // 
            this.textBox3.Location = new System.Drawing.Point(59, 103);
            this.textBox3.Name = "textBox3";
            this.textBox3.Size = new System.Drawing.Size(125, 20);
            this.textBox3.TabIndex = 9;
            // 
            // dateTimePicker1
            // 
            this.dateTimePicker1.Location = new System.Drawing.Point(59, 56);
            this.dateTimePicker1.Name = "dateTimePicker1";
            this.dateTimePicker1.Size = new System.Drawing.Size(125, 20);
            this.dateTimePicker1.TabIndex = 10;
            // 
            // radioButton1
            // 
            this.radioButton1.AutoSize = true;
            this.radioButton1.Location = new System.Drawing.Point(59, 82);
            this.radioButton1.Name = "radioButton1";
            this.radioButton1.Size = new System.Drawing.Size(48, 17);
            this.radioButton1.TabIndex = 11;
            this.radioButton1.TabStop = true;
            this.radioButton1.Text = "Male";
            this.radioButton1.UseVisualStyleBackColor = true;
            // 
            // radioButton2
            // 
            this.radioButton2.AutoSize = true;
            this.radioButton2.Location = new System.Drawing.Point(125, 82);
            this.radioButton2.Name = "radioButton2";
            this.radioButton2.Size = new System.Drawing.Size(59, 17);
            this.radioButton2.TabIndex = 12;
            this.radioButton2.TabStop = true;
            this.radioButton2.Text = "Female";
            this.radioButton2.UseVisualStyleBackColor = true;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(3, 36);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(30, 13);
            this.label1.TabIndex = 13;
            this.label1.Text = "фио:";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(3, 62);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(33, 13);
            this.label2.TabIndex = 14;
            this.label2.Text = "дата:";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(3, 84);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(28, 13);
            this.label3.TabIndex = 15;
            this.label3.Text = "пол:";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(0, 106);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(43, 13);
            this.label4.TabIndex = 16;
            this.label4.Text = "сумма:";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(64, 202);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(84, 13);
            this.label5.TabIndex = 17;
            this.label5.Text = "сортировка по:";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(481, 262);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.radioButton2);
            this.Controls.Add(this.radioButton1);
            this.Controls.Add(this.dateTimePicker1);
            this.Controls.Add(this.textBox3);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.button4);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.dataGridView1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
 
        }
 
        #endregion
 
        private System.Windows.Forms.DataGridView dataGridView1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button button3;
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Button button4;
        private System.Windows.Forms.TextBox textBox2;
        private System.Windows.Forms.TextBox textBox3;
        private System.Windows.Forms.DateTimePicker dateTimePicker1;
        private System.Windows.Forms.RadioButton radioButton1;
        private System.Windows.Forms.RadioButton radioButton2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
    }
0
Заблокирован
24.05.2014, 23:56 5
Лучший ответ Сообщение было отмечено Anisik как решение

Решение

Забыл прикрепить скриншот(для большей наглядности), исправляюсь:
Миниатюры
Описать структуру с именем AGENCY  
0
0 / 0 / 0
Регистрация: 24.05.2014
Сообщений: 20
27.05.2014, 21:46  [ТС] 6
spasibo
0
27.05.2014, 21:46
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
27.05.2014, 21:46
Помогаю со студенческими работами здесь

Описать структуру с именем NOTE
Помогите плиз с задачкой или подкинте идею. Желательно в формах

Описать структуру с именем STUDENT
Помогите исправить ошибки пожалуйста. Задание: Описать структуру с именем STUDENT, содержащую...

Описать структуру с именем ZNAK
Описать структуру с именем ZNAK, содержащую следующие поля: фамилия, имя; знак Зодиака; день...

Описать структуру с именем AEROFLOT
Описать структуру с именем AEROFLOT, содержащую следующие поля: □ название пункта назначения...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
6
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru