コード例 #1
0
        public ReportView(int id)
        {
            InitializeComponent();

            var list = ReportWrapper.GetReports(id);

            if (list.Count != 0)
            {
                lstReports.ItemsSource = list;
            }

            var agentlist    = AgentWrapper.GetAllAgents();
            var informerlist = InformerWrapper.GetAllInformers();

            foreach (var i in agentlist)
            {
                authorlist.Add(new Person(i.Id, "", "", i.Name));
            }

            foreach (var i in informerlist)
            {
                authorlist.Add(new Person(i.Id, "", "", i.Name));
            }

            cmbAuthor.ItemsSource = authorlist;

            observedlist = ObservedWrapper.GetAllObserved();

            cmbObserved.ItemsSource = observedlist;
        }
コード例 #2
0
        private void btnGetAllObserved_Click(object sender, RoutedEventArgs e)
        {
            var list = ObservedWrapper.GetAllObserved();

            if (list.Count != 0)
            {
                lstObserved.ItemsSource = list;
            }
        }
コード例 #3
0
        private void btnSaveObserved_Click(object sender, RoutedEventArgs e)
        {
            try {
                Observed observed = new Observed();

                observed.Id          = int.Parse(txtObservedId.Text);
                observed.Name        = txtObservedName.Text;
                observed.Nationality = txtObservedNationality.Text;
                observed.CPR         = txtObservedCPR.Text;
                observed.Tags        = txtObservedTags.Text;

                ObservedWrapper.SaveObserved(observed);

                // Try to save appearance
                if (txtObservedHeight.Text != "" || txtObservedEyecolor.Text != "" || txtObservedHaircolor.Text != "")
                {
                    Appearance appearance;
                    if (observed.Id == -1)
                    {
                        appearance = new Appearance(int.Parse(txtObservedHeight.Text), txtObservedEyecolor.Text, txtObservedHaircolor.Text, InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        appearance = new Appearance(int.Parse(txtObservedHeight.Text), txtObservedEyecolor.Text, txtObservedHaircolor.Text, observed.Id);
                    }

                    InfoWrapper.SaveAppearence(appearance);
                }

                // Try to save address
                if (txtObservedStreet.Text != "" || txtObservedAreacode.Text != "")
                {
                    Address address;
                    // Check if it's a new observed
                    if (observed.Id == -1)
                    {
                        address = new Address(txtObservedStreet.Text, int.Parse(txtObservedAreacode.Text), InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        address = new Address(txtObservedStreet.Text, int.Parse(txtObservedAreacode.Text), observed.Id);
                    }

                    InfoWrapper.SaveAddress(address);
                }

                // Try to save image
                if (txtObservedImagePath.Text != "")
                {
                    if (File.Exists(txtObservedImagePath.Text))
                    {
                        FileStream   fs = new FileStream(txtObservedImagePath.Text, FileMode.Open, FileAccess.Read);
                        BinaryReader br = new BinaryReader(fs);

                        Database.Entities.Image img;

                        // if new observed
                        if (observed.Id == -1)
                        {
                            img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), InfoWrapper.GetLastPersonId());
                        }
                        else
                        {
                            img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), observed.Id);
                        }

                        InfoWrapper.SaveImage(img);
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show($"Der er sket en fejl. Er alle felterne korrekt udfyldt?\n\n{ex.Message}");
            }
        }