private void btnBack_Click(object sender, EventArgs e) { LoggedIn frmLog = new LoggedIn(farmerWorkingWith); frmLog.Show(); this.Close(); }
public void LogginSucc(Farmer farmer) { farmer = farmer.getUserInformation(); txtPassword.Clear(); txtUsername.Clear(); string mes = ("Welcome back " + farmer.UserName + "!"); MessageBox.Show(mes); LoggedIn frmLog = new LoggedIn(farmer); this.Hide(); frmLog.Show(); }
//Create Farm private void button2_Click(object sender, EventArgs e) { if (txtFarmSize.Text == "" || txtFarmName.Text == "" || cmbAmountOfAnimals.Text == "") { MessageBox.Show("Please fill in all fields!"); } else { bool shouldIRun = true; switch (int.Parse(cmbAmountOfAnimals.Text)) { case 2: if (txtAnimalAmountOne.Text == "" || txtAnimalAmountTwo.Text == "") { shouldIRun = false; } break; case 3: if (txtAnimalAmountOne.Text == "" || txtAnimalAmountTwo.Text == "" || txtAnimalAmountThree.Text == "") { shouldIRun = false; } break; case 4: if (txtAnimalAmountOne.Text == "" || txtAnimalAmountTwo.Text == "" || txtAnimalAmountThree.Text == "" || txtAnimalAmountFour.Text == "") { shouldIRun = false; } break; case 5: if (txtAnimalAmountOne.Text == "" || txtAnimalAmountTwo.Text == "" || txtAnimalAmountThree.Text == "" || txtAnimalAmountFour.Text == "" || txtAnimalAmountFive.Text == "") { shouldIRun = false; } break; default: break; } if (shouldIRun) { List <string> dataToSave = new List <string>(); Farm farmToSave = new Farm(txtFarmName.Text, int.Parse(txtFarmSize.Text)); //dataToSave.Add(txtFarmName.Text + Changebles.splitOn + txtFarmSize.Text); SaveLoad save = new SaveLoad(); dataToSave.Add(cmbAmountOfAnimals.Text); switch (int.Parse(cmbAmountOfAnimals.Text)) { case 2: dataToSave.Add(cmbAnimalOne.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountOne.Text); dataToSave.Add(cmbAnimalTwo.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountTwo.Text); break; case 3: dataToSave.Add(cmbAnimalOne.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountOne.Text); dataToSave.Add(cmbAnimalTwo.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountTwo.Text); dataToSave.Add(cmbAnimalThree.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountThree.Text); break; case 4: dataToSave.Add(cmbAnimalOne.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountOne.Text); dataToSave.Add(cmbAnimalTwo.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountTwo.Text); dataToSave.Add(cmbAnimalThree.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountThree.Text); dataToSave.Add(cmbAnimalFour.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountFour.Text); break; case 5: dataToSave.Add(cmbAnimalOne.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountOne.Text); dataToSave.Add(cmbAnimalTwo.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountTwo.Text); dataToSave.Add(cmbAnimalThree.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountThree.Text); dataToSave.Add(cmbAnimalFour.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountFour.Text); dataToSave.Add(cmbAnimalFive.Text.SplitInfo(0) + Changebles.splitOn + txtAnimalAmountFive.Text); break; default: break; } save.SaveThis(dataToSave, farmToSave, farmerWorkingWith); farmToSave.InsertFarm(farmerWorkingWith.UserUsername.ToString()); LoggedIn frmLogged = new LoggedIn(farmerWorkingWith); frmLogged.Show(); this.Close(); } else { MessageBox.Show("Please fill in all fields!"); } } }