示例#1
0
        public void RouteUser(string username, string password)
        {
            Form frm;
            User usr = SearchForUser(username);

            if (usr != null && Hashing.ValidatePassword(password, usr.password))
            {
                switch (usr.user_type_id)
                {
                case 1:
                    frm = new FrmUser(usr);
                    frm.ShowDialog();
                    break;

                case 2:
                    frm = new FrmSupervisor(usr);
                    frm.ShowDialog();
                    break;

                case 3:
                    frm = new FrmAdmin(usr);
                    frm.ShowDialog();

                    break;
                }
            }
            else
            {
                string title   = "Advertencia";
                string message = "Contraseña incorrecta o nombre de usuario incorrecto";
                Dialogs.OkDialog(title, message);
            }
        }
示例#2
0
        private void mnuAdmin_Click(object sender, EventArgs e)
        {
            FrmAdmin frmAdmin = new FrmAdmin();

            this.Hide();
            frmAdmin.ShowDialog();
            this.Show();
        }
示例#3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text == String.Empty)
            {
                lblMessage.Text = "Kullanıcı adı boş geçilemez.";
                txtUsername.Focus();
                return;
            }
            else if (txtPassword.Text == String.Empty)
            {
                lblMessage.Text = "Şifre boş geçilemez.";
                txtPassword.Focus();
                return;
            }
            using (IUserRepository userRepo = new UserRepository(new BeamDeflectionDbContext()))
            {
                var result = userRepo.Login(txtUsername.Text, txtPassword.Text);
                switch (result.State)
                {
                case Basecore.Model.Enums.BusinessResultType.NotSet:
                    lblMessage.Text = result.Message;
                    break;

                case Basecore.Model.Enums.BusinessResultType.Success:
                    if (result.Result.Username == "admin" && result.Result.IsActive == true)
                    {
                        result.Result.LastLogin = DateTime.UtcNow;
                        FrmAdmin frm = new FrmAdmin(result.Result);
                        frm.ShowDialog();
                        this.Hide();
                    }
                    else
                    {
                        result.Result.LastLogin = DateTime.UtcNow;
                        FrmCalculation frm = new FrmCalculation(result.Result);
                        frm.Show();
                        this.Hide();
                    }

                    break;

                case Basecore.Model.Enums.BusinessResultType.Error:
                    lblMessage.Text = result.Message;
                    break;

                case Basecore.Model.Enums.BusinessResultType.Warning:
                    lblMessage.Text = result.Message;
                    break;

                case Basecore.Model.Enums.BusinessResultType.Info:
                    lblMessage.Text = result.Message;
                    break;

                default:
                    break;
                }
            }
        }
示例#4
0
        public void SignIn(object sender, EventArgs e)
        {
            Member member = new Member();

            if (!IsEmpty(txtUsername.Text))
            {
                member.Username = txtUsername.Text;
            }

            if (!InvalidInt(txtPIN.Text))
            {
                member.PIN = Convert.ToInt32(txtPIN.Text);
            }

            if (MemberDB.IsMember(member))
            {
                if (MemberDB.LogIn(member))
                {
                    Member dbMember =
                        CurrentMember.GetCurrentMember();

                    if (chkAdmin2.Checked is true &&
                        dbMember.IsAdmin is true)
                    {
                        this.Hide();

                        FrmAdmin addAdminForm =
                            new FrmAdmin();

                        addAdminForm.ShowDialog();

                        this.Close();
                    }
                    else
                    {
                        this.Hide();

                        FrmLibrary addLibraryForm =
                            new FrmLibrary();

                        addLibraryForm.ShowDialog();

                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("PIN incorrect. Try again.");
                }
            }
示例#5
0
 private void lblNatrag_Click(object sender, EventArgs e)
 {
     korisnikZanimanje = baza.Instanca.dohvatiBroj("SELECT zanimanje FROM zaposlenik where id= '" + korisnikId + "' ");
     if (korisnikZanimanje == 1)
     {
         FrmAdmin forma = new FrmAdmin(korisnikId);
         this.Hide();
         forma.ShowDialog();
         this.Close();
     }
     else
     {
         FrmZaposlenik forma = new FrmZaposlenik(korisnikId);
         this.Hide();
         forma.ShowDialog();
         this.Close();
     }
 }
示例#6
0
        private void aDMINToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            FrmAdmin frmad = new FrmAdmin();

            frmad.ShowDialog();
        }