Ejemplo n.º 1
0
        public virtual void SetAcceptReject(bool isAcceptReject, bool supressCloseButton)
        {
            if (!IsDisposed)                    // TODO: Something better here to determine if form is closing
            {
                FMainMenu.SuspendLayout();
                FToolBar.SuspendLayout();
                try
                {
                    if (isAcceptReject)
                    {
                        _closeMenuItem.ShortcutKeys = Keys.None;                                // HACK: If this shortcut key isn't changed, the key for accept does not work (presumably because there is a conflict for a moment)
                        AddMenu(_acceptMenuItem);
                        AddMenu(_rejectMenuItem);
                        RemoveMenu(_closeMenuItem);
                        _acceptMenuItem.ShortcutKeys = Keys.F9;

                        AddToToolBar(_acceptButton, 0);
                        AddToToolBar(_rejectButton, 1);
                        RemoveFromToolBar(_closeButton);
                    }
                    else
                    {
                        _acceptMenuItem.ShortcutKeys = Keys.None;
                        AddMenu(_closeMenuItem);
                        RemoveMenu(_acceptMenuItem);
                        RemoveMenu(_rejectMenuItem);
                        _closeMenuItem.ShortcutKeys = Keys.F9;

                        if (!supressCloseButton)
                        {
                            AddToToolBar(_closeButton, 0);
                        }
                        RemoveFromToolBar(_acceptButton);
                        RemoveFromToolBar(_rejectButton);
                    }
                    _isAcceptReject = isAcceptReject;
                }
                finally
                {
                    FToolBar.ResumeLayout();
                    FMainMenu.ResumeLayout();
                }
            }
        }
Ejemplo n.º 2
0
        private void Blogin_Click(object sender, EventArgs e)
        {
            if (TbPassword.ForeColor == Color.DimGray || TbUsername.ForeColor == Color.DimGray)
            {
                MessageBox.Show("User dan Password harus di isi!!", "PERINGATAN", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                A.SetQueri("SELECT `id_user`, `id_akses`, `username`, `kode_ref` " +
                           "FROM `m_user` WHERE `hapus`='N' AND `username`='" + TbUsername.Text +
                           "' AND `password`=MD5('" + TbPassword.Text + "') LIMIT 1");
                bool ada = false;

                foreach (DataRow baris in A.GetQueri().GetData().Rows)
                {
                    S.SetUsername(baris["username"].ToString().EncodeToBase64String());
                    S.SetUseracces(baris["id_akses"].ToString());
                    S.SetUserid(baris["id_user"].ToString());
                    S.SetKodeGuru(baris["kode_ref"].ToString());
                    S.SetKodesiswa(baris["kode_ref"].ToString());
                    ada = true;
                }

                if (ada)
                {
                    if (S.GetUseracces() == "1" || S.GetUseracces() == "2")
                    {
                        S.SetUsernama(A.SingelData("SELECT `namaguru` FROM `m_guru` WHERE `kode_guru`='" + S.GetKodeGuru() + "';"));
                    }
                    else if (S.GetUseracces() == "3")
                    {
                        S.SetUsernama(A.SingelData("SELECT `namasiswa` FROM `m_siswa` WHERE  `kode_siswa`='" + S.GetKodesiswa() + "';"));
                    }

                    TbPassword.Clear();
                    TbUsername.Clear();
                    Tbusername_Leave(sender, e);
                    Tbpassword_Leave(sender, e);
                    this.ShowInTaskbar = false;
                    this.Hide();
                    A.SetLogin();
                    Properties.Settings.Default.loginsaveusername = CbSaveUsername.Checked;
                    Properties.Settings.Default.username          = S.GetUsername();
                    Properties.Settings.Default.Save();
                    FMainMenu f = new FMainMenu();
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        List <Form> openForms = new List <Form>();
                        foreach (Form form in Application.OpenForms)
                        {
                            openForms.Add(form);
                        }

                        foreach (Form ff in openForms)
                        {
                            if (ff.Name != "FLogin")
                            {
                                ff.Close();
                            }
                        }

                        this.Show();
                        this.ShowInTaskbar = true;
                        if (Properties.Settings.Default.loginsaveusername)
                        {
                            TbUsername.Text      = S.GetUsername().DecodeFromBase64String();
                            TbUsername.ForeColor = Color.Black;
                        }
                    }
                    else
                    {
                        A.SetLogout();
                        Close();
                    }
                }
                else
                {
                    MessageBox.Show("Username / Password Salah!!", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }