|
Главная | Правила | Регистрация | Дневники | Справка | Пользователи | Календарь | Поиск | Сообщения за день | Все разделы прочитаны |
|
Опции темы | Опции просмотра |
08.05.2016, 19:36 | #1 (permalink) |
Новичок
Регистрация: 08.05.2016
Сообщений: 1
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
|
Блок-схемы по функциям C#
Функции ДОБАВИТЬ Код:
public void add() { if (dataGridView1.RowCount < 50)//максимум значений { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") MessageBox.Show("Fill in the fields"); else { double x = -1; int y = -1; for (int i = 0; i < dataGridView1.RowCount; i++)//проверка на тот же код товара { if (dataGridView1.Rows[i].Cells[0].Value.ToString() == textBox1.Text) { x = 0.5; } } for (int j = 0; j < dataGridView1.RowCount; j++)//если уже есть такой товар { if (dataGridView1.Rows[j].Cells[0].Value.ToString() == textBox1.Text && dataGridView1.Rows[j].Cells[1].Value.ToString() == textBox2.Text && dataGridView1.Rows[j].Cells[3].Value.ToString() == textBox4.Text) { y = j; x = 0.6; } } if (x == 0.6)//если есть такая строка, добавляем { dataGridView1.Rows[y].Cells[2].Value = Convert.ToInt32(dataGridView1[2, y].Value) + int.Parse(textBox3.Text); textBox1.Clear(); ; textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); MessageBox.Show("The quantity of goods increased"); prov = true; } else if (x == 0.5)//если есть такой код { MessageBox.Show("Use code"); } else { dataGridView1.Rows.Add(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); MessageBox.Show("Added"); prov = true; }}} else MessageBox.Show("The maximum amount of goods"); } УДАЛИТЬ Код:
public void delete() { if (dataGridView1.RowCount != 0) { int ind = dataGridView1.SelectedCells[0].RowIndex; dataGridView1.Rows.RemoveAt(ind); MessageBox.Show("Deleted"); prov = true; } else MessageBox.Show("Nothing to remove!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } СОРТИРОВКА Код:
public void sort() { for (int i = 0; i < dataGridView1.RowCount; i++) { for (int j = 0; j < dataGridView1.RowCount; j++) { if (Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value) < Convert.ToInt32(dataGridView1.Rows[j].Cells[0].Value)) { var kod1 = dataGridView1.Rows[i].Cells[0].Value; var name1 = dataGridView1.Rows[i].Cells[1].Value; var kol1 = dataGridView1.Rows[i].Cells[2].Value; var cena1 = dataGridView1.Rows[i].Cells[3].Value; dataGridView1.Rows[i].Cells[0].Value = dataGridView1.Rows[j].Cells[0].Value; dataGridView1.Rows[i].Cells[1].Value = dataGridView1.Rows[j].Cells[1].Value; dataGridView1.Rows[i].Cells[2].Value = dataGridView1.Rows[j].Cells[2].Value; dataGridView1.Rows[i].Cells[3].Value = dataGridView1.Rows[j].Cells[3].Value; dataGridView1.Rows[j].Cells[0].Value = kod1; dataGridView1.Rows[j].Cells[1].Value = name1; dataGridView1.Rows[j].Cells[2].Value = kol1; dataGridView1.Rows[j].Cells[3].Value = cena1; } } } MessageBox.Show("Sorted"); prov = true; } СОХРАНИТЬ Код:
public void save() { StreamWriter scale = new StreamWriter("scale.txt"); for (int i = 0; i < dataGridView1.RowCount; i++) { for (int j = 0; j < dataGridView1.ColumnCount; j++) { scale.Write(dataGridView1.Rows[i].Cells[j].Value.ToString() + "~"); } if (i != dataGridView1.RowCount - 1) scale.WriteLine(); } scale.Close(); MessageBox.Show("Saved"); prov = false; } |
08.05.2016, 19:36 | |
Helpmaster
Member
Регистрация: 08.03.2016
Сообщений: 0
|
Если есть свободная минутка - можете посмотреть схожие топики Pascal, блок-схемы Блок-схемы Построение блок-схемы |
Ads | |
Member
Регистрация: 31.10.2006
Сообщений: 40200
Записей в дневнике: 0
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 55070
|
Опции темы | |
Опции просмотра | |
|
|