Esempio n. 1
0
        private void userEditBtn_Click(object sender, EventArgs e)
        {
            UserSecurity.User user = (UserSecurity.User)usersBinding.Current;

            if (user.Login == UserSecurity.CurrentUser.Login)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Error;
                ib.Show("You cannot edit yourself!");

                return;
            }

            if (user.Roles.Contains(m_adminRole))
            {
                if (!CanSuperAdmin("edit administrators"))
                {
                    return;
                }
            }

            UserEditForm dlg = new UserEditForm(user);

            dlg.ShowDialog(this);
        }
Esempio n. 2
0
        private void userRoleList_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue != CheckState.Checked)
            {
                return;
            }

            if (SCOUT.Core.Security.UserSecurity.CurrentUser
                .CanPerform(SCOUT.Core.Security.UserSecurity.Action.AdministrateAdmins))
            {
                return;
            }

            /*
             * Don't user's who aren't supposed to be allowed to edit admins
             * be able to add them!
             */
            SCOUT.Core.Security.UserSecurity.Role adminRole = SCOUT.Core.Security.UserSecurity.Roles.Find("Id",
                                                                                                          SCOUT.Core.Security.UserSecurity.Role.AdminRoleId);

            if (e.Index == SCOUT.Core.Security.UserSecurity.Roles.IndexOf(adminRole))
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Error;
                ib.Show("You cannot add aministrators.");

                e.NewValue = CheckState.Unchecked;

                return;
            }
        }
Esempio n. 3
0
        private void roleDelBtn_Click(object sender, EventArgs e)
        {
            if (!CanSuperAdmin("delete roles"))
            {
                return;
            }

            UserSecurity.Role role = (UserSecurity.Role)rolesBinding.Current;
            InfoBox           ib   = new InfoBox();

            if (role.Id == UserSecurity.Role.AdminRoleId)
            {
                ib.Icon = MessageBoxIcon.Error;
                ib.Show("You cannot delete the administrator role!");

                return;
            }

            DialogResult ans;

            ib.Type    = InfoBoxType.SuperConfirmBox;
            ib.Buttons = MessageBoxButtons.YesNo;
            ib.Icon    = MessageBoxIcon.Warning;

            ans = ib.Show("You are about to delete the \"{0}\" role.\r" +
                          "This operation cannot be undone.\r\r" +
                          "Continue anyway?", role.Name);

            if (ans == DialogResult.Yes)
            {
                try
                {
                    UserSecurity.Roles.Remove(role);
                    UserSecurity.Roles.Save();
                }
                catch (Exception ex)
                {
                    ib = new InfoBox();

                    ib.Icon = MessageBoxIcon.Error;
                    ib.Show("Save Error:\n{0}", ex.Message);
                }
            }
        }
Esempio n. 4
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            // Ensure that a site has been selected.
            Site selectedSite = siteSelList.SelectedItem as Site;

            if (selectedSite == null)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Exclamation;
                ib.Show("You must select a site to log into.");

                siteSelList.Focus();
                return;
            }

            SCOUT.Core.Security.UserSecurity.User u;

            SetStatus(Color.Black, "Authenticating...");

            if (userEdit.EditValue == null)
            {
                u = null;
            }
            else
            {
                u =
                    SCOUT.Core.Security.UserSecurity.User.GetUser(
                        userEdit.EditValue.ToString());
            }

            if (u != null)
            {
                if (u.Password == passEdit.EditValue.ToString())
                {
                    SCOUT.Core.Data.Site.Current = selectedSite;

                    SCOUT.Core.Security.UserSecurity.CurrentUser = u;

                    CheckForForcedPassChange(u);

                    Scout.Core.Modules.Client.RecordClientLogOn(u.Login, u.MachineName, m_verStr);

                    SCOUT.Core.Data.Helpers.Config["LastSiteIdx"] =
                        siteSelList.SelectedIndex.ToString();

                    DialogResult = DialogResult.OK;
                    return;
                }
            }

            passEdit.EditValue = null;
            userEdit.Focus();

            SetStatus(Color.Red, "Invalid username or password!");
        }
Esempio n. 5
0
        private void VerifySaveClose()
        {
            InfoBox      ib = new InfoBox();
            DialogResult ans;

            ib.Buttons = MessageBoxButtons.YesNo;

            if (m_order.IsTemplate)
            {
                ans = ib.Show(TemplateSavedMessage());
            }
            else
            {
                ans = ib.Show(OrderSavedMessage());
            }

            if (ans == DialogResult.Yes)
            {
                Close();
            }
        }
Esempio n. 6
0
        private void userDelBtn_Click(object sender, EventArgs e)
        {
            UserSecurity.User user = (UserSecurity.User)usersBinding.Current;
            InfoBox           ib   = new InfoBox();

            if (user.Login == UserSecurity.CurrentUser.Login)
            {
                ib.Icon = MessageBoxIcon.Error;
                ib.Show("You cannot delete yourself!");

                return;
            }

            DialogResult ans;

            ib.Type    = InfoBoxType.SuperConfirmBox;
            ib.Icon    = MessageBoxIcon.Warning;
            ib.Buttons = MessageBoxButtons.YesNo;

            ans = ib.Show("You are about to delete the user \"{0}\".\r" +
                          "This operation cannot be undone.\r\r" +
                          "Continue anyway?",
                          user.Login);

            if (ans == DialogResult.Yes)
            {
                try
                {
                    UserSecurity.Users.Remove(user);
                    UserSecurity.Users.Save();
                }
                catch (Exception ex)
                {
                    ib = new InfoBox();

                    ib.Icon = MessageBoxIcon.Error;
                    ib.Show("Save Error:\r{0}", ex.Message);
                }
            }
        }
Esempio n. 7
0
        private void BindResults(DataTable table)
        {
            if (table.Rows.Count == 0)
            {
                InfoBox ib = new InfoBox();

                ib.Show("No results found.");

                return;
            }

            waybillGrid.DataSource = table;
        }
Esempio n. 8
0
        private bool CanSuperAdmin(string action)
        {
            if (!IsSuperAdmin)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Error;
                ib.Show("You cannot {0}.", action);

                return(false);
            }

            return(true);
        }
Esempio n. 9
0
        private bool Save()
        {
            Focus();

            // Check if another order already exists with the same order identifiers
            Order existingOrder = OrderService
                                  .OrderWithIdentifiersExists(
                m_order.RMA,
                m_order.PO,
                m_order.Other,
                m_order.Id);

            if (existingOrder != null)
            {
                if (MessageBox.Show(
                        "Another order exists with these identifiers. Would you like to cancel saving and view this order?",
                        Application.ProductName,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    mainOrderForm form = new mainOrderForm(existingOrder);
                    form.WindowState = FormWindowState.Maximized;
                    form.MdiParent   = MdiParent;
                    form.Show();
                    form.Focus();

                    return(false);
                }
            }

            if (!EditorsAreValid() || !String.IsNullOrEmpty(m_order.Error))
            {
                ShowContractErrors();
                return(false);
            }

            try
            {
                Scout.Core.Data.Save(m_order.Session);
                return(true);
            }
            catch (Exception ex)
            {
                InfoBox ib = new InfoBox();
                ib.Icon = MessageBoxIcon.Error;
                ib.Show("Error saving order:\r{0}", ex.Message);
                return(false);
            }
        }
Esempio n. 10
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            try
            {
                m_role.Save();
            }
            catch (Exception ex)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Error;
                ib.Show("Save Error:\r{0}", ex.Message);

                return;
            }

            DialogResult = DialogResult.OK;
        }
Esempio n. 11
0
        private bool Save()
        {
            try
            {
                m_org.Save();
            }
            catch (BrokenRuleException excp)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Error;
                ib.Show("Error saving organization:\r{0}", excp.Message);

                return(false);
            }

            return(true);
        }
Esempio n. 12
0
        private void ShowContractErrors()
        {
            InfoBox infoBox = new InfoBox();

            infoBox.Buttons = MessageBoxButtons.OK;
            infoBox.Icon    = MessageBoxIcon.Error;
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(m_order.Error);

            foreach (IValidationControl control in m_validationControls)
            {
                stringBuilder.Append(control.Error());
            }


            infoBox.Show("{0}", stringBuilder.ToString());
        }
Esempio n. 13
0
        private void delAddrBtn_Click(object sender, System.EventArgs e)
        {
            if (m_org.Addresses.Count > 0)
            {
                Address      a  = m_org.Addresses[addrList.SelectedIndex];
                InfoBox      ib = new InfoBox();
                DialogResult res;

                ib.Buttons = MessageBoxButtons.YesNo;
                res        = ib.Show("You are about to delete the \"{0}\" address." +
                                     "This operation cannot be undone.\r\r" +
                                     "Are you sure you wish to do this?",
                                     a.Label);

                if (res == DialogResult.Yes)
                {
                    m_org.Addresses.Remove(a);
                }
            }
        }
Esempio n. 14
0
        private void delContBtn_Click(object sender, System.EventArgs e)
        {
            if (m_org.Contacts.Count > 0)
            {
                Contact      c  = m_org.Contacts[contactsList.SelectedIndex];
                InfoBox      ib = new InfoBox();
                DialogResult res;

                ib.Buttons = MessageBoxButtons.YesNo;
                res        = ib.Show("You are about to delete the contact \"{0}\".  " +
                                     "This operation cannot be undone.\r\r" +
                                     "Are you sure you wish to do this?",
                                     c.Name);

                if (res == DialogResult.Yes)
                {
                    m_org.Contacts.Remove(c);
                }
            }
        }
Esempio n. 15
0
        private void initLists()
        {
            // Make sure we have at least one site to chose from.
            if (m_sites.Count == 0)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Exclamation;
                ib.Show("There are no sites to log into!");

                return;
            }

            // Load sites into site drop down.
            siteSelList.Properties.Items.AddRange(m_sites);
            int lastSel = 0;

            if (m_sites.Count > 1)
            {
                Int32.TryParse(SCOUT.Core.Data.Helpers.Config["LastSiteIdx"], out lastSel);
            }

            siteSelList.SelectedIndex = lastSel;
        }
Esempio n. 16
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            string npass = newPassTxt.Text.Trim();
            string cpass = confPassTxt.Text.Trim();

            if (npass != "")
            {
                if (npass != cpass)
                {
                    InfoBox ib = new InfoBox();

                    ib.Icon = MessageBoxIcon.Error;
                    ib.Show("New and confirmation passwords do not match.");

                    return;
                }

                m_user.Password = npass;
            }

            try
            {
                m_user.Save();
            }
            catch (Exception ex)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Error;
                ib.Show("Error Saving:\n{0}", ex.Message);

                return;
            }

            DialogResult = DialogResult.OK;
        }
Esempio n. 17
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (!m_forced)
            {
                /*
                 * Check if forced because we fill in bogus info
                 * on the forced version.
                 */
                if (m_user.Password != oldTxt.Text)
                {
                    InfoBox ib = new InfoBox();

                    ib.Icon = MessageBoxIcon.Error;
                    ib.Show("Old password incorrect.");

                    return;
                }
            }

            string npass = newTxt.Text.Trim();
            string cpass = confirmTxt.Text.Trim();

            if (npass == String.Empty)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Error;
                ib.Show("A password is required.");

                newTxt.Focus();
                return;
            }

            if (npass != cpass)
            {
                InfoBox ib = new InfoBox();

                ib.Show("New and confirm passwords do not match.");

                return;
            }

            if (npass == m_user.Password)
            {
                InfoBox ib = new InfoBox();

                ib.Show("New and old passwords must be different.");

                return;
            }

            m_user.Password        = npass;
            m_user.ForcePassChange = false;

            try
            {
                m_user.Save();
                MessageBox.Show("Password changed.", Application.ProductName, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                Close();
            }
            catch (Exception ex)
            {
                InfoBox ib = new InfoBox();

                ib.Icon = MessageBoxIcon.Error;
                ib.Show(ex.Message);

                if (!m_forced)
                {
                    return;
                }
            }

            DialogResult = DialogResult.OK;
        }