コード例 #1
0
        private void btnRegister_Click_1(object sender, EventArgs e)
        {
            customer = new Customer();
            Contract contract = new Contract();

            string   name     = txtName.Text;
            string   surname  = txtSurname.Text;
            string   password = txtPassword.Text;
            string   email    = txtEmail.Text;
            DateTime date     = dtpBirthday.Value.Date;

            if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(surname) || String.IsNullOrEmpty(email) && String.IsNullOrEmpty(password))
            {
                MessageBox.Show("All inputs must be filled", "Error registering",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
            else
            {
                foreach (RadioButton r in buttons)
                {
                    if (r.Checked == true)
                    {
                        Audioplatform p     = DataProvider.GetPlatform(r.Name);
                        DateTime      dtend = DateTime.Now;
                        DateTime      end   = new DateTime(2020, dtend.Month, dtend.Day);
                        DataProvider.AddContract(DateTime.Now.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"), r.Name, name, surname);
                        DataProvider.AddCustomer(name, surname, email, date.ToString("yyyy-MM-dd"), password, r.Name, p.price, DateTime.Now.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"));
                        MessageBox.Show("You have successfully registred on audio platform " + p.name + " which costs" + p.price, "Wellcome!",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
            }
            this.Close();
        }