-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateTask.xaml.cs
More file actions
85 lines (77 loc) · 3.04 KB
/
Copy pathUpdateTask.xaml.cs
File metadata and controls
85 lines (77 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FinalProjectApp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class UpdateAssignment : Window
{
public UpdateAssignment()
{
InitializeComponent();
}
private void Cancel(object sender, RoutedEventArgs e)
{
TeacherHome th = new TeacherHome();
th.Show();
Close();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
string dbsCon = @"Data Source=LABSCIFIPC16\LOCALHOST;Initial Catalog=FinalProj;Integrated Security=True";
SqlConnection sqlCon = new SqlConnection(dbsCon);
using (sqlCon)
{
string q = "Update Assignments SET _name=@val1, dueDate=@val2, subject=@val3, classID=@val4 " +
"where id=@val;";
SqlCommand cmd = new SqlCommand(q, sqlCon);
cmd.Parameters.AddWithValue("@val", idBox.Text);
cmd.Parameters.AddWithValue("@val1", name.Text);
cmd.Parameters.AddWithValue("@val2", dueDater.Text);
cmd.Parameters.AddWithValue("@val3", cboxSubj.Text);
cmd.Parameters.AddWithValue("@val4", idComboBox.Text);
try
{
sqlCon.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Assignment updated successfully.");
TeacherHome th = new TeacherHome();
th.Show();
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sqlCon.Close();
Close();
}
}
}
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
FinalProjectApp.FinalProjDataSet1 finalProjDataSet1 = ((FinalProjectApp.FinalProjDataSet1)(this.FindResource("finalProjDataSet1")));
// Load data into the table Classes. You can modify this code as needed.
FinalProjectApp.FinalProjDataSet1TableAdapters.ClassesTableAdapter finalProjDataSet1ClassesTableAdapter = new FinalProjectApp.FinalProjDataSet1TableAdapters.ClassesTableAdapter();
finalProjDataSet1ClassesTableAdapter.Fill(finalProjDataSet1.Classes);
System.Windows.Data.CollectionViewSource classesViewSource1 = ((System.Windows.Data.CollectionViewSource)(this.FindResource("classesViewSource1")));
classesViewSource1.View.MoveCurrentToFirst();
}
}
}