Example #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            this.Close();
            frmThemKhoa frm = new frmThemKhoa();

            frm.Show();
        }
        private void btnThemKhoa_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = KetNoi.str;
            con.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandText = "INSERT INTO Khoa VALUES('" + txtMaKhoa.Text + "','" + txtTenKhoa.Text + "')";
            cmd.ExecuteNonQuery();
            DialogResult result;

            result = MessageBox.Show("THÊM DỮ LIỆU THÀNH CÔNG", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            if (result == DialogResult.OK)
            {
                this.Close();
                frmThemKhoa frm = new frmThemKhoa();
                frm.Show();
            }
        }