I have tow windows in WPF APP, In the first windows the admin will add a ticket information, and in other windows, the employee should show a list of all tickets with a new one once have been added(automatically). on the following simple code:
//On User Window, set the itemSource
DataClasses1DataContext dc = new DataClasses1DataContext(Properties.Settings.Default.AJFactoryConnectionString);
public MainWindow()
{
if (dc.DatabaseExists()) AllTasksListView.ItemsSource = dc.TicketTables;};
//List View
<ListView Name="AllTasksListView" >
//Admin Window that allow him to add anew ticekt
public DataClasses1DataContext dc = new DataClasses1DataContext(Properties.Settings.Default.AJFactoryConnectionString);
public void InsertNewTickt(string Status,string Descrption)
{
TicketTable x = new TicketTable
{
CreatedDate = DateTime.Now,
Status = Status,
DeliveryDate = DateTime.Now,
Descrption = Descrption
};
dc.TicketTables.InsertOnSubmit(x);
try
{
dc.SubmitChanges();
}
catch (Exception ee)
{
dc.SubmitChanges();
}
}
I need a good way to update listview
immediately once the admin adds a new ticket(new row in sql). I am new in WPF, and I find a lot of solutions but in same windows, In my case, I have 2 windows.