Пример #1
0
        private void ActivateApplication(UserDTO UserLoggedIn)
        {
            int companyTypeID = UserLoggedIn.CompanyTypeID;

            if (companyTypeID == 1)
            {
                Ometz.Representative.UI.MainMenu newForm = new Ometz.Representative.UI.MainMenu(UserLoggedIn.CompanyID);
                newForm.ShowDialog();
                newForm.Activate();
                this.Hide();

                if (newForm.DialogResult == DialogResult.Cancel)
                {
                    this.Close();

                }

            }

            if (companyTypeID == 2)
            {
                Ometz.Supplier.UI.frmSupplierMain newForm = new Ometz.Supplier.UI.frmSupplierMain(UserLoggedIn.CompanyID);
                newForm.ShowDialog();
                newForm.Activate();
                this.Hide();

                if (newForm.DialogResult == DialogResult.Cancel)
                {
                    this.Close();

                }

            }
        }
Пример #2
0
        //Method that gets user information
        public UserDTO GetUser(string userName)
        {
            string userN = "";
            userN = userName;
            UserDTO UserLogedIn = new UserDTO();
            //User user = new User();
            User UserDb=new User();

            using (var context = new RFQEntities())
            {
                 var result = (from usr in context.Users.Include("Company")
                              where usr.UserName == userN
                              select usr).First();
                if (result!=null)
                 UserDb = (User)result;
            }

            if (UserDb != null)
            {
                UserLogedIn.UserID = UserDb.UserID;
                UserLogedIn.UserName = UserDb.UserName;
                UserLogedIn.Password = UserDb.Password;
                UserLogedIn.CompanyID = UserDb.Company.CompanyID;
                UserLogedIn.CompanyTypeID = UserDb.Company.CompanyTypeID;
            }

            return UserLogedIn;
        }