Ejemplo n.º 1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (radioNam.Checked == true)
            {
                gioiTinh = "Nam";
            }
            else
            {
                gioiTinh = "Nữ";
            }

            if (Them)
            {
                try
                {
                    // Thực hiện lệnh
                    bl.Them(this.txtMaNV.Text, this.txtTen.Text, this.ngaySinh.Value,
                            gioiTinh, this.txtDiaChi.Text, this.txtSDT.Text, this.txtCMND.Text, ref err);
                    // Load lại dữ liệu trên DataGridView
                    LoadData();
                    // Thông báo
                    MessageBox.Show("Đã thêm xong!");
                }
                catch (SqlException)
                {
                    MessageBox.Show("Không thêm được. Lỗi rồi!");
                }
            }
            else
            {
                // Thực hiện lệnh
                bl.CapNhat(this.txtMaNV.Text, this.txtTen.Text, this.ngaySinh.Value,
                           this.radioNam.Text, this.txtDiaChi.Text, this.txtSDT.Text, this.txtCMND.Text, ref err);
                // Load lại dữ liệu trên DataGridView
                LoadData();
                // Thông báo
                MessageBox.Show("Đã sửa xong!");
            }
            // Đóng kết nối
        }