Exemplo n.º 1
0
        public Person GetPerson(int id)
        {
            DataSet ds = new DataSet();

            ds = ExecuteQuery($"Select top 1 * from Persons where id = '{id}'");
            DataRow r = ds.Tables[0].Rows[0];

            switch ((string)r["role"].ToString().ToUpper())
            {
            case "AGENT":
                Person a = new Agent((int)r["id"], (string)r["name"], (string)r["address"], (string)r["nationality"], (string)r["serializedImage"], (string)r["description"]);
                return(a);

            case "INFORMANT":
                Person i = new Informant((int)r["id"], (string)r["name"], (string)r["address"], (string)r["nationality"], (string)r["serializedImage"], (string)r["description"], (string)r["methodOfPayment"], (string)r["currency"]);
                return(i);

            case "OBSERVANT":
                Person o = new Observant((int)r["id"], (string)r["name"], (string)r["address"], (string)r["nationality"], (string)r["serializedImage"], (string)r["description"]);
                return(o);

            default:
                throw new ArgumentException("Role Not Valid");
            }
        }
Exemplo n.º 2
0
 private void BtnCreate_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrEmpty(tbxName.Text))
     {
         MessageBox.Show("You must enter a name");
     }
     else if (String.IsNullOrEmpty(tbxAddress.Text))
     {
         MessageBox.Show("You must enter an Address");
     }
     else if (String.IsNullOrEmpty(tbxNationality.Text))
     {
         MessageBox.Show("You must enter a Nationality (NAN for unknown)");
     }
     else
     {
         if (tbxNationality.Text.Count() != 3)
         {
             MessageBox.Show("Nationality must follow the standards of ISO-3166, Alpha-3");
         }
         else
         {
             Observant o = new Observant(tbxName.Text, tbxAddress.Text, tbxNationality.Text, imgstring, tbxDescription.Text);
             db.NewPerson(o);
             this.Close();
         }
     }
 }
Exemplo n.º 3
0
 public EditObservant(Observant o)
 {
     InitializeComponent();
     db = new DBHandler();
     observant = o;
     imgString = o.SerializedImage;
     lblName.Content = observant.Name;
     lblAddress.Content = observant.Address;
     lblNationality.Content = observant.Nationality;
     lblDescription.Content = observant.Description;
     tbxName.Text = observant.Name;
     tbxAddress.Text = observant.Address;
     tbxNationality.Text = observant.Nationality;
     tbxDescription.Text = observant.Description;
     if (o.SerializedImage.ToUpper() != "PLACEHOLDER")
     {
         imgPicture.Source = db.StringToImage(o.SerializedImage);
     }
 }