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
        public void GetAllInformersTest()
        {
            List <Informer> list = InformerWrapper.GetAllInformers();

            Assert.AreEqual(3, list.Count);
            Assert.AreEqual("Elias A. Kristoffersen", list[0].Name);
        }
        private void btnGetAllInformers_Click(object sender, RoutedEventArgs e)
        {
            var list = InformerWrapper.GetAllInformers();

            if (list.Count != 0)
            {
                lstInformers.ItemsSource = list;
            }
        }
示例#4
0
        public void SaveInformerTest()
        {
            List <Informer> list = InformerWrapper.GetAllInformers();

            Assert.AreEqual(3, list.Count);

            InformerWrapper.SaveInformer(new Informer("DKK", "Cash", "", -1, "000000-0000", "TST", "TEST"));

            list = InformerWrapper.GetAllInformers();
            Assert.AreEqual(4, list.Count);
        }
        private void btnSaveInformer_Click(object sender, RoutedEventArgs e)
        {
            try {
                Informer informer = new Informer();

                informer.Id          = int.Parse(txtInformerId.Text);
                informer.Name        = txtInformerName.Text;
                informer.Nationality = txtInformerNationality.Text;
                informer.CPR         = txtInformerCPR.Text;
                informer.Currency    = txtInformerCurrency.Text;
                informer.PaymentType = txtInformerPaymentType.Text;
                informer.Tags        = txtInformerTags.Text;

                InformerWrapper.SaveInformer(informer);

                // Try to save appearance
                if (txtInformerHeight.Text != "" || txtInformerEyecolor.Text != "" || txtInformerHaircolor.Text != "")
                {
                    Appearance appearance;
                    if (informer.Id == -1)
                    {
                        appearance = new Appearance(int.Parse(txtInformerHeight.Text), txtInformerEyecolor.Text, txtInformerHaircolor.Text, InfoWrapper.GetLastPersonId());
                    }
                    else
                    {
                        appearance = new Appearance(int.Parse(txtInformerHeight.Text), txtInformerEyecolor.Text, txtInformerHaircolor.Text, informer.Id);
                    }

                    InfoWrapper.SaveAppearence(appearance);
                }

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

                    InfoWrapper.SaveAddress(address);
                }

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

                        Database.Entities.Image img;

                        // if new informer
                        if (informer.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)), informer.Id);
                        }

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