Example #1
0
 private void Remove_Click(object sender, EventArgs e)
 {
     if (this.dataGridView1.CurrentRow != null)
     {
         string type = this.RelationType.SelectedItem.ToString();
         this.label1.Text = string.Empty;
         if (type == types[0])
         {
             var person      = (PersonDTO)this.dataGridView1.CurrentRow.DataBoundItem;
             var isSuccesful = service.RemovePerson(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[2];
             }
         }
         else if (type == types[1])
         {
             var location    = (LocationDTO)this.dataGridView1.CurrentRow.DataBoundItem;
             var isSuccesful = service.RemoveLocation(this.itemPath);
             if (isSuccesful)
             {
                 this.label1.ForeColor = Color.DarkGreen;
                 this.label1.Text      = messages[0];
             }
             else
             {
                 this.label1.ForeColor = Color.DarkRed;
                 this.label1.Text      = messages[2];
             }
         }
         else
         {
             var property    = (PropertyDTO)this.dataGridView1.CurrentRow.DataBoundItem;
             var isSuccesful = service.RemoveDynamicProperty(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[2];
             }
         }
     }
 }