예제 #1
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     //Check Username & Password
     //Retrieve ID
     if (txtUsername.Text != "" && txtPassword.Text != "")
     {
         var acc = new PatientService.AccountCredentials();
         acc.username = txtUsername.Text;
         acc.password = txtPassword.Text;
         string   response = client.Login(acc);
         string[] tokens   = response.Split('|');
         if (tokens[0] == "200")
         {
             //if Authenticated..
             int ID = 0;
             this.Hide();
             var form1 = new Form1(Convert.ToInt32(tokens[1]));
             form1.Closed += (s, args) => this.Close();
             form1.Show();
         }
         else
         if (tokens[0] == "422")
         {
             MessageBox.Show(tokens[1] + "\nUsername/Password Mismatch!");
         }
         else
         {
             MessageBox.Show(tokens[1] + "\nPlease Register First!");
         }
     }
     else
     {
         MessageBox.Show("Username/ Password could not be empty!");
     }
     //
 }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtName.Text != "" && comboBox1.Text != "" && txtUser.Text != "" && txtPass.Text != "")
            {
                if (txtPass.Text.Length >= 6)
                {
                    var p = new PatientService.Patient();
                    p.Name    = txtName.Text;
                    p.DOB     = dateTimePicker1.Value;
                    p.Gender  = comboBox1.Text;
                    p.Address = rtbAddress.Text;
                    p.Job     = txtJob.Text;

                    if (checkedListBox1.GetItemChecked(0))
                    {
                        p.Smoker = "Smoker";
                    }
                    else
                    {
                        p.Smoker = "Non-Smoker";
                    }


                    if (checkedListBox1.GetItemChecked(1))
                    {
                        p.Alcoholic = "Alcoholic";
                    }
                    else
                    {
                        p.Alcoholic = "Non-Alcoholic";
                    }
                    var acc = new PatientService.AccountCredentials();
                    acc.username = txtUser.Text;
                    acc.password = txtPass.Text;

                    //TODO: Send acc and p to the server (DONE)
                    string response = client.register(p, acc);
                    if (response == "200")
                    {
                        //Close form
                        this.Hide();
                        var main = new Main(); // (ID);
                        main.Closed += (s, args) => this.Close();
                        main.Show();
                    }

                    else
                    {
                        MessageBox.Show("Error Occured\nPlease Try Again Later");
                    }
                }
                else
                {
                    MessageBox.Show("Please Enter a Password that has at least 6 Characters!");
                }
            }
            else
            {
                MessageBox.Show("Please Enter At Least the Following Required Fields:\nFull Name\nGender\nUsername\nPassword");
            }
        }