Example #1
0
 private void Add_Click(object sender, EventArgs e)
 {
     if (this.dataGridView1.CurrentRow != null)
     {
         this.label1.Text = string.Empty;
         string type = this.RelationType.SelectedItem.ToString();
         if (type == types[0])
         {
             var person      = (PersonDTO)this.dataGridView1.CurrentRow.DataBoundItem;
             var isSuccesful = service.AttachPerson(this.itemPath, person.FirstName, person.LastName, person.Group);
             if (isSuccesful)
             {
                 this.label1.ForeColor = Color.DarkGreen;
                 this.label1.Text      = messages[0];
             }
             else
             {
                 this.label1.ForeColor = Color.DarkRed;
                 this.label1.Text      = messages[1];
             }
         }
         else if (type == types[1])
         {
             var location    = (LocationDTO)this.dataGridView1.CurrentRow.DataBoundItem;
             var isSuccesful = service.ChangeLocation(this.itemPath, location.Name, location.Country, location.Region);
             if (isSuccesful)
             {
                 this.label1.ForeColor = Color.DarkGreen;
                 this.label1.Text      = messages[0];
             }
             else
             {
                 this.label1.ForeColor = Color.DarkRed;
                 this.label1.Text      = messages[1];
             }
         }
         else
         {
             var property    = (PropertyDTO)this.dataGridView1.CurrentRow.DataBoundItem;
             var isSuccesful = service.AttachDynamicProperty(this.itemPath, property.Name, property.Value);
             if (isSuccesful)
             {
                 this.label1.ForeColor = Color.DarkGreen;
                 this.label1.Text      = messages[0];
             }
             else
             {
                 this.label1.ForeColor = Color.DarkRed;
                 this.label1.Text      = messages[1];
             }
         }
     }
 }