private void load_32_Click(object sender, EventArgs e) { StreamReader file = new StreamReader(@"a:\gitjub\курсач\load_32.txt"); string name; tar.collisions = 0; tariph.collisions = 0; while (file.Peek() > -1) { name = file.ReadLine(); tar.add(tar.getkey(name, ""), name, 3, 0, null); tariph.add(name, 3, 0, null); } for (int j = 0; j < tar.max_elements; j++) { if (tar.free(tar.mas[j])) { continue; } else { dataGridView1.Rows.Add(tar.mas[j].hash.ToString(), tar.mas[j].name); //dataGridView1.Rows[i].Cells[0].Value = tar.mas[j].hash.ToString(); //dataGridView1.Rows[i].Cells[1].Value = tar.mas[j].name; } } for (int j = 0; j < tariph.max_elements; j++) { if (tariph.free(tariph.mas[j])) { continue; } else { dataGridView2.Rows.Add(tariph.mas[j].hash.ToString(), tariph.mas[j].name); //dataGridView2.Rows[i].Cells[0].Value = tariph.mas[j].hash.ToString(); //dataGridView2.Rows[i].Cells[1].Value = tariph.mas[j].name; } } collis_1.Text = tar.collisions.ToString(); collis_2.Text = tariph.collisions.ToString(); }
private void button1_Click(object sender, EventArgs e) { int type = 0; int error_number = 0; if ((checkBoxAddTariphInternet.Checked) && (checkBoxAddTariphTV.Checked)) { type = 2; } else if ((checkBoxAddTariphInternet.Checked) && !(checkBoxAddTariphTV.Checked)) { type = 1; } else if (!(checkBoxAddTariphInternet.Checked) && (checkBoxAddTariphTV.Checked)) { type = 3; } else { error_number = 1; } if (!check_for_int(tariph_cost.Text)) { error_number = 2; } if (!check_for_int(tariph_speed.Text)) { error_number = 2; } else if (tariph_title.Text == "" || tariph_provider.Text == "" || tariph_cost.Text == "") //|| tariph_speed.Text == "") { error_number = 1; //message_box(error_number); } else if (tariph_title.Text.Length > 30 || tariph_provider.Text.Length > 30 || tariph_cost.Text.Length > 8 || tariph_speed.Text.Length > 10) { error_number = 2; message_box(error_number); } else if (type == 3) { if (tariph_speed.Text != "") { if (Convert.ToInt32(tariph_speed.Text) != 0) { error_number = 2; } } } else if ((Convert.ToInt32(tariph_speed.Text) > 200) && (Convert.ToInt32(tariph_speed.Text) < 0)) { error_number = 2; message_box(error_number); } else if ((checkBoxAddTariphInternet.Checked) && ((Convert.ToInt32(tariph_speed.Text) > 200))) { error_number = 2; } if (error_number == 0) { bool can_add = provider.add_tariph(tariph_title.Text, Convert.ToInt32(tariph_cost.Text), tariph_provider.Text); if (!can_add) { if (provider.find(tariph_provider.Text) != null) { error_number = 4; } else { error_number = 3; } } if (tariph_speed.Text == "") { tariph.add(tariph.getkey(tariph_title.Text, tariph_provider.Text), tariph_title.Text, type, 0, provider.find(tariph_provider.Text)); } else { tariph.add(tariph.getkey(tariph_title.Text, tariph_provider.Text), tariph_title.Text, type, Convert.ToInt32(tariph_speed.Text), provider.find(tariph_provider.Text)); } } message_box(error_number); tariph_title.Text = tariph_cost.Text = tariph_provider.Text = tariph_speed.Text = ""; checkBoxAddTariphTV.Checked = false; checkBoxAddTariphInternet.Checked = false; }