Пример #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var admin = new
            {
                Name     = tbName.Text,
                Username = tbUsername.Text,
                Password = tbPassword.Text
            };
            var r = AdminController.AddAdmin(admin);

            if (r)
            {
                MessageBox.Show("User Added!");
            }
            else
            {
                MessageBox.Show("User not Added!");
            }
        }
Пример #2
0
        private void DoReg(object sender, EventArgs e)
        {
            var admin = new
            {
                Id       = AdminId.Text,
                Name     = AdminName.Text,
                UserName = AdminUser.Text,
                Password = AdminPass.Text,
                MobileNo = AdminMobile.Text,
                Gender   = AdminGender.SelectedItem.ToString()
            };
            var result = AdminController.AddAdmin(admin);

            if (result)
            {
                MessageBox.Show("Admin Added");
            }
            else
            {
                MessageBox.Show("Could not Add Admin", "Invalid Registration", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void SubClicked(object sender, EventArgs e)
        {
            string errMsg = "";
            bool   hasErr = false;

            string name     = "";
            string username = "";

            string pass   = "";
            string rePass = "";


            if (!radioButtonAdmin.Checked && !radioButtonEmployee.Checked && !radioButtonCustomer.Checked)
            {
                errMsg += "Registration Type required.\n";
                hasErr  = true;
            }

            if (textBoxRName.Text.Equals(""))
            {
                errMsg += "Name required.\n";
                hasErr  = true;
            }
            else
            {
                name = textBoxRName.Text;
            }


            if (textBoxRUsername.Text.Equals(""))
            {
                errMsg += "Username required.\n";
                hasErr  = true;
            }
            else
            {
                username = textBoxRUsername.Text;
            }

            if (textBoxPass.Text.Equals(""))
            {
                errMsg += "Password required.\n";
                hasErr  = true;
            }
            else
            {
                pass = textBoxPass.Text;
            }

            if (textBoxRePass.Text.Equals(""))
            {
                errMsg += "Re entering Password required.\n";
                hasErr  = true;
            }
            else
            {
                rePass = textBoxRePass.Text;
            }

            if (!pass.Equals(rePass))
            {
                errMsg += "Password doesn't match\n";
                hasErr  = true;
            }


            if (!hasErr)
            {
                string output = String.Format("Account created: \n \n" +
                                              "name: {0} \n" +
                                              "username: {1} \n"
                                              , name, username);
                rTRegOutput.Text = output;

                if (radioButtonEmployee.Checked)
                {
                    dynamic employee = new
                    {
                        Name     = name,
                        Username = username,
                        Password = pass
                    };
                    var result = EmployeeController.AddEmployee(employee);

                    if (result)
                    {
                        MessageBox.Show("Employee Added");
                    }
                    else
                    {
                        MessageBox.Show("Employee Not Added");
                    }
                }

                if (radioButtonAdmin.Checked)
                {
                    dynamic admin = new
                    {
                        Name     = name,
                        Username = username,
                        Password = pass
                    };
                    var result = AdminController.AddAdmin(admin);

                    if (result)
                    {
                        MessageBox.Show("Admin Added");
                    }
                    else
                    {
                        MessageBox.Show("Admin Not Added");
                    }
                }

                if (radioButtonCustomer.Checked)
                {
                    dynamic customer = new
                    {
                        Name     = name,
                        Username = username,
                        Password = pass
                    };
                    var result = CustomerController.AddCustomer(customer);

                    if (result)
                    {
                        MessageBox.Show("Customer Added");
                    }
                    else
                    {
                        MessageBox.Show("Customer Not Added");
                    }
                }
            }

            else
            {
                MessageBox.Show(errMsg);
            }
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(name.Text) || string.IsNullOrEmpty(address.Text) || string.IsNullOrEmpty(mobile.Text) || string.IsNullOrEmpty(email.Text) || string.IsNullOrEmpty(password.Text) || gender.SelectedItem == null)
            {
                if (string.IsNullOrEmpty(name.Text))
                {
                    nameallert.Visible = true;
                }
                else
                {
                    nameallert.Visible = false;
                }
                if (string.IsNullOrEmpty(address.Text))
                {
                    addressallert.Visible = true;
                }
                else
                {
                    addressallert.Visible = false;
                }
                if (string.IsNullOrEmpty(mobile.Text))
                {
                    mobileallert.Visible = true;
                }
                else
                {
                    mobileallert.Visible = false;
                }
                if (string.IsNullOrEmpty(email.Text))
                {
                    emailallert.Visible = true;
                }
                else
                {
                    emailallert.Visible = false;
                }
                if (string.IsNullOrEmpty(password.Text))
                {
                    passwordallert.Visible = true;
                }
                else
                {
                    passwordallert.Visible = false;
                }
                if (gender.SelectedItem == null)
                {
                    genderallert.Visible = true;
                }
                else
                {
                    genderallert.Visible = false;
                }

                MessageBox.Show("Please enter your Information", "Invalid Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (mobile.Text.Length != 11)
            {
                mobileallert.Visible = true;
                MessageBox.Show("Please enter your 11 digit mobile no", "Invalid Mobile No", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (password.Text.Length < 6)
            {
                passwordallert.Visible = true;
                MessageBox.Show("Please enter atleast 6 digit password", "Invalid Mobile No", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (email.Text.Contains(".com") == false)
            {
                emailallert.Visible = true;
                MessageBox.Show("Please enter your  correct email address", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else if ((mobile.Text.Substring(0, 2) != "01"))
            {
                mobileallert.Visible = true;
                MessageBox.Show("Wrong mobile operator", "Invalid Mobile No", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            else
            {
                try
                {
                    var admin = new
                    {
                        Name           = name.Text.Trim(),
                        PresentAddress = address.Text.Trim(),
                        MobileNo       = Convert.ToInt32(mobile.Text),
                        Gender         = gender.SelectedItem.ToString().Trim(),

                        Email    = email.Text.Trim(),
                        Password = password.Text.Trim()
                    };
                    var result = AdminController.AddAdmin(admin);
                    if (result)
                    {
                        confirm.Visible = true;
                        this.Hide();
                        new LoginPage().Show();
                    }
                }
                catch (FormatException)
                {
                    mobileallert.Visible = true;
                    MessageBox.Show("Do not insert character in phone number", "Invalid Mobile No", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(name.Text) || string.IsNullOrEmpty(address.Text) || string.IsNullOrEmpty(mobile.Text) || string.IsNullOrEmpty(email.Text) || string.IsNullOrEmpty(password.Text) || gender.SelectedItem == null)
            {
                if (string.IsNullOrEmpty(name.Text))
                {
                    nameallert.Visible = true;
                }
                else
                {
                    nameallert.Visible = false;
                }
                if (string.IsNullOrEmpty(address.Text))
                {
                    addressallert.Visible = true;
                }
                else
                {
                    addressallert.Visible = false;
                }
                if (string.IsNullOrEmpty(mobile.Text))
                {
                    mobileallert.Visible = true;
                }
                else
                {
                    mobileallert.Visible = false;
                }
                if (string.IsNullOrEmpty(email.Text))
                {
                    emailallert.Visible = true;
                }
                else
                {
                    emailallert.Visible = false;
                }
                if (string.IsNullOrEmpty(password.Text))
                {
                    passwordallert.Visible = true;
                }
                else
                {
                    passwordallert.Visible = false;
                }
                if (gender.SelectedItem == null)
                {
                    genderallert.Visible = true;
                }
                else
                {
                    genderallert.Visible = false;
                }

                MessageBox.Show("Please enter your Information", "Invalid Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }



            else
            {
                try
                {
                    var admin = new
                    {
                        Name           = name.Text.Trim(),
                        PresentAddress = address.Text.Trim(),
                        MobileNo       = Convert.ToInt32(mobile.Text),
                        Gender         = gender.SelectedItem.ToString().Trim(),

                        Email    = email.Text.Trim(),
                        Password = password.Text.Trim()
                    };
                    var result = AdminController.AddAdmin(admin);
                    if (result)
                    {
                        confirm.Visible = true;
                        this.Hide();
                        new LoginPage().Show();
                    }
                }
                catch (Exception ex)
                {
                    mobileallert.Visible = true;
                    MessageBox.Show(ex.Message, "Invalid Mobile No", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }