Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
0
        private void toolStripButtonAdd_Click(object sender, EventArgs e)
        {
            Form_Add_PowerTool form = new Form_Add_PowerTool(lstT, lstPT.Count + 1, Сountrys);

            form.ShowDialog();
            if (form.pt != null)
            {
                if (form.pt.PowerType == 1)
                {
                    lstPT.Add(new Screwdrivers(form.pt));
                }
                else if (form.pt.PowerType == 2)
                {
                    lstPT.Add(new Drills(form.pt));
                }
                else if (form.pt.PowerType == 3)
                {
                    lstPT.Add(new Perforators(form.pt));
                }
                else if (form.pt.PowerType == 4)
                {
                    lstPT.Add(new Bulgarians(form.pt));
                }
                else if (form.pt.PowerType == 5)
                {
                    lstPT.Add(new Saw(form.pt));
                }
                else if (form.pt.PowerType == 6)
                {
                    lstPT.Add(new Screwdrivers(form.pt));
                }
                else
                {
                    lstPT.Add(new PowerTool(form.pt));
                }


                int i = lstPT.Count - 1;
                dataGridView2.Rows.Add(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);
            }
        }