Пример #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Assistance.Init();
     Assistance.LoadSettings();
     BindingDatas();
     //NameNumLength = FileLength(numpath);
     spb.obj    = toolStripStatusLabel1;
     pastDBSHA1 = Assistance.Settings.ShA1OfDB;
     if (SECURITY_Enabled == true)
     {
         if (pastDBSHA1 != Assistance.GetSHA1Hash(Settings.DBpath))
         {
             var pib = new PasswordInputDialog(this, "检测到不安全的数据修改,请输入管理员密码", true);
             pib.Owner = this;
             pib.Show();
         }
     }
     conn.ConnectionString = "Data Source=" + Settings.DBpath;
     TBOutput.Location     = pictureBox1.Location;
     TBOutput.Size         = pictureBox1.Size;
     TBOutput.Visible      = false;
     ReadDataFromDatabase();
     LoadConfig_SelectedClassroom();
     ShowSelectedClassroomCheckbox();
 }
Пример #2
0
        public void updateDataBase()
        {
            if (AllStudents.Count == 0)
            {
                return;
            }
            foreach (Student astd in AllStudents)
            {
                astd.Sha1 = astd.getSHA1();
            }
            Stopwatch sw = new Stopwatch();

            sw.Start();
            SQLiteConnection conn = new SQLiteConnection();

            conn.ConnectionString = "Data source=" + Settings.DBpath;
            conn.Open();
            var           cmd     = conn.CreateCommand();
            StringBuilder tempCmd = new StringBuilder("replace  into students values");

            foreach (var astd in AllStudents)
            {
                tempCmd.Append(getStudentText(astd) + ",");
            }
            tempCmd.Remove(tempCmd.Length - 1, 1);
            cmd.CommandText = tempCmd.ToString();
            cmd.ExecuteNonQuery();
            // loadStudent();
            sw.Stop();
            var sw1 = new StreamWriter(Settings.SHA1ofDBpath, false);

            sw1.WriteLine(Assistance.GetSHA1Hash(Settings.DBpath));
            sw1.Close();
            spb.add("完成更新!用时" + sw.ElapsedMilliseconds + "ms");
        }