示例#1
0
        private void bLogin_Click_1(object sender, EventArgs e)
        {
            var email = this.email.Text.Trim();
            var passw = tPassword.Text.Trim();

            Error.ForeColor = Color.Red;

            if (email.Length == 0)
            {
                Error.Text = "ID can not be empty.";
                return;
            }

            if (passw.Length == 0)
            {
                Error.Text = "Password can not be empty.";
            }
            else
            {
                var u = new User();
                employee = new Employee();

                if (employee.LogIn(email, passw, "Employee"))
                {
                    Error.Text      = "Successful";
                    Error.ForeColor = Color.Green;
                    admin           = new AdminPanel();
                    admin.Show();
                    Hide();
                    //return;
                }
                else
                {
                    if (u.LogIn(email, passw, "Customer"))
                    {
                        if (bunifuCheckbox1.Checked)
                        {
                            User.UpdateSavedInformations(email, passw);
                        }
                        if (h == null)
                        {
                            h = new Home(email);
                            h.Show();

                            //UserInformations.TakeEmail(email);
                        }
                        else
                        {
                            h = null;
                        }

                        Payment.TakeEmail(email);
                        //Home.TakeEmail(email);
                        PaymentDelivery.TakeEmail(email);
                        Hide();

                        //if (mainForm != null)
                        //{
                        //    mainForm.Close();
                        //}
                        //else
                        //{
                        //    mainForm = new MainForm();
                        //    mainForm.Show();
                        //    if (bunifuCheckbox1.Checked)
                        //    {
                        //        u.UpdateSavedInformations(email, passw);
                        //    }
                        //    else
                        //    {
                        //        u.UpdateSavedInformations("Empty", "Empty");
                        //    }

                        //    Payment.TakeEmail(email);
                        //    MainForm.TakeEmail(email);
                        //    PaymentDelivery.TakeEmail(email);
                        //    this.Close();
                        //}
                    }
                    else
                    {
                        Error.Text = "Email or password is not correct.";
                    }
                }
            }
        }