Example #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            int number = 0;

            try
            {
                number = Int32.Parse(textBoxNumber.Text);
            }
            catch { MessageBox.Show("Error"); return; }

            double price = 0;

            try
            {
                price = double.Parse(textBoxPrice.Text);
            }
            catch { MessageBox.Show("Некоректне значення ціни!"); return; }

            pt          = new PowerTool(number, textBoxPrice.Text, textBoxName.Text, dateTimePicker1.Value.Date.Day, dateTimePicker1.Value.Date.Month, dateTimePicker1.Value.Date.Year, lstT[comboBoxType.SelectedIndex].Number, comboBoxCountry.SelectedIndex.ToString());
            pt.Sides[0] = Int32.Parse(textBoxWidth.Text);
            pt.Sides[1] = Int32.Parse(textBoxHeight.Text);
            pt.Sides[2] = Int32.Parse(textBoxLength.Text);
            pt.features.Clear();
            for (int i = 0; i < listBoxP.Items.Count; i++)
            {
                pt.features.Add(listBoxP.Items[i].ToString());
            }
            pt.photo_file_name = file_name;
            this.Close();
        }
Example #2
0
        private void toolStripButtonEdit_Click(object sender, EventArgs e)
        {
            if (dataGridView2.CurrentRow != null)
            {
                int j = dataGridView2.CurrentRow.Index;
                if (j >= lstPT.Count)
                {
                    return;
                }
                int id = Int32.Parse(dataGridView2[6, j].Value.ToString());

                int i = Get_number_by_id(id);
                Form_Add_PowerTool form = new Form_Add_PowerTool(lstT, lstPT[i], Сountrys);
                form.ShowDialog();
                if (form.pt != null)
                {
                    dataGridView2.Rows.RemoveAt(j);

                    PowerTool p = new PowerTool(form.pt);

                    if (form.pt.PowerType == 1)
                    {
                        p = new Screwdrivers(form.pt);
                    }
                    else if (form.pt.PowerType == 2)
                    {
                        p = new Drills(form.pt);
                    }
                    else if (form.pt.PowerType == 3)
                    {
                        p = new Perforators(form.pt);
                    }
                    else if (form.pt.PowerType == 4)
                    {
                        p = new Bulgarians(form.pt);
                    }
                    else if (form.pt.PowerType == 5)
                    {
                        p = new Saw(form.pt);
                    }
                    else if (form.pt.PowerType == 6)
                    {
                        p = new Screwdrivers(form.pt);
                    }
                    else
                    {
                        lstPT.Add(new PowerTool(form.pt));
                    }
                    lstPT[i] = p;


                    dataGridView2.Rows.Insert(j, lstT[lstPT[i].PowerType - 1].Name, lstPT[i].ActionPrice, lstPT[i].Name, lstPT[i].Years, lstPT[i].DeliveryPrice(), Сountrys[Int32.Parse(lstPT[i].Country)], lstPT[i].Number);
                }
            }
        }
Example #3
0
        private bool is_filter(PowerTool s)
        {
            int    i        = comboBoxFaculty.SelectedIndex;
            double minPrice = double.Parse(textBoxMinPrice.Text);
            double maxPrice = double.Parse(textBoxMaxPrice.Text);

            if (((comboBoxFaculty.SelectedIndex == 0) || (s.PowerType == i)) && (minPrice <= s.ActionPrice) && (s.ActionPrice <= maxPrice))
            {
                return(true);
            }
            return(false);
        }
Example #4
0
 public PowerTool(PowerTool p)
 {
     this.Number          = p.Number;
     this.Price           = p.Price;
     this.Name            = p.Name;
     this.Day             = p.Day;
     this.Month           = p.Month;
     this.Year            = p.Year;
     this.PowerType       = p.PowerType;
     this.Country         = p.Country;
     this.photo_file_name = p.photo_file_name;
     Sides    = new int[3];
     Sides[0] = p.Sides[0];
     Sides[1] = p.Sides[0];
     Sides[2] = p.Sides[0];
     features = new List <string>();
     features = p.features;
 }
Example #5
0
        public Form_Add_PowerTool(List <PowerToolType> lstT, PowerTool pt, List <string> Сountrys) : this(lstT, pt.Number, Сountrys)
        {
            textBoxPrice.Text          = pt.Price;
            textBoxName.Text           = pt.Name;
            textBoxWeight.Text         = pt.V.ToString();
            comboBoxType.SelectedIndex = pt.PowerType - 1;
            dateTimePicker1.Value      = new DateTime(pt.Year, pt.Month, pt.Day);
            this.Text = pt.Price + " № " + pt.Number;


            textBoxWidth.Text  = pt.Sides[0].ToString();
            textBoxHeight.Text = pt.Sides[1].ToString();
            textBoxLength.Text = pt.Sides[2].ToString();


            for (int i = 0; i < pt.features.Count; i++)
            {
                listBoxP.Items.Add(pt.features[i]);
            }
            file_name = pt.photo_file_name;
            string new_file_name = "Photo\\" + pt.photo_file_name;

            if (File.Exists(new_file_name))
            {
                image = new Bitmap(new_file_name);
            }
            else
            {
                image = new Bitmap("Photo\\no_pic_person.jpg");
            }
            pictureBox1.Image = image;
            pictureBox1.Invalidate();
            //image.Dispose();
            try
            { comboBoxCountry.SelectedIndex = Int32.Parse(pt.Country); }
            catch
            {
            }
        }
Example #6
0
 public Perforators(PowerTool p) : base(p)
 {
 }
Example #7
0
 public Saw(PowerTool p) : base(p)
 {
 }
Example #8
0
 public Grinders(PowerTool p) : base(p)
 {
 }
Example #9
0
 public Screwdrivers(PowerTool p) : base(p)
 {
 }
Example #10
0
 public Drills(PowerTool p) : base(p)
 {
 }
Example #11
0
 public Bulgarians(PowerTool p) : base(p)
 {
 }