コード例 #1
0
ファイル: Login.cs プロジェクト: SieBrum/Barroc-IT
        public void Login(object sender, EventArgs e)
        {
            if (txtb_Username.Text == "" || txtb_Password.Text == "")
            {
                MessageBox.Show("Please fill the username and password fields.");
            }
            else
            {
                DatabaseHandler dbh = new DatabaseHandler();
                dbh.OpenConnection();
                if (dbh.Login(txtb_Username.Text, txtb_Password.Text))
                {
                    if (cb_Remember.Checked == true)
                    {
                        Properties.Settings.Default["RememberMe"] = true;
                        Properties.Settings.Default["Username"]   = txtb_Username.Text;
                        Properties.Settings.Default.Save();
                    }

                    switch (txtb_Username.Text.ToLower())
                    {
                    case "development":
                        frm_Development devForm = new frm_Development();
                        devForm.Show();
                        break;

                    case "sales":
                        frm_Sales salForm = new frm_Sales();
                        salForm.Show();
                        break;

                    case "finance":
                        frm_Finance_2 finForm = new frm_Finance_2();
                        finForm.Show();
                        break;

                    default:
                        MessageBox.Show("An Error Occured.");
                        break;
                    }
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Login Failed! :'(");
                }
            }
        }
コード例 #2
0
        public static ToolStripControlHost[] DTPGenerator(frm_Sales form)
        {
            DateTimePicker dtp_From = new DateTimePicker()
            {
                Width = 140
            };

            dtp_From.ValueChanged += new System.EventHandler(form.SetDateFromLabel);
            DateTimePicker dtp_Till = new DateTimePicker()
            {
                Width = 140
            };

            dtp_Till.ValueChanged += new System.EventHandler(form.SetDateTillLabel);
            Label lbl_From = new Label()
            {
                Text = "From:", Width = 140
            };
            Label lbl_Till = new Label()
            {
                Text = "Till:", Width = 140
            };
            Button btn = new Button()
            {
                Text = "Search"
            };

            btn.Click     += new System.EventHandler(form.Search);
            dtp_From.Value = DateTime.Now.Date;
            dtp_Till.Value = DateTime.Now.Date;

            ToolStripControlHost lblch_From = new ToolStripControlHost(lbl_From);
            ToolStripControlHost lblch_Till = new ToolStripControlHost(lbl_Till);
            ToolStripControlHost tsch_From  = new ToolStripControlHost(dtp_From);
            ToolStripControlHost tsch_Till  = new ToolStripControlHost(dtp_Till);
            ToolStripControlHost tsch_btn   = new ToolStripControlHost(btn);

            ToolStripControlHost[] arrayControl = new ToolStripControlHost[5];
            arrayControl[0] = new ToolStripControlHost(lbl_From);
            arrayControl[1] = new ToolStripControlHost(dtp_From);
            arrayControl[2] = new ToolStripControlHost(lbl_Till);
            arrayControl[3] = new ToolStripControlHost(dtp_Till);
            arrayControl[4] = new ToolStripControlHost(btn);

            return(arrayControl);
        }