Ejemplo n.º 1
0
 //Method for the event to go to a specific form if a farmer that exists is selected
 private void NavResumeOrFarmView(Farmer CurrentFarmer)
 {
     if (CurrentFarmer.GetFarmSize() > 0)
     {
         if (CurrentFarmer.numOfAnimals() > 0)
         {
             Farm_View form = new Farm_View(CurrentFarmer.ID);
             this.Hide();
             form.ShowDialog();
             this.Close();
         }
         else
         {
             Animal_Selection form = new Animal_Selection(CurrentFarmer.ID, CurrentFarmer.GetFarmSize());
             this.Hide();
             form.ShowDialog();
             this.Close();
         }
     }
     else
     {
         Farm_Creation form = new Farm_Creation(CurrentFarmer.ID);
         this.Hide();
         form.ShowDialog();
         this.Close();
     }
 }
Ejemplo n.º 2
0
 private void pbxNext_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName.Text == "")
         {
             throw new NoFarmerNameException();
         }
         int   success     = 0;
         Style FarmerStyle = new Style();
         FarmerStyle.Eyecolour  = txtEye.Text;
         FarmerStyle.OutfitType = txtOutfit.Text;
         FarmerStyle.SkinColour = txtSkin.Text;
         FarmerStyle.HairColour = txtHair.Text;
         Farmer        farmer      = new Farmer(txtName.Text, cmbGender.Text, int.Parse(txtAge.Text), FarmerStyle);
         MessageObject FarmerToAdd = new MessageObject();
         FarmerToAdd.Data             = farmer.BinarySerialization();
         FarmerToAdd.FormIdentifier   = 2;
         FarmerToAdd.ObjectIdentifier = 1;
         FarmerToAdd.ActionIdentifier = 2;
         Client.SendData(FarmerToAdd);
         // success = farmer.InsertFarmer();3
         Farm_Creation form = new Farm_Creation();
         this.Hide();
         form.ShowDialog();
         this.Close();
     }
     catch (NoFarmerNameException)
     {
         MessageBox.Show("Your Farmer needs a Name");
     }
     catch (FormatException)
     {
         MessageBox.Show("Age has to be a number");
     }
 }