Beispiel #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (Validation.ValidateDonor(textBoxName.Text, textBoxBloodGroup.Text, textBoxRh.Text, textBoxMail.Text, textBoxPhone.Text))
            {
                DialogResult dialogResult = MessageBox.Show("Do you want to add new Donor?", "Adding new Donor", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    var Donor = new Donor()
                    {
                        Name        = textBoxName.Text,
                        BloodGroup  = textBoxBloodGroup.Text,
                        RH          = textBoxRh.Text,
                        MailAdress  = textBoxMail.Text,
                        PhoneNumber = textBoxPhone.Text
                    };

                    GetDataOps.AddDonor(Donor);
                    frm.dataGridViewDonors.DataSource = GetDataOps.GetAllDonnors();
                }
                else if (dialogResult == DialogResult.No)
                {
                }
            }
            else
            {
                MessageBox.Show("Error! Entries aren't good");
            }
        }
Beispiel #2
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            if (Validation.ValidateDonor(textBoxName.Text, textBoxBloodGroup.Text, textBoxRh.Text, textBoxMail.Text, textBoxPhone.Text))
            {
                DialogResult dialogResult = MessageBox.Show("Do you want to Upate Donor?", "Updating Donor", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    GetDataOps.UpdateDonor(GetDataOps.DonorUpdateId, textBoxName.Text, textBoxBloodGroup.Text, textBoxRh.Text, textBoxMail.Text, textBoxPhone.Text);
                    frm.dataGridViewDonors.DataSource = GetDataOps.GetAllDonnors();
                }

                else if (dialogResult == DialogResult.No)
                {
                }
            }
            else
            {
                MessageBox.Show("Error! Entries are not good");
            }
        }
        private void deleteDonorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                GetDataOps.DonorUpdateId = int.Parse(dataGridViewDonors.SelectedCells[0].Value.ToString());
                DialogResult dialogResult = MessageBox.Show("Are you sure?", "Deleting Donor", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    GetDataOps.DeleteDonor(GetDataOps.DonorUpdateId);
                    dataGridViewDonors.DataSource = GetDataOps.GetAllDonnors();
                }

                else if (dialogResult == DialogResult.No)
                {
                }
            }
            catch (Exception)
            {
                MessageBox.Show("You must select Id of Donor or whole row");
            }
        }
 private void listAllDonorsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     dataGridViewDonors.DataSource = GetDataOps.GetAllDonnors();
 }