Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     CreateChairPersonAccounts();
     if (Session["Id"] != null)
     {
         if (Session["AccountType"].ToString().Equals("Student"))
         {
             Response.Redirect("Student.aspx");
         }
         else if (Session["AccountType"].ToString().Equals("Teacher"))
         {
             Response.Redirect("Teacher.aspx");
         }
         else if (Session["AccountType"].ToString().Equals("ChairPerson"))
         {
             Response.Redirect("ChairPerson.aspx");
         }
         else if (Session["AccountType"].ToString().Equals("Admin"))
         {
             Response.Redirect("Admin.aspx");
         }
     }
     else
     {
         Txtusername.Focus();
     }
 }
Beispiel #2
0
        public frmLogin()
        {
            splashThread = new Thread(new ThreadStart(threadStartingPoint));
            splashThread.SetApartmentState(ApartmentState.STA);
            splashThread.IsBackground = true;
            splashThread.Start();
            Stopwatch stopwatch = Stopwatch.StartNew();

            InitializeComponent();
            ResourceManager myManager;
            string          isConstrAvail = string.Empty;

            try
            {
                myManager     = new ResourceManager(typeof(ProcessDesigner.Properties.Resources));
                conStr        = myManager.GetString("ConnectionString");
                isConstrAvail = System.Configuration.ConfigurationManager.ConnectionStrings[conStr].ToString();
            }
            catch (Exception ex)
            {
                ex.LogException();
                splashThread.Abort();
                if (string.IsNullOrEmpty(isConstrAvail))
                {
                    ShowErrorMessage(PDMsg.DBNotConnected);
                }
                btnClose.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                return;
            }
            loggedon = new Login(conStr);
            if (!loggedon.Dal.IsNotNullOrEmpty())
            {
                splashThread.Abort();
                ShowErrorMessage(PDMsg.DBNotConnected);
                btnClose.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                return;
            }

            int remaingtime = 5000 - stopwatch.ElapsedMilliseconds.ToString().ToIntValue();

            stopwatch.Stop();
            if (remaingtime > 0)
            {
                Thread.Sleep(remaingtime);
            }

            splashThread.Abort();

            //if (loggedon.IsValidVersionNo(sVersion) == false && Assembly.GetExecutingAssembly().IsRelease())
            //{
            //    ShowErrorMessage(PDMsg.VersionMisMatch(sVersion));
            //    this.Close();
            //}

            rbtDD.IsChecked = true;
            this.Topmost    = true;
            this.Topmost    = false;

            Txtusername.Focus();
            //Txtusername.Text = "jaya";
            //TxtPassword.Password = "******";
            //btnOk.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            //txtLastUpdate.Text = DateTime.Now.Date.ToString("dd.MM.yyyy") + " Ver.Release III /D&D/SFL";
            txtLastUpdate.Text     = "SmartPD " + " 03/Oct/2018" + " Production V5.4/D&D/SFL";
            grdCapsLock.Visibility = Keyboard.IsKeyToggled(Key.CapsLock) ? Visibility.Visible : Visibility.Hidden;
        }
Beispiel #3
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                userName = Txtusername.Text;
                //password = TxtPassword.Password.ToString().EncryptPassword();
                password = TxtPassword.Password;

                var focusedControl = Keyboard.FocusedElement;

                if (userName.Trim().Length <= 0)
                {
                    ShowInformationMessage(PDMsg.NotEmpty("User name"));
                    Txtusername.Focus();
                    return;
                }

                if (TxtPassword.Password.Trim().Length <= 0)
                {
                    ShowInformationMessage(PDMsg.NotEmpty("Password"));
                    TxtPassword.Focus();
                    return;
                }

                UserInformation _userInformation = new UserInformation();
                _userInformation.UserName      = userName;
                _userInformation.Dal           = loggedon.Dal;
                _userInformation.SFLPDDatabase = loggedon.DB;

                bool isForceToChangePassword;
                bool isValid = loggedon.IsValidUser(userName, password, out isForceToChangePassword);
                if (isValid)
                {
                    _userInformation.UserRole = loggedon.GetUserRole(userName);
                    _userInformation.Version  = loggedon.GetVersion();
                    if (string.IsNullOrEmpty(_userInformation.UserRole))
                    {
                        result = ShowInformationMessage(PDMsg.RoleNotDefined);
                        return;
                    }
                    Application.Current.Properties.Add("userinfo", _userInformation);
                    isForceToChangePassword = false;
                    if (isForceToChangePassword)
                    {
                        ProcessDesigner.frmChangePassword changePassword = new ProcessDesigner.frmChangePassword(_userInformation);
                        changePassword.Owner         = this;
                        changePassword.ShowInTaskbar = false;
                        changePassword.txtOldPassword.Focus();
                        changePassword.ShowDialog();

                        bool isPasswordChanged = changePassword.IsUserVerified;
                        if (!isPasswordChanged)
                        {
                            App.Current.Shutdown();
                        }
                    }

                    ProcessDesigner.MainWindow mw = new ProcessDesigner.MainWindow(_userInformation);
                    bool isAdmin = loggedon.GetisAdmin(userName);
                    if (isAdmin)
                    {
                        mw.miSecurity.Visibility = Visibility.Visible;
                        mw.miPartNumberConfiguration.Visibility = Visibility.Visible;
                        mw.miExhibit.Visibility        = Visibility.Visible;
                        mw.miLocationMaster.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        mw.miSecurity.Visibility = Visibility.Collapsed;
                        mw.miPartNumberConfiguration.Visibility = Visibility.Collapsed;
                        mw.miExhibit.Visibility        = Visibility.Collapsed;
                        mw.miLocationMaster.Visibility = Visibility.Collapsed;
                    }

                    StatusMessage.StatusBarDetails = mw.stMain;
                    StatusMessage.UserName         = userName;
                    StatusMessage.setStatus("Ready");
                    string hostname = Dns.GetHostName();
                    //  string ip = Dns.GetHostByName(hostname)[0].ToString();
                    string ip       = Dns.GetHostByName(hostname).AddressList[0].ToString();
                    string username = _userInformation.UserName;
                    bll = new ActiveUsersBLL(_userInformation);
                    bll.LogIn(username, ip, hostname);
                    mw.Show();
                    this.Close();
                }
                else
                {
                    result = ShowInformationMessage(PDMsg.WrongUNamePassword);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowInformationMessage(PDMsg.WrongUNamePassword);
                ex.LogException();
                return;
            }
        }