Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string   name     = txbName.Text;
            DateTime birthday = dtpBirthDay.Value;
            string   address  = txbAddress.Text;
            string   phone    = txbPhone.Text;
            string   email    = txbEmail.Text;
            string   topic    = txbTopic.Text;
            string   country  = txbCountry.Text;
            int      fee;

            if (txbFee.Text == "")
            {
                fee = 0;
            }
            else
            {
                fee = Convert.ToInt32(txbFee.Text);
            }
            int check;

            if (cbCheck.Checked == true)
            {
                check = 1;
            }
            else
            {
                check = 0;
            }
            AudienceDAO _audience = new AudienceDAO();

            if (_audience.CheckExist(name, phone))
            {
                MessageBox.Show("Người này đã tồn tại", "Thông Báo");
            }
            else
            {
                _audience.AddAudience(name, birthday, address, phone, topic, email, check, country, fee);
                Register next = new Register();
                this.Hide();
                next.Show();
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int     index       = dgvData.CurrentCell.RowIndex;
            DataRow row         = (dgvData.Rows[index].DataBoundItem as DataRowView).Row;
            string  name        = row["Name"].ToString();
            string  phonenumber = row["PhoneNumber"].ToString();

            if (flag == 1)
            {
                InstructorDAO _instructorDAO = new InstructorDAO();
                _instructorDAO.DeleteData(name, phonenumber);
            }
            else if (flag == 2)
            {
                GuestDAO _guest = new GuestDAO();
                _guest.DeleteData(name, phonenumber);
            }
            else
            {
                AudienceDAO _audience = new AudienceDAO();
                _audience.DeleteData(name, phonenumber);
            }
            ShowData();
        }