private void btnHitungAritmetika_Click(object sender, RoutedEventArgs e)
        {
            double a, b, n, Un, Sn;

            a = double.Parse(txtBoxAritmetikaA.Text);
            b = double.Parse(txtBoxAritmetikaB.Text);
            n = double.Parse(txtBoxAritmetikaN.Text);

            Un = Fungsi.deretAritmetikaUn(a, b, n);
            Sn = Fungsi.deretAritmetikaSn(a, n, Un);

            lblHasilUnAritmetika.Content = Un.ToString();
            lblHasilSnAritmetika.Content = Sn.ToString();
        }
Пример #2
0
        public void Insert()
        {
            string query = "INSERT INTO student_info (SN, Password, EntryDate, Level, Status,"
                           + " CourseCode, Major, LastName, FirstName, MiddleName,"
                           + " Address, Sex, BirthDate, BirthPlace, Citizenship, Religion, ContactNo)"
                           + " VALUES"
                           + " (@SN, @Password, @EntryDate, @Level, @Status, @CourseCode, @Major, @LastName, @FirstName, @MiddleName, @Address, @Sex, @BirthDate, @BirthPlace, @Citizenship, @Religion, @ContactNo);";

            try
            {
                using (MySqlConnection myConn = new MySqlConnection(connection))
                    using (MySqlCommand myCommand = new MySqlCommand(query, myConn))
                    {
                        myCommand.Parameters.AddWithValue("@SN", this.Sn.ToString());
                        myCommand.Parameters.AddWithValue("@Password", this.Password.ToString());
                        myCommand.Parameters.AddWithValue("@EntryDate", this.EntryDate.ToString());
                        myCommand.Parameters.AddWithValue("@Level", this.Level.ToString());
                        myCommand.Parameters.AddWithValue("@Status", this.Status.ToString());
                        myCommand.Parameters.AddWithValue("@CourseCode", this.Course.ToString());
                        myCommand.Parameters.AddWithValue("@Major", this.Major.ToString());
                        myCommand.Parameters.AddWithValue("@LastName", this.LastName.ToString());
                        myCommand.Parameters.AddWithValue("@FirstName", this.FirstName.ToString());
                        myCommand.Parameters.AddWithValue("@MiddleName", this.MiddleName.ToString());
                        myCommand.Parameters.AddWithValue("@Address", this.Address.ToString());
                        myCommand.Parameters.AddWithValue("@Sex", this.Sex.ToString());
                        myCommand.Parameters.AddWithValue("@BirthDate", this.Bday.ToString());
                        myCommand.Parameters.AddWithValue("@BirthPlace", this.Bplace.ToString());
                        myCommand.Parameters.AddWithValue("@Citizenship", this.Citizenship.ToString());
                        myCommand.Parameters.AddWithValue("@Religion", this.Religion.ToString());
                        myCommand.Parameters.AddWithValue("@ContactNo", this.Contact.ToString());

                        myCommand.CommandTimeout = 60;
                        myConn.Open();
                        int affectedRows = myCommand.ExecuteNonQuery();
                        MessageBox.Show("Student account registered\nSN: " + Sn.ToString(), "Successful");
                    }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #3
0
        public void Update()
        {
            string query = "UPDATE `student_info` SET `Password` = @Password, `EntryDate` = @EntryDate, `Level` = @Level,"
                           + "`Status` = @Status, `CourseCode` = @CourseCode, `Major` = @Major, `LastName` = @LastName, "
                           + "`FirstName` = @FirstName, `MiddleName` = @MiddleName, `Address` = Address, `Sex` = @Sex, "
                           + "`BirthDate` = @BirthDate, `BirthPlace` = @BirthPlace, `Citizenship` = @Citizenship, "
                           + "`Religion` = @Religion, `ContactNo` = @ContactNo WHERE `student_info`.`SN` = @SN;";

            try
            {
                using (MySqlConnection myConn = new MySqlConnection(connection))
                    using (MySqlCommand myCommand = new MySqlCommand(query, myConn))
                    {
                        myCommand.Parameters.AddWithValue("@SN", this.Sn.ToString());
                        myCommand.Parameters.AddWithValue("@Password", this.Password.ToString());
                        myCommand.Parameters.AddWithValue("@EntryDate", this.EntryDate.ToString());
                        myCommand.Parameters.AddWithValue("@Level", this.Level.ToString());
                        myCommand.Parameters.AddWithValue("@Status", this.Status.ToString());
                        myCommand.Parameters.AddWithValue("@CourseCode", this.Course.ToString());
                        myCommand.Parameters.AddWithValue("@Major", this.Major.ToString());
                        myCommand.Parameters.AddWithValue("@LastName", this.LastName.ToString());
                        myCommand.Parameters.AddWithValue("@FirstName", this.FirstName.ToString());
                        myCommand.Parameters.AddWithValue("@MiddleName", this.MiddleName.ToString());
                        myCommand.Parameters.AddWithValue("@Address", this.Address.ToString());
                        myCommand.Parameters.AddWithValue("@Sex", this.Sex.ToString());
                        myCommand.Parameters.AddWithValue("@BirthDate", this.Bday.ToString());
                        myCommand.Parameters.AddWithValue("@BirthPlace", this.Bplace.ToString());
                        myCommand.Parameters.AddWithValue("@Citizenship", this.Citizenship.ToString());
                        myCommand.Parameters.AddWithValue("@Religion", this.Religion.ToString());
                        myCommand.Parameters.AddWithValue("@ContactNo", this.Contact.ToString());

                        myCommand.CommandTimeout = 60;
                        myConn.Open();
                        int affectedRows = myCommand.ExecuteNonQuery();
                        MessageBox.Show("Student Information Updated\nSN:" + Sn.ToString(), "Successful");
                    }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #4
0
        public void Delete()
        {
            string query = "DELETE FROM `student_info` WHERE `student_info`.`SN` = @SN";

            try
            {
                using (MySqlConnection myConn = new MySqlConnection(connection))
                    using (MySqlCommand myCommand = new MySqlCommand(query, myConn))
                    {
                        myCommand.Parameters.AddWithValue("@SN", this.Sn.ToString());

                        myCommand.CommandTimeout = 60;
                        myConn.Open();
                        int affectedRows = myCommand.ExecuteNonQuery();
                        MessageBox.Show("Student Info Deleted\nSN:" + Sn.ToString(), "Successful");
                    }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #5
0
        private void TB_搜尋_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (TB_搜尋.Text.Length == 5 || TB_搜尋.Text.Length > 40)
            {
                int Sn;
                if (!int.TryParse(TB_搜尋.Text, out Sn))
                {
                    if (TB_搜尋.Text.Contains("sn="))
                    {
                        var s = TB_搜尋.Text.Substring(TB_搜尋.Text.IndexOf("sn=") + 3);
                        if (!int.TryParse(s, out Sn))
                        {
                            WPFMessageBox.Show("不是正確的連結格式。");
                            return;
                        }
                    }
                    else
                    {
                        WPFMessageBox.Show("不是正確的連結格式。");
                        return;
                    }
                }

                Model.BahaModel Baha = new Model.BahaModel();

                if (Local.ProxyIP != "" && Local.ProxyPort != 0) //如果有設定Proxy
                {
                    WebRequest.Proxy = new System.Net.WebProxy(Local.ProxyIP, Local.ProxyPort);

                    if (Local.ProxyUser != "")
                    {
                        System.Net.ServicePointManager.Expect100Continue = false;
                        WebRequest.Proxy.UseDefaultCredentials           = true;
                        WebRequest.Proxy.Credentials = new System.Net.NetworkCredential(Local.ProxyUser, Local.ProxyPass);
                    }
                }

                Baha.SN   = Sn.ToString();
                Baha.Name = WebRequest.GetTitle(Baha.SN).Split('-')[0];

                if (Baha.Name == "")
                {
                    return;
                }
                if (Baha.Name == "巴哈姆特電玩資訊站")
                {
                    WPFMessageBox.Show("找不到SN為" + Baha.SN + "的影片資料。");
                    return;
                }

                if (VideoList.Where(I => I.SN == Baha.SN).Count() > 0)
                {
                    WPFMessageBox.Show("此影片 " + Baha.Name + " 己經在清單中...");
                    return;
                }

                if (File.Exists(Local.AniDir + "\\" + Baha.Name + ".mp4"))
                {
                    if (WPFMessageBox.Show("在下載資料夾裡己經有同樣名稱為 " + Baha.Name + " 的影片,是否要重新下載?"  , WPFMessageBoxButton.YesNo) == WPFMessageBoxResult.No)
                    {
                        return;
                    }
                }

                Baha.Status = "排隊中...";

                if (VideoList.Count > 0)
                {
                    Baha.No = VideoList.Max(I => I.No) + 1;
                }
                else
                {
                    Baha.No = 1;
                }
                Baha.Quality = Local.Quality;

                VideoList.Add(Baha);
                DataGrid_清單.ItemsSource = null;
                DataGrid_清單.ItemsSource = VideoList;

                處理下載();
                TB_搜尋.Text = "";
            }
        }