Example #1
0
        private void DonorRegister_Click(object sender, EventArgs e)
        {
            DonorsService donorsService = new DonorsService();
            Donors        donors        = new Donors();

            donors.Name       = DonorName.Text;
            donors.Address    = DonorAddress.Text;
            donors.Age        = Convert.ToInt32(DonorAge.Text);
            donors.Gender     = (string)DonorGender.SelectedItem;
            donors.Phone      = DonorPhone.Text;
            donors.Email      = DonorEmail.Text;
            donors.BloodGroup = (string)DonorBloodGroup.SelectedItem;
            donors.Weight     = Convert.ToInt32(DonorWeight.Text);


            if (donorsService.SendDonorEmail(donors.Email))
            {
                if (donorsService.Add(donors) > 0)
                {
                    MessageBox.Show("Record Added!");
                }
            }
            else
            {
                MessageBox.Show("Error!");
            }
        }
        private void DonorRegister_Click(object sender, EventArgs e)
        {
            DonorsService donorsService = new DonorsService();
            Donors        donors        = new Donors();
            Blood         blood         = new Blood();

            int count = Convert.ToInt32(donorsService.RowCount());

            donors.Id         = count += 101;
            donors.Name       = DonorName.Text;
            donors.Address    = DonorAddress.Text;
            donors.Age        = Convert.ToInt32(DonorAge.Text);
            donors.Gender     = (string)DonorGender.SelectedItem;
            donors.Phone      = DonorPhone.Text;
            donors.Email      = DonorEmail.Text;
            donors.BloodGroup = (string)DonorBloodGroup.SelectedItem;
            donors.Weight     = Convert.ToInt32(DonorWeight.Text);

            DateTime dateTime = DateTime.UtcNow.Date;

            donors.Date = dateTime.ToString("yyyy/MM/dd");

            BloodService bloodService = new BloodService();

            string bloodGroup = (string)DonorBloodGroup.SelectedItem;
            int    quantity   = bloodService.GetCurrentQuantity(bloodGroup);

            quantity += 1;
            bloodService.Add(bloodGroup, quantity);


            if (donorsService.SendDonorEmail(donors.Email) && DonorPhone.Text.Length == 11)
            {
                if (donorsService.Add(donors) > 0)
                {
                    MessageBox.Show("Record Added!");
                }
            }


            else
            {
                MessageBox.Show("Error! Please Check your Mail or Provide a Valid Phone number");
            }
        }