Exemple #1
0
        private void del_Click(object o, EventArgs args)
        {
            TextBox box = flowLayoutPanel6.Controls[2] as TextBox;

            if (flowLayoutPanel6.Controls[2].BackColor == Color.Crimson)
            {
                TextBox b = flowLayoutPanel6.Controls[0] as TextBox;
                b.Text = "Taxer with such ID or name have not been found!";
            }
            else if (!CheckTaxIsFree(Tax_park.FindTaxer(box.Text)))
            {
                TextBox b = flowLayoutPanel6.Controls[0] as TextBox;
                b.Text = "Taxer is in a trip now. Wait till it comes!";
            }
            else
            {
                Taxer          tax          = Tax_park.FindTaxer(box.Text);
                List <Control> listControls = new List <Control>();
                foreach (Control control in flowLayoutPanel1.Controls)
                {
                    listControls.Add(control);
                }

                foreach (Control control in listControls)
                {
                    Button b = control as Button;
                    if (b.Text == tax.Name)
                    {
                        flowLayoutPanel1.Controls.Remove(control);
                        control.Dispose();
                    }
                }
                Tax_park.DelTaxer(tax);
                List <Control> listControls2 = new List <Control>();
                foreach (Control control in flowLayoutPanel6.Controls)
                {
                    listControls2.Add(control);
                }

                foreach (Control control in listControls2)
                {
                    flowLayoutPanel6.Controls.Remove(control);
                    control.Dispose();
                }
            }
        }
Exemple #2
0
        private bool CheckTaxIsFree(Taxer tax)
        {
            List <Control> listControls = new List <Control>();

            foreach (Control control in flowLayoutPanel1.Controls)
            {
                listControls.Add(control);
            }

            foreach (Control control in listControls)
            {
                Button b = control as Button;
                if (tax.Name == b.Text)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #3
0
        private void accept3_Click(object o, EventArgs args)
        {
            List <Control> controls = new List <Control>();

            foreach (Control c in flowLayoutPanel6.Controls)
            {
                controls.Add(c);
            }
            if (controls.Any(x => x.BackColor == Color.Crimson))
            {
                TextBox b2 = flowLayoutPanel6.Controls[0] as TextBox;
                b2.Text = "Salary must contain only integers!!!";
            }
            else
            {
                foreach (Control cont in controls)
                {
                    if (cont.Enabled && cont.BackColor == Color.OldLace)
                    {
                        TextBox b      = cont as TextBox;
                        int     index  = flowLayoutPanel6.Controls.GetChildIndex(b);
                        Taxer   curTax = Tax_park.FindTaxer(flowLayoutPanel6.Controls[3 + 3 * ((int)((index - 3) / 3))].Text);
                        Tax_park.SetTaxerSalaryPerTrip(curTax, Convert.ToInt32(b.Text));
                    }
                }

                List <Control> listControls2 = new List <Control>();
                foreach (Control control in flowLayoutPanel6.Controls)
                {
                    listControls2.Add(control);
                }

                foreach (Control control in listControls2)
                {
                    flowLayoutPanel6.Controls.Remove(control);
                    control.Dispose();
                }
            }
        }