コード例 #1
0
ファイル: Specialties.cs プロジェクト: Lara87/gradebook
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if ((e.ColumnIndex == 0) && (start.role == 0) || (start.role == 1) || (start.role == 2))
            {
                //del

                if (MessageBox.Show("Вы действительно хотите удалить запись?", "Внимание", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    using (SqlConnection sqlConnection = new SqlConnection(url))
                    {
                        sqlConnection.Open();
                        var           rowIndex = e.RowIndex;
                        var           cell     = dataGridView1.Rows[rowIndex].Cells[2].Value;
                        var           com1     = new SqlCommand(" DELETE FROM Table_Specialty WHERE [Код специальности] = '" + cell + "' ", sqlConnection);
                        SqlDataReader sqldr    = com1.ExecuteReader();
                        dataGridView1.Rows.RemoveAt(rowIndex);
                    }
                    MessageBox.Show("Данные успешно удалены!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            if ((e.ColumnIndex == 1) && (start.role == 0) || (start.role == 1) || (start.role == 2))
            {
                //edit
                SpecialtyInfo specialtyInfo = new SpecialtyInfo(specialtyList[e.RowIndex], false, this);
                specialtyInfo.Show();
            }
        }
コード例 #2
0
ファイル: Specialties.cs プロジェクト: Lara87/gradebook
        private void button1Add_Click(object sender, EventArgs e)
        {
            SpecialtyInfo specialtyInfo = new SpecialtyInfo(null, true, this);

            specialtyInfo.Show();
        }