示例#1
0
        public void ArrangeSubmitButton()
        {
            // 設置大小
            SubmitButton.Size = new Size((int)(Size.Width * 0.08), SelectorOfYear.Height);

            // 設置相對位置(水平貼齊月分的選擇器,然後稍微往右移動)
            int x = SelectorOfMonth.Location.X + SelectorOfMonth.Width + IntervalOfTopTool;
            int y = SelectorOfMonth.Location.Y;

            SubmitButton.Location = (Point) new Size(x, y);

            // 預設內容
            SubmitButton.Text = "送出查詢";

            // 設置樣式
            SubmitButton.BackColor = Color.RoyalBlue;
            SubmitButton.ForeColor = Color.White;
            SubmitButton.FlatStyle = FlatStyle.Flat;
            SubmitButton.FlatAppearance.MouseOverBackColor = Color.RoyalBlue;
            SubmitButton.TabStop = false;
            SubmitButton.FlatAppearance.BorderSize = 0;

            // 預設的焦點為年分的選擇器,若不修改則其內容會在程式開啟時被反白
            // 將程式開啟後的焦點轉移到這個按鈕
            SubmitButton.Select();
        }
示例#2
0
        private void AddStudentForm_Load(object sender, EventArgs e)
        {
            int BoundsWidth  = Screen.PrimaryScreen.Bounds.Width;
            int BoundsHeight = Screen.PrimaryScreen.Bounds.Height;
            int X_Coordinate = BoundsWidth - this.Width;
            int Y_Coordinate = BoundsHeight - this.Height;

            Location = new Point(X_Coordinate / 2, (Y_Coordinate / 2) + 25);

            SubmitButton.Select();
            BirthdayPicker.Value = DateTime.Now;

            //EXCEPTION 1
            try
            {
                variables           = new Variables();
                opacityform         = new OpacityForm();
                cryptography        = new Cryptography();
                sqlconnectionconfig = new SQLConnectionConfig();

                RegistryKey registrykey = Registry.CurrentUser.OpenSubKey(@variables.pathname);
                string      tempdata    = registrykey.GetValue("SQLServerConnectionString").ToString();

                //USER SQLSERVER CONNECTION SETTINGS
                sqlconnectionconfig.SqlConnectionString = cryptography.Decrypt(tempdata);
                sqlconnection = new SqlConnection(sqlconnectionconfig.SqlConnectionString);

                DataTable datatable = new DataTable();
                sqlconnection.Open();

                //INNER EXCEPTION 1
                try
                {
                    //INIT STUDENT ID
                    AssignNewStudentID();

                    //INIT NEW USER ID
                    AssignNewUserID();

                    //GET CURRENT SCHOOL YEAR
                    GetCurrentSchoolYear();

                    //INIT SECTION DROPDOWN
                    RetrieveSectionList();
                }

                catch (Exception exception)
                {
                    opacityform.Show();
                    MessageBox.Show(exception.StackTrace.ToString(), "@Add Student Form Inner Exception 1",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    opacityform.Hide();
                }
            }

            catch (Exception exception)
            {
                opacityform.Show();
                MessageBox.Show(exception.StackTrace.ToString(), "@Add Student Form Exception 1",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                opacityform.Hide();
            }
        }