示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(CString);

            con.Open();

            SqlCommand exe = new SqlCommand("INSERT INTO RubricLevel(RubricId,Details,MeasurementLevel) values('" + Convert.ToInt32(comboBox1.SelectedValue) + "','" + Details.Text + "','" + Convert.ToInt32(comboBox2.SelectedItem) + "')", con);

            exe.ExecuteNonQuery();
            MessageBox.Show("Added!");
            this.Hide();
            Form10 frm = new Form10();

            frm.Show();
        }
示例#2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection con = new SqlConnection(CString);

            con.Open();

            if (e.ColumnIndex == dataGridView1.Columns["del"].Index)
            {
                int        row = e.RowIndex;
                int        sel = Convert.ToInt32(dataGridView1.Rows[row].Cells["Id"].Value);
                SqlCommand exe = new SqlCommand("DELETE FROM RubricLevel WHERE Id = '" + sel + "'", con);
                exe.ExecuteNonQuery();
                MessageBox.Show("Deleted!");
                this.Hide();
                Form10 form = new Form10();
                form.Show();
            }
        }