Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Viltu vista breytingar?", "Breyta verkefni", MessageBoxButton.YesNo);
            try
            {
                if (result == MessageBoxResult.Yes)
                {
                    DataRowView drv = (DataRowView)App.Current.Properties["project"];
                    string description = txtPDescription.Text;
                    DateTime pdate = (DateTime)drv["pdate"];
                    int eid = (int)drv["employee_eid"];
                    string pname = txtprojectName.Text;
                    int pid = (int)drv["pid"];

                    //update project
                    projectmasterDataSetTableAdapters.projectTableAdapter pta = new projectmasterDataSetTableAdapters.projectTableAdapter();
                    pta.UpdateProjectById(description, pdate, eid, isFinished, pname, pid);

                    //log int projectmessagestable: the change in project state(finsished/unfinished)
                    if(isFinished != isFinishedChanged && isFinished == true)
                    {
                        projectmasterDataSetTableAdapters.project_messagesTableAdapter pma = new projectmasterDataSetTableAdapters.project_messagesTableAdapter();
                        pma.Insert(pid, eid, "*** Staða verkefnis fært í lokið ***", DateTime.Now, null, null);
                    }
                    if (isFinished != isFinishedChanged && isFinished == false)
                    {
                        projectmasterDataSetTableAdapters.project_messagesTableAdapter pma = new projectmasterDataSetTableAdapters.project_messagesTableAdapter();
                        pma.Insert(pid, eid, "*** Verkefni enduropnað ***", DateTime.Now, null, null);
                    }
                    //update current properties also
                    drv["projectisfinished"] = isFinished;

                    this.Close();
                }
            }
            catch
            {
                MessageBox.Show("Ekki hægt að vista breytingar");
            }



        }