private static int saveToTableOfPart(FormSaveToDataBase form, string date)
        {
            string nameOfPart   = form.textBox1.Text;
            int    cipherDetail = Convert.ToInt32(form.textBox2.Text);

            bool isCipherExist = false;

            try
            {
                dbConnection.GetDataUsingDataAdapter($@"SELECT * FROM {DETAIL} WHERE cipher_detail = {cipherDetail}", ref tempDataTable, ref tableDataAdapter);

                isCipherExist = tempDataTable.Rows[0] != null;
            }

            catch { isCipherExist = false; }

            if (!isCipherExist)
            {
                double lengthOfPart = Part.getLenghtOfPart();

                dbConnection.SetQuery($@"INSERT INTO {DETAIL} VALUES ('{nameOfPart}', {cipherDetail}, '{date}', {doubleToStringForDb(lengthOfPart)})");
            }

            return(cipherDetail);
        }
        private static void saveWorkpieceToTableOfOperations(FormSaveToDataBase form, int index)
        {
            ParametersWorkpiece parametersWorkpiece = Part.getWorkpiece();

            // ClassesToCalculate.ResultsOfCalculation resultOfCalculation = Part.getSurfaceOnIndex(0).getResultsOfCalculation();

            // form.переходыTableAdapter.Insert(Convert.ToInt16(form.dataGridView1[0, index - 1].Value.ToString()) + 1, 0, parametersWorkpiece.getNameOfWorkpiece(), "", (float)parametersWorkpiece.getSurfaceRoughnessRz(), (float)parametersWorkpiece.getThicknessOfDefectiveCoating(), (float)resultOfCalculation.getSpatialDeviation()[0], (float)resultOfCalculation.getdeviationOfInstallation()[0], (float)resultOfCalculation.getAccuracies()[0], (float)resultOfCalculation.getNominalAllowance()[0], (float)resultOfCalculation.getSizeOfWorkprieceAfterOperation()[0], parametersWorkpiece.getIdWorkpiece(), null, (float)parametersWorkpiece.getValidOffsetSurface(), (int)parametersWorkpiece.getKvalitet());
        }
        private static void saveToDatabase(FormSaveToDataBase form)
        {
            DateTime date         = DateTime.Now;
            string   dateToString = date.ToString("MM.dd.yyyy");

            int cipherDetail  = saveToTableOfPart(form, dateToString);
            int idCalculation = saveToCalculation(form, cipherDetail, dateToString);

            saveToTableTechnologicalProcessAndSurfaces(form, cipherDetail, idCalculation);
        }
 public static void buttonSaveToDatabase(FormSaveToDataBase form)
 {
     try
     {
         if (checkNameOfPartAndNameOfSurface(form))
         {
             saveToDatabase(form);
             MessageBox.Show("Сохранение прошло успешно");
             form.Close();
         }
     }
     catch (Exception e) { MessageBox.Show("Ошибка Базы данных" + e.TargetSite, "Ошибка"); }
 }
        private static void saveToTableTechnologicalProcessAndSurfaces(FormSaveToDataBase form, int cipherDetail, int idCalculation)
        {
            ParametersWorkpiece workpiece = Part.getWorkpiece();
            int idWorkpieceInDB           = saveWorkpiece(cipherDetail, idCalculation, workpiece);

            List <Operation> technologicalProcess = Part.getSurfaceOnIndex(0).getOperations();
            int countOperation = Part.getSurfaceOnIndex(0).getCountShortListOperation();

            for (int i = 0; i < countOperation; i++)
            {
                int idOperation = saveOperationInTechnologicalProcess(cipherDetail, idCalculation, technologicalProcess[i], i + 1);
            }

            saveSurfaces(cipherDetail, idCalculation);
        }
        private static bool checkNameOfPartAndNameOfSurface(FormSaveToDataBase form)
        {
            if (form.textBox1.Text.Equals(""))
            {
                MessageBox.Show("Введите наименование детали", "Ошибка");
                return(false);
            }

            if (form.textBox2.Text.Equals(""))
            {
                MessageBox.Show("Введите обозначение поверхности", "Ошибка");
                return(false);
            }

            return(true);
        }
        private static void saveToTableOfOperations(FormSaveToDataBase form, int index)
        {
            Surface surface = Part.getSurfaceOnIndex(0);

            List <ParametersOperation> parametersOperations = surface.getParametersOperation();

            int numberOfOperation = surface.getCountLongListOperation();

            for (int i = 0; i < numberOfOperation; i++)
            {
                ParametersOperation parametersOperation = parametersOperations[i];

                ClassesToCalculate.ResultsOfCalculation resultsOfCalculation = parametersOperation.getResultsOfCalculation();

                string nameOperation = parametersOperation.getTypeOfMachining() + ',' + parametersOperation.getPrecisionOfMachining();

                //  form.переходыTableAdapter.Insert(Convert.ToInt16(form.dataGridView1[0, index - 1].Value.ToString()) + 1, i + 1, nameOperation, parametersOperation.getTypeOfInstrument(), (float)parametersOperation.getSurfaceRoughnessRz(), (float)parametersOperation.getThicknessOfDefectiveCoating(), (float)resultsOfCalculation.getSpatialDeviation(), (float)resultsOfCalculation.getdeviationOfInstallation(), (float)resultsOfCalculation.getAccuracies(), (float)resultsOfCalculation.getNominalAllowance(), (float)resultsOfCalculation.getSizeOfWorkprieceAfterOperation(), parametersOperation.getIdOperation(), null, (float)parametersOperation.getCoefficientOfRefinement(), (int)parametersOperation.getKvalitet());
            }
        }
Esempio n. 8
0
        private void buttonSaveToBase_Click(object sender, EventArgs e)
        {
            FormSaveToDataBase form = new FormSaveToDataBase();

            form.ShowDialog();
        }
        private static int saveToCalculation(FormSaveToDataBase form, int cipherDetail, string date)
        {
            dbConnection.SetQuery($@"INSERT INTO {CALCULATION} VALUES ({cipherDetail}, '{date}')");

            return(getIdentCurrent(CALCULATION));
        }