Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        //Create Farm
        private void button2_Click(object sender, EventArgs e)
        {
            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.SelectedText);
            switch (int.Parse(cmbAmountOfAnimals.SelectedText))
            {
            case 2:
                dataToSave.Add(cmbAnimalOne.SelectedText + Changebles.splitOn + txtAnimalAmountOne);
                dataToSave.Add(cmbAnimalTwo.SelectedText + Changebles.splitOn + txtAnimalAmountTwo);

                break;

            case 3:
                dataToSave.Add(cmbAnimalOne.SelectedText + Changebles.splitOn + txtAnimalAmountOne);
                dataToSave.Add(cmbAnimalTwo.SelectedText + Changebles.splitOn + txtAnimalAmountTwo);
                dataToSave.Add(cmbAnimalThree.SelectedText + Changebles.splitOn + txtAnimalAmountThree);
                break;

            case 4:
                dataToSave.Add(cmbAnimalOne.SelectedText + Changebles.splitOn + txtAnimalAmountOne);
                dataToSave.Add(cmbAnimalTwo.SelectedText + Changebles.splitOn + txtAnimalAmountTwo);
                dataToSave.Add(cmbAnimalThree.SelectedText + Changebles.splitOn + txtAnimalAmountThree);
                dataToSave.Add(cmbAnimalFour.SelectedText + Changebles.splitOn + txtAnimalAmountFour);
                break;

            case 5:
                dataToSave.Add(cmbAnimalOne.SelectedText + Changebles.splitOn + txtAnimalAmountOne);
                dataToSave.Add(cmbAnimalTwo.SelectedText + Changebles.splitOn + txtAnimalAmountTwo);
                dataToSave.Add(cmbAnimalThree.SelectedText + Changebles.splitOn + txtAnimalAmountThree);
                dataToSave.Add(cmbAnimalFour.SelectedText + Changebles.splitOn + txtAnimalAmountFour);
                dataToSave.Add(cmbAnimalFive.SelectedText + Changebles.splitOn + txtAnimalAmountFive);
                break;

            default:
                break;
            }
            save.SaveThis(dataToSave, farmToSave, farmerWorkingWith);

            LoggedIn frmLogged = new LoggedIn(farmerWorkingWith);
        }
Exemplo n.º 3
0
        //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!");
                }
            }
        }