private void button2_Click(object sender, EventArgs e)
        {
            string chuoi;

            chuoi = txtMaKhoa.Text;
            if (kiemtratontai())
            {
                MessageBox.Show("Mã khoa đã tồn tại. Vui lòng nhập lại !");
            }
            else
            {
                if (txtMaKhoa.Text == "")
                {
                    MessageBox.Show("Bạn phải nhập mã khoa");
                }
                //else if (chuoi.Length != 4)
                //{
                //    MessageBox.Show("Bạn phải nhập đúng 4 ký tự");
                //}
                else
                {
                    string     them    = "insert into DMKhoa values ('" + txtMaKhoa.Text + "','" + txtTenKhoa.Text + "','" + txtDiaChiKhoa.Text + "')";
                    SqlCommand comThem = new SqlCommand(them, con);
                    comThem.ExecuteNonQuery();
                    getdata();
                    MessageBox.Show("Thêm mới thành công ");
                    this.Close();
                    frmDMKhoa tg = new frmDMKhoa();
                    tg.ShowDialog();
                }
            }
        }
Esempio n. 2
0
        private void đầuSáchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDMKhoa dmk = new frmDMKhoa();

            dmk.Show();
        }