private void ProvStudyOrg() { string sqlSU = "SELECT Id FROM Organizations WHERE StudyOrg = 1"; using (SqlConnection connection = new SqlConnection(Strings.ConStr)) { connection.Open(); SqlCommand sql = new SqlCommand(sqlSU, connection); SqlDataReader reader = sql.ExecuteReader(); if (!reader.HasRows) { MessageBox.Show("В базе данных нет учебной организации, в которой происходит учет!\n" + "Требуется внести ее в базу данных!"); SettingOrganizations setting = new SettingOrganizations(); setting.lHeader.Text = "Добавление учебной организации"; setting.AddRed = true; setting.cbStatus.Text = "Работающая"; setting.checkBox1.Visible = true; setting.checkBox1.Checked = true; setting.cbStatus.Enabled = false; setting.ShowDialog(); if (!setting.resOrg) { MessageBox.Show("Данные о учебной организации не внесены!\n" + "Надеюсь, что в следущий раз получится)"); Close(); } } OrgLoadData(); } }
private void button5_Click(object sender, EventArgs e) { SettingOrganizations setting = new SettingOrganizations(); setting.lHeader.Text = "Добавление организации"; setting.AddRed = true; setting.cbStatus.Text = "Работающая"; setting.ShowDialog(); OrgLoadData(); }
private void button4_Click(object sender, EventArgs e) { if (colOrg) { if (Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value) > -1) { SettingOrganizations setting = new SettingOrganizations(); setting.lHeader.Text = "Редактирование организации"; setting.AddRed = false; setting.SelectedOrgId = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); setting.tbName.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[1].Value); setting.tbAddress.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[2].Value); setting.dtpDateReg.Value = DateTime.Parse(Convert.ToString(dataGridView1.CurrentRow.Cells[3].Value)); setting.tbDirector.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[4].Value); setting.tbOGRN.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[5].Value); setting.tbINN.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[6].Value); setting.tbKPP.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[7].Value); setting.textBox3.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[12].Value); setting.textBox2.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[13].Value); setting.textBox1.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[14].Value); string status = Convert.ToString(dataGridView1.CurrentRow.Cells[10].Value); if (Convert.ToString(dataGridView1.CurrentRow.Cells[11].Value) == "1") { setting.cbStatus.Enabled = false; setting.cbStatus.Text = "Работающая"; } else { if (status == "1") { setting.cbStatus.Text = "Работающая"; } else if (status == "2") { setting.cbStatus.Text = "Не работающая"; } } setting.ShowDialog(); OrgLoadData(); } else { MessageBox.Show("Не выбранна запись для редактирования!"); } } else { MessageBox.Show("Нет записей для редактирования!"); } }
private void изменитьОбразовательнуюОрганизациюToolStripMenuItem_Click(object sender, EventArgs e) { int oldId = -1; string sqlSU = "SELECT Id FROM Organizations WHERE StudyOrg = 1"; using (SqlConnection connection = new SqlConnection(Strings.ConStr)) { connection.Open(); SqlCommand sql = new SqlCommand(sqlSU, connection); SqlDataReader reader = sql.ExecuteReader(); if (reader.HasRows) { reader.Read(); oldId = reader.GetInt32(0); } } SettingOrganizations setting = new SettingOrganizations(); setting.lHeader.Text = "Добавление учебной организации"; setting.AddRed = true; setting.cbStatus.Text = "Работающая"; setting.checkBox1.Visible = true; setting.checkBox1.Checked = true; setting.cbStatus.Enabled = false; setting.ShowDialog(); if (setting.resOrg) { string sqlDelOrg = String.Format("DELETE FROM Organizations WHERE Id = '{0}'", oldId); using (SqlConnection connection = new SqlConnection(Strings.ConStr)) { connection.Open(); SqlCommand command = new SqlCommand(sqlDelOrg, connection); command.ExecuteNonQuery(); } } OrgLoadData(); }