private void UpdateWindow()
        {

            projectmasterDataSetTableAdapters.project_costsTableAdapter pca = new projectmasterDataSetTableAdapters.project_costsTableAdapter();

            if (App.Current.Properties["AddProjectCost_Employee"] != null)
            {
                DataRowView drv = (DataRowView)App.Current.Properties["AddProjectCost_Employee"];
                eid = (int)drv["eid"];
                string name = (string)drv["name"];
                lblAddProjectCostEmployee.Content = name;
                App.Current.Properties["AddProjectCost_Employee"] = null;
            }

            if (App.Current.Properties["AddProjectCost_Project"] != null)
            {
                DataRowView drv = (DataRowView)App.Current.Properties["AddProjectCost_Project"];
                pid = (int)drv["pid"];
                string projectname = (string)drv["projectname"];
                lblAddProjectCostProject.Content = projectname;
                App.Current.Properties["AddProjectCost_Project"] = null;
            }


        }
        private void btnAddProjectCost_Click(object sender, RoutedEventArgs e)
        {
            string description = (string)txtpcdescription.Text;
            DateTime costdate = (DateTime)dpCostDate.SelectedDate;
            int cost = Convert.ToInt32(txtcost.Text);

            try
            {
                projectmasterDataSetTableAdapters.project_costsTableAdapter pca = new projectmasterDataSetTableAdapters.project_costsTableAdapter();
                pca.InsertProjectCost(pid, eid, description, costdate, DateTime.Now, cost);
                this.Close();
            }
            catch (Exception)
            {

                MessageBox.Show("Verður að fylla í viðeigandi reiti");
            }
            
        }
        private void UpdateWindow()
        {

            projectmasterDataSetTableAdapters.project_costsTableAdapter pca = new projectmasterDataSetTableAdapters.project_costsTableAdapter();

            if (App.Current.Properties["SelectedEmployee"] != null)
            {
                DataRowView drv = (DataRowView)App.Current.Properties["SelectedEmployee"];
                eid = (int)drv["eid"];
                string name = (string)drv["name"];
                lblAddProjectCostEmployee.Content = name;
                App.Current.Properties["SelectedEmployee"] = null;
            }

            if (App.Current.Properties["SelectedProject"] != null)
            {
                DataRowView drv = (DataRowView)App.Current.Properties["SelectedProject"];
                pid = (int)drv["pid"];
                string projectname = (string)drv["projectname"];
                lblAddProjectCostProject.Content = projectname;
                App.Current.Properties["SelectedProject"] = null;
            }

            try 
            { 
                if((bool)App.Current.Properties["myProject"] == true)
                {
                    DataRowView drv2 = (DataRowView)App.Current.Properties["thisProjectCost"];
                    lblAddProjectCostProject.Content = (string)drv2["projectname"];

                    lblAddProjectCostEmployee.Content = (string)App.Current.Properties["User"];
                    btnAddProjectCostEmployee.Visibility = Visibility.Collapsed;
                    btnAddProjectCostProject.Visibility = Visibility.Collapsed;
                    eid = (int)App.Current.Properties["UserId"];
                    pid = (int)drv2["pid"];
                }
           }
            catch { }


        }
Beispiel #4
0
        private void menu_RemoveProjectCost_Click(object sender, RoutedEventArgs e)
        {
            DataRowView drv = (DataRowView)project_costsDataGrid.SelectedItem;
            string description = (string)drv["costdescription"];
            int pcid = (int)project_costsDataGrid.SelectedValue;
            MessageBoxResult result = MessageBox.Show("Ertu viss um að þú viljir eyða færslu nr. " + pcid + "?", "Eyða færslu", MessageBoxButton.YesNo);

            if(result == MessageBoxResult.Yes)
            { 
                try
                {
                    projectmasterDataSetTableAdapters.project_costsTableAdapter pca = new projectmasterDataSetTableAdapters.project_costsTableAdapter();
                    pca.DeleteProjectCost(pcid);
                    MessageBox.Show("Færslu nr. " + pcid + " hefur verið eytt.");
                    UpdateWindow();

                }
                catch(Exception )
                {
                    MessageBox.Show("Ekki hægt að eyða færslu nr." + pcid , "Framkvæmd mistókst");
                }
            }
        }