예제 #1
0
        // save new brand in csv-file
        private void saveBrandtoolStripButton_Click(object sender, EventArgs e)
        {
            dataGridViewMaker.ReadOnly = true;
            int           n        = dataGridViewMaker.RowCount - 1;
            int           k        = int.Parse(brand.lastId());
            string        id       = (k + 1).ToString();
            string        name     = dataGridViewMaker.Rows[n].Cells[2].Value.ToString();
            List <string> rowMaker = new List <string>();

            rowMaker.Add(id);
            rowMaker.Add(name);
            brand.Add(rowMaker);
        }
예제 #2
0
        // save new model in csv-file
        private void saveModelsToolStripButton_Click(object sender, EventArgs e)
        {
            dataGridViewModel.ReadOnly = true;
            int           n        = dataGridViewModel.RowCount - 1;
            int           k_model  = int.Parse(models.lastId());
            string        id       = (k_model + 1).ToString();
            string        id_brand = selectIdBrand.ToString();
            string        name     = dataGridViewModel.Rows[n].Cells[2].Value.ToString();
            List <string> rowModel = new List <string>();

            rowModel.Add(id);
            rowModel.Add(id_brand);
            rowModel.Add(name);
            models.Add(rowModel);
        }
예제 #3
0
 private void toolStripButton3_Click(object sender, EventArgs e)
 {
     try
     {
         string id         = "";
         string name       = "";
         string address_st = "";
         string tel        = "";
         if (edit)
         {
             id         = dataGridViewAddress.Rows[selectIndex].Cells[1].Value.ToString();
             name       = dataGridViewAddress.Rows[selectIndex].Cells[2].Value.ToString();
             address_st = dataGridViewAddress.Rows[selectIndex].Cells[3].Value.ToString();
             tel        = dataGridViewAddress.Rows[selectIndex].Cells[4].Value.ToString();
             address.Edit(selectId, id + ";" + name + ";" + address_st + ";" + tel + ";");
         }
         else
         {
             int n = dataGridViewAddress.RowCount - 1;
             int k = int.Parse(address.lastId());
             id         = (k + 1).ToString();
             name       = dataGridViewAddress.Rows[n].Cells[2].Value.ToString();
             address_st = dataGridViewAddress.Rows[n].Cells[3].Value.ToString();
             tel        = dataGridViewAddress.Rows[n].Cells[4].Value.ToString();
             List <string> rowAddress = new List <string>();
             rowAddress.Add(id);
             rowAddress.Add(name);
             rowAddress.Add(address_st);
             rowAddress.Add(tel);
             address.Add(rowAddress);
         }
         dataGridViewAddress.ReadOnly = true;
     }
     catch
     {
     }
 }
예제 #4
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //     bool f = other.checkBoxCZ.Checked;
            //    MessageBox.Show(f.ToString());
            try
            {
                //add base properties

                int k_properties = int.Parse(baseProperties.lastId());
                // MessageBox.Show(k_properties.ToString());
                IdProperties = (k_properties + 1).ToString();
                rowProperties.Add(IdProperties);
                rowProperties.Add(comboBoxGas.SelectedItem.ToString());
                rowProperties.Add(textBoxVMotor.Text);
                rowProperties.Add(textBoxZul.Text);
                rowProperties.Add(textBoxNorma.Text);
                rowProperties.Add(textBoxBox.Text);
                rowProperties.Add(textBoxPrivid.Text);

                bool isRecord = false;
                using (CsvReader csv = new CsvReader(new StreamReader("baseProperties.csv"), true, ';'))
                {
                    bool a = true;
                    while (csv.ReadNextRecord())
                    {
                        // MessageBox.Show(csv.FieldCount.ToString());
                        int k = 0;
                        for (int i = 1; i < csv.FieldCount; i++)
                        {
                            // MessageBox.Show("i " + i + " " + csv[i] + " " + rowProperties[i]);
                            if (csv[i].CompareTo(rowProperties[i]) == 0)
                            {
                                k++;
                            }
                        }
                        // j++;
                        if (k == 6)
                        {
                            IdProperties = csv[0];
                            isRecord     = true;
                            break;
                        }
                        //if (csv[1] == IdBrand && IdBrand != "")
                        //{
                        //    comboBoxModels.Items.Add(csv[2]);
                        //    dataModels.n = csv[0];
                        //    dataModels.name = csv[2];
                        //    Modelslist.Add(dataModels);
                        //}
                        //   else
                        // comboBoxModels.Items.Add(csv[2]);
                    }
                }

                if (!isRecord)
                {
                    baseProperties.Add(rowProperties);
                }

                //add  properties
                List <string> rowNewCar = new List <string>();
                int           k_newCar  = int.Parse(Car.lastId());
                string        id_newCar = (k_newCar + 1).ToString();
                // MessageBox.Show(id_newCar);
                rowNewCar.Add(id_newCar);
                rowNewCar.Add(IdBrand); //1
                rowNewCar.Add(IdModel); //2
                rowNewCar.Add(IdAddress);
                rowNewCar.Add(IdType);  //4
                rowNewCar.Add(IdColor);
                rowNewCar.Add(IdProperties);
                rowNewCar.Add(textBoxPeredPidvisk.Text);//7
                rowNewCar.Add(textBoxZadPidvisk.Text);
                rowNewCar.Add(textBoxPeredStop.Text);
                rowNewCar.Add(textBoxZadStop.Text);
                //rowNewCar.Add(textBoxPeredStop.Text);
                rowNewCar.Add(textBoxGasCity.Text);
                rowNewCar.Add(textBoxGasRoad.Text);
                rowNewCar.Add(textBoxGasCombo.Text);
                rowNewCar.Add(textBoxMaxSpeed.Text);
                rowNewCar.Add(textBoxSizeCar.Text);
                rowNewCar.Add(textBoxKlirens.Text);
                rowNewCar.Add(textBoxVBak.Text);
                rowNewCar.Add(textBoxVBag.Text);
                rowNewCar.Add(textBoxSizeS.Text);
                rowNewCar.Add(textBoxYear.Text);
                rowNewCar.Add(textBoxPrice.Text); //21
                rowNewCar.Add(other.checkBoxCZ.Checked.ToString());
                rowNewCar.Add(other.checkBoxSP.Checked.ToString());
                rowNewCar.Add(other.checkBoxPF.Checked.ToString());
                rowNewCar.Add(other.checkBoxK.Checked.ToString());
                rowNewCar.Add(other.checkBoxE.Checked.ToString());
                rowNewCar.Add(other.checkBoxPZS.Checked.ToString());
                rowNewCar.Add(other.checkBoxPPS.Checked.ToString());
                rowNewCar.Add(other.checkBoxPC.Checked.ToString());
                rowNewCar.Add(other.checkBoxDZ.Checked.ToString());
                Car.Add(rowNewCar);
                MessageBox.Show("Успішно додано!");
                Close();
            }
            catch (Exception t)
            {
                MessageBox.Show("Помилка додавання запусу в таблицю. Вибачте за незручності. Детальніше: " + t.Message);
            }
        }