private void button_Click(object sender, RoutedEventArgs e) { DateTime current = DateTime.Now.Date; DateTime taskTime = (DateTime)Dpick.SelectedDate; int result = DateTime.Compare(current, taskTime); if (result > 0) { MessageBox.Show("Ви не можете створити завдання на попереднє число."); } else { string richText = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd).Text; Tasks task = new Tasks(); task.taskDate = Dpick.SelectedDate.ToString(); task.taskName = richText; task.taskPriority = comboBox.SelectedValue.ToString(); task.taskStatus = defaultStatus; CRUD crud = new CRUD(); task.UserID=crud.getId(); crud.Add(task); //MessageBox.Show(task.taskName); this.Close(); } }
private void btnLogin_Click(object sender, RoutedEventArgs e) { CRUD c = new CRUD(); String userName = txtBxuserName.Text.ToLower(); string pass = passBxPassword.Password; lblfrgtPass.Visibility = Visibility.Hidden; lblLoading.Visibility = Visibility.Visible; txtBxuserName.IsEnabled = false; passBxPassword.IsEnabled = false; btnLogin.IsEnabled = false; TaskManEntities tme = new TaskManEntities(); var user=tme.Users.Where(p=>p.id==1).FirstOrDefault(); foreach (var v in tme.Users) { if (v.userLogin == userName) { user = tme.Users.Where(p => p.userLogin == userName).FirstOrDefault(); } } if (user.userPass == pass) { MainWindow mw = new MainWindow(); c.setID(user.id); this.Close(); mw.ShowDialog(); } else { lblLoading.Visibility = Visibility.Hidden; lblfrgtPass.Visibility = Visibility.Visible; txtBxuserName.IsEnabled = true; txtBxuserName.BorderBrush = Brushes.Red; passBxPassword.IsEnabled = true; passBxPassword.BorderBrush = Brushes.Red; btnLogin.IsEnabled = true; Mouse.OverrideCursor = null; } }