Exemplo n.º 1
0
        public RecycleBinUserCtrl(string staffID)
        {
            InitializeComponent();

            this.staffID = staffID;

            employeeList = eda.getAllDeletedEmployees(conn);
            supplierList = sda.getAllDeletedSuppliers(conn);

            input_staffSearchChanged(null, null);
            input_supplierSearchChanged(null, null);
        }
Exemplo n.º 2
0
        private bool isInputCorrect()
        {
            bool correct = true;

            if (!perfumeRadioButton.Checked && !packageRadioButton.Checked && !bottleRadioButton.Checked)
            {
                supplierTypeErrorLabel.Visible = true;
                correct = false;
            }
            else
            {
                supplierTypeErrorLabel.Visible = false;
            }

            if (string.IsNullOrWhiteSpace(supplierNameTextBox.Text) || !nameFormat.IsMatch(supplierNameTextBox.Text))
            {
                supplierNameErrorLabel.Visible = true;
                correct = false;
            }
            else
            {
                supplierNameErrorLabel.Visible = false;
            }

            if (string.IsNullOrWhiteSpace(supplierContactNoTextBox.Text) || !phoneFormat.IsMatch(supplierContactNoTextBox.Text))
            {
                supplierContactNoErrorLabel.ForeColor = Color.Red;
                correct = false;
            }
            else
            {
                supplierContactNoErrorLabel.ForeColor = SystemColors.ControlText;
            }

            if (string.IsNullOrWhiteSpace(emailTextBox.Text) || !FormatChecker.isValidEmail(emailTextBox.Text))
            {
                emailErrorLabel.Text    = rs.GetString("inputValidEmail");
                emailErrorLabel.Visible = true;
                correct = false;
            }
            else
            {
                bool            emailExist       = false;
                List <Supplier> suppliers        = sda.getAllSuppliers(conn);
                List <Supplier> deletedSuppliers = sda.getAllDeletedSuppliers(conn);
                if (!emailExist)
                {
                    foreach (Supplier sup in suppliers)
                    {
                        if (!string.IsNullOrWhiteSpace(sup.getEmail()) && sup.getEmail().Equals(emailTextBox.Text))
                        {
                            if (!string.IsNullOrWhiteSpace(sup.getSupplierID()) && !sup.getSupplierID().Equals(idTextBox.Text))
                            {
                                emailExist = true;
                                break;
                            }
                        }
                    }
                }
                if (!emailExist)
                {
                    foreach (Supplier sup in deletedSuppliers)
                    {
                        if (!string.IsNullOrWhiteSpace(sup.getEmail()) && sup.getEmail().Equals(emailTextBox.Text))
                        {
                            if (!string.IsNullOrWhiteSpace(sup.getSupplierID()) && !sup.getSupplierID().Equals(idTextBox.Text))
                            {
                                emailExist = true;
                                break;
                            }
                        }
                    }
                }

                if (emailExist)
                {
                    emailErrorLabel.Text    = rs.GetString("emailExists");
                    emailErrorLabel.Visible = true;
                    correct = false;
                }
                else
                {
                    emailErrorLabel.Text    = " ";
                    emailErrorLabel.Visible = false;
                }
            }

            if (string.IsNullOrWhiteSpace(supplierAddressTextBox.Text))
            {
                supplierAddressErrorLabel.Visible = true;
                correct = false;
            }
            else
            {
                supplierAddressErrorLabel.Visible = false;
            }

            return(correct);
        }