Beispiel #1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            timer.Start();
            lblCompanyName.Text =
                AppConfig.Instance.CompanyName;
            lblCompanyAddress.Text =
                AppConfig.Instance.CompanyAddress +
                " Phone (" +
                AppConfig.Instance.CompanyPhoneNumber +
                ")";
            lblGateName.Text =
                AppConfig.Instance.GateName;

            FormLogin login = new FormLogin();
            if (login.ShowDialog(this) == DialogResult.OK)
            {
                string username = login.Username;
                string password = login.Password;

                if (!AppConfig.Instance.ValidateLogin(username, password))
                {
                    MessageBox.Show(this, "Gagal melakukan login ke server",
                        "Gagal Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Close();
                }
                else
                {
                    statusLabelUser.Text = "User :"******"-" + dt.Month + "-" + dt.Day +
                        " " + dt.Hour + ":" + dt.Minute + ":" + dt.Second;
                    statusLabelStartLogin.Text = "Mulai Login:" +
                        dateStr;
                    ClearForm();
                    Commons.FullScreen.SetWinFullScreen(this.Handle);
                }
            }
            else
            {
                Application.Exit();
            }

            
        }
Beispiel #2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            using (FormLogin login = new FormLogin())
            {
                login.StartPosition = FormStartPosition.CenterScreen;
                if (login.ShowDialog() == DialogResult.OK)
                {
                    string username = login.Username;
                    string password = login.Password;
                    if (AppConfig.Instance.ValidateLogin(username, password))
                    {
                        FullScreen.SetWinFullScreen(this.Handle);

                        lblCompanyName.Text = AppConfig.Instance.CompanyName;
                        lblCompanyAddress.Text = AppConfig.Instance.CompanyAddress + " (" +
                            AppConfig.Instance.CompanyPhoneNumber + ")";
                        lblGateName.Text = AppConfig.Instance.GateName;

                        OpenVideoPlayer();
                        OpenSerialPort();
                    }
                    else
                    {
                        MessageBox.Show("Username atau password salah", "Gagal Login",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Close();
                    }
                }
                else
                {
                    Close();
                }
            }

        }
Beispiel #3
0
        private void mnItemLogin_Click(object sender, EventArgs e)
        {
            if (mnItemLogin.Text == "&Login")
            {
                FormLogin login = new FormLogin();
                if (login.ShowDialog() == DialogResult.OK)
                {
                    string username = login.Username;
                    string password = login.Password;
                    if (AppConfig.Instance.ValidateLogin(username, password))
                    {
                        mnItemReport.Visible = true;
                        mnItemManage.Visible = true;
                        mnItemGantiPassword.Visible = true;

                        if (AppConfig.Instance.IsCurrentUserAdmin())
                        {
                            mnItemPrice.Visible = true;
                            mnItemMember.Visible = true;
                            mnItemUser.Visible = true;
                            mnItemSetting.Visible = true;
                        }
                        else
                        {
                            mnItemPrice.Visible = false;
                            mnItemMember.Visible = false;
                            mnItemUser.Visible = false;
                            mnItemSetting.Visible = false;
                        }
                        

                        statusLabelUser.Text = "User :"******"Mulai Login :"******"dd MMMM yyyy") + " " +
                            now.ToString("T");
                        mnItemLogin.Text = "&Logout";
                    }
                    else
                    {
                        MessageBox.Show("Login Failed ...");
                    }                   
                }
            }
            else
            {
                // TODO close all form
                mnItemManage.Visible = false;
                mnItemReport.Visible = false;
                mnItemLogin.Text = "&Login";

                statusLabelUser.Text = "User :"******"Mulai Login :";

                //close allform
                if (null != price)
                {
                    price.Close();
                    price.Dispose();
                }

                if (null != user)
                {
                    user.Close();
                    user.Dispose();
                }
            }
        }