示例#1
0
 private void TbxPassword_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(tbxPassword.Text.Trim()))
     {
         return;
     }
     using (var context = new MyBookDB())
     {
         users = context.User.ToList();
         if (users.Count == 0)
         {
             if (users.Count == 0)
             {
                 User user = new User();
                 user.IsMainAccount = true;
                 user.PassWord      = "******";
                 context.User.Add(user);
                 context.SaveChanges();
                 MessageBox.Show("这是密码:laolixiangni;不能让别人看到咯!");
                 New(user);
             }
         }
         else
         {
             var currentuser = users.FirstOrDefault(t => t.PassWord == tbxPassword.Text.Trim());
             if (currentuser != null)
             {
                 New(currentuser);
             }
         }
     }
 }
示例#2
0
 private void BtnSetting_Click(object sender, EventArgs e)
 {
     using (var context = new MyBookDB())
     {
         var         res      = context.TimeSetting.ToList().OrderByDescending(t => t.DatetimeSetting).FirstOrDefault();
         TimeSetting settings = new TimeSetting();
         settings.DatetimeSetting = DateTime.Now;
         settings.Time            = this.HowLongChangeWallPaper.Value;
         context.TimeSetting.Remove(res);
         context.TimeSetting.Add(settings);
         context.SaveChanges();
     }
 }
示例#3
0
 public void SetTime()
 {
     using (var context = new MyBookDB())
     {
         var timesettingd = context.TimeSetting.ToList().OrderByDescending(t => t.DatetimeSetting);
         if (timesettingd.Count() == 0)
         {
             TimeSetting settings = new TimeSetting();
             settings.DatetimeSetting = DateTime.Now;
             settings.Time            = this.HowLongChangeWallPaper.Value;
             context.TimeSetting.Add(settings);
             context.SaveChanges();
         }
         else
         {
             var firsettime = timesettingd.FirstOrDefault();
             this.HowLongChangeWallPaper.Value = firsettime.Time;
         }
     }
 }