Ejemplo n.º 1
0
        private void Attendeeschedule_Load(object sender, EventArgs e)
        {
            Attendeebll attendee = new Attendeebll();
            DataTable   dt       = attendee.datagridload();

            dgAttendee.DataSource = dt;
        }
        private void dgAttendee_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            Attendeebll attendee = new Attendeebll();

            int columnIndex = dgAttendee.CurrentCell.ColumnIndex;
            int attendeid   = int.Parse(dgAttendee.CurrentRow.Cells["aid"].Value.ToString());

            attendee.Id = attendeid;

            if (dgAttendee.CurrentRow.Cells[columnIndex].Value.ToString() == "Edit")
            {
                DataTable dts = attendee.loaddata();
                txtFirst.Text  = dts.Rows[0][0].ToString();
                txtLast.Text   = dts.Rows[0][1].ToString();
                txtEmail.Text  = dts.Rows[0][2].ToString();
                cmbTicket.Text = dts.Rows[0][3].ToString();
                txtNumber.Text = dts.Rows[0][4].ToString();

                btnAdd.Text = "Update";
            }
            else if (dgAttendee.CurrentRow.Cells[columnIndex].Value.ToString() == "Delete")
            {
                DialogResult confirmResult = MessageBox.Show("Are you sure to delete this item??", "Confirm Delete?", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    attendee.Delete();
                    DataTable dt = attendee.datagridload();
                    dgAttendee.DataSource = dt;
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtFirst.Text == "")
            {
                MessageBox.Show("Please enter a firstname");
            }
            else if (txtLast.Text == "")
            {
                MessageBox.Show("Please enter a lastname");
            }
            else if (txtEmail.Text == "")
            {
                MessageBox.Show("Please enter a Email");
            }
            else if (txtNumber.Text == "")
            {
                MessageBox.Show("Please enter a Number of days");
            }
            else if (cmbTicket.Text == "")
            {
                MessageBox.Show("Please select a type of ticket");
            }
            else
            {
                if (btnAdd.Text == "Add")
                {
                    Attendeebll attendee = new Attendeebll();

                    attendee.Firstname     = txtFirst.Text;
                    attendee.Lastname1     = txtLast.Text;
                    attendee.Numberofdays  = txtNumber.Text;
                    attendee.Email1        = txtEmail.Text;
                    attendee.Typeofticket1 = cmbTicket.Text;
                    attendee.add();
                    MessageBox.Show("Successful");
                    txtFirst.Text = txtLast.Text = txtEmail.Text = txtNumber.Text = "";
                    Attendeebll attende = new Attendeebll();
                    DataTable   dt      = attende.datagridload();
                    dgAttendee.DataSource = dt;
                }
                else if (btnAdd.Text == "Update")
                {
                    Attendeebll attendee = new Attendeebll();
                    attendee.update();
                    MessageBox.Show("Updated");
                    btnAdd.Text   = "Add";
                    txtFirst.Text = txtLast.Text = txtEmail.Text = txtNumber.Text = "";
                    Attendeebll attende = new Attendeebll();
                    DataTable   dt      = attende.datagridload();
                    dgAttendee.DataSource = dt;
                }
            }
        }