public static void selectedIndexNamePartChanged(FormOfWorkWithDatabase form)
        {
            int selectIndexNamePart   = form.NamePart.SelectedIndex;
            int selectIndexCipherPart = form.CipherPart.SelectedIndex;

            if (selectIndexNamePart != selectIndexCipherPart)
            {
                form.CipherPart.SelectedIndex = selectIndexNamePart;
            }

            form.LengthPart.Text = searchPart[selectIndexNamePart].getLengthPart().ToString();

            selectCalculationInDB(selectIndexNamePart);

            form.Calculation.Items.Clear();

            foreach (DependenceCalculation date in calculations)
            {
                form.Calculation.Items.Add(date.getDate());
            }
            try
            {
                form.Calculation.SelectedIndex = 0;
            }
            catch { }
        }
        private static DependenceSurface createSurface(DataRow row, FormOfWorkWithDatabase form)
        {
            int idInDb = Convert.ToInt32(row[0]);

            string nameSurface = Convert.ToString(row[2]);
            double diameter    = Convert.ToDouble(row[3]);

            int        typeIndex  = Convert.ToInt32(row[4]);
            ComboBox   comboBox   = form.parrentForm.TypeOfPart;
            TypeOfPart typeOfPart = selectIndexOfTypesFromComboBox(typeIndex, comboBox);

            typeIndex = Convert.ToInt32(row[5]);
            comboBox  = form.parrentForm.TypeOfAllowance;
            TypeOfPart typeOfAllowance = selectIndexOfTypesFromComboBox(typeIndex, comboBox);

            typeIndex = Convert.ToInt32(row[6]);
            comboBox  = form.parrentForm.TypeOfProcessedSurface;
            TypeOfPart typeOfProcessedSurface = selectIndexOfTypesFromComboBox(typeIndex, comboBox);

            double surfaceRoughness = Convert.ToDouble(row[7]);
            double holeDepth        = Convert.ToDouble(row[8]);
            double tolerance        = Convert.ToDouble(row[9]);

            DependenceSurface surface = new DependenceSurface(idInDb, nameSurface, diameter, typeOfPart, typeOfAllowance, typeOfProcessedSurface, surfaceRoughness, tolerance, holeDepth);

            return(surface);
        }
        public static void TextChangedInComboBoxNamePart(FormOfWorkWithDatabase form)
        {
            try
            {
                List <DependencePart> serchInPart = new List <DependencePart>();
                string serchString = form.NamePart.SelectedText;

                foreach (DependencePart part in parts)
                {
                    if (part.getName().StartsWith(serchString))
                    {
                        serchInPart.Add(part);
                    }
                }

                form.NamePart.Items.Clear();

                foreach (DependencePart part in serchInPart)
                {
                    form.NamePart.Items.Add(part.getName());
                }

                form.NamePart.SelectedIndex = 0;
                form.NamePart.DroppedDown   = true;
            }
            catch { }
        }
        private static void selectTechnologicalProcess(int index, FormOfWorkWithDatabase form)
        {
            DataTable tablesDataTable = new DataTable();
            DataTable tempDataTable   = new DataTable();

            DependenceCalculation calculation = calculations[index];

            dbConnection.GetDataUsingDataAdapter($@"SELECT * FROM Operations WHERE ID_calculation = {calculation.getId()}", ref tempDataTable, ref tableDataAdapter);
            try
            {
                int countRows = tempDataTable.Rows.Count;

                workpriece = createWorkpriece(tempDataTable.Rows[0]);

                technologicalProcess = new List <DependenceOperationInTechnologicalProcess>();

                for (int i = 1; i < countRows; i++)
                {
                    DataRow row = tempDataTable.Rows[i];
                    technologicalProcess.Add(createOperation(row));
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
        public static void selectedIndexComboBoxCalculationChange(FormOfWorkWithDatabase form)
        {
            int selectedIndex = form.Calculation.SelectedIndex;

            selectTechnologicalProcess(selectedIndex, form);
            getTechnologicalProcessInTreeView(form);

            getSurfacesInComboBoxAndTextBoxes(form, selectedIndex);
        }
        private static void insertPartInMainForm(FormOfWorkWithDatabase form)
        {
            Part.insertListOfSurfacess(form.parrentForm);
            Part.insertParametersOfPartInTextboxes(form.parrentForm);
            Part.insertListOfOperationsInTreeView(form.parrentForm);

            EventClickOnButtonOfSelectWorkpriece.enabledTextBoxes(form.parrentForm);

            form.parrentForm.SurfacesTreeView.SelectedNode = form.parrentForm.SurfacesTreeView.Nodes[0];
        }
        public static void selectedIndexCipherPartChange(FormOfWorkWithDatabase form)
        {
            int selectIndexCipherPart = form.CipherPart.SelectedIndex;
            int selectIndexNamePart   = form.NamePart.SelectedIndex;

            if (selectIndexCipherPart != selectIndexNamePart)
            {
                form.NamePart.SelectedIndex = selectIndexCipherPart;
            }
        }
        public static void buttonClickSaveToPart(FormOfWorkWithDatabase form)
        {
            saveWorkpriece();
            saveTechnologicalProcessInPart();
            saveSurfaceInPart(form);

            insertPartInMainForm(form);

            form.Close();
        }
        public static void selectedIndexComboBoxSurfaceChange(FormOfWorkWithDatabase form)
        {
            int selectedIndex = form.Surfaces.SelectedIndex;

            selectOperationInDB(selectedIndex);

            try
            {
                insertParametersIntextBox(form, selectedIndex);
                insertOperationsInTreeView(form);
            }
            catch { }
        }
Example #10
0
 private static void insertParametersOfOperations(FormOfWorkWithDatabase form)
 {
     /* int numberOfOperations = form.dataGridView2.Rows.Count - 1;
      * Surface surface = new Surface();
      *
      * for (int i = 1; i < numberOfOperations; i++)
      * {
      *   ParametersOperation parametersOperation = createOperation(form, i);
      *  //surface.setOpetation(parametersOperation);
      * }
      *
      * Part.setOpetations(surface, 0);*/
 }
        private static void getTechnologicalProcessInTreeView(FormOfWorkWithDatabase form)
        {
            TreeNodeCollection nodes = form.TechnologicalProcess.Nodes;

            nodes.Clear();

            nodes.Add(workpriece.getNameWorkpriece());

            foreach (DependenceOperationInTechnologicalProcess operation in technologicalProcess)
            {
                string nameOperation = operation.getOperation().getTypeOfMachining();
                nodes.Add(nameOperation);
            }
        }
        private static void insertOperationsInTreeView(FormOfWorkWithDatabase form)
        {
            defineDependenciesOperations();

            form.Operations.Nodes.Clear();

            foreach (DependenceOperation operation in operations)
            {
                string typeOfMachining  = operation.getOperation().getTypeOfMachining();
                string typeOfInstrument = operation.getOperation().getTypeOfInstrument();

                form.Operations.Nodes.Add(typeOfMachining + ' ' + typeOfInstrument);
            }
        }
Example #13
0
 private static void insertParametersOfWorkpriece(FormOfWorkWithDatabase form)
 {
     /*string nameOfWorkpiece = form.dataGridView1.CurrentRow.Cells[11].Value.ToString();
      * int idWorkpiece = Convert.ToInt32(form.dataGridView2[11, 0].Value.ToString());
      *
      * double surfaceRoughnessRz = Convert.ToDouble(form.dataGridView2[4, 0].Value.ToString());
      * Interval recommendedIntervalRz = new Interval();
      *
      * int kvalitet = Convert.ToInt32(form.dataGridView2[14, 0].Value.ToString());
      * double thicknessOfDefectiveCoating = Convert.ToDouble(form.dataGridView2[5, 0].Value.ToString());
      * double validOffsetSurface = Convert.ToDouble(form.dataGridView2[13, 0].Value.ToString());
      *
      * ParametersWorkpiece parametersWorkpiece = new ParametersWorkpiece(nameOfWorkpiece, idWorkpiece, surfaceRoughnessRz, recommendedIntervalRz, kvalitet, thicknessOfDefectiveCoating, validOffsetSurface);
      * Part.setWorkpiece(parametersWorkpiece);*/
 }
        private static void insertParametersIntextBox(FormOfWorkWithDatabase form, int index)
        {
            DependenceSurface   surface    = surfaces[index];
            ParametersOfSurface parameters = surface.getParametersOfSurface();

            form.diameterOfSurface.Text = parameters.getDiameterOfPart().ToString();

            form.typeOfPart.Text             = parameters.getTypeOfPart().getName();
            form.typeOfAllowance.Text        = parameters.getTypeOfAllowance().getName();
            form.TypeOfProcessedSurface.Text = parameters.getTypeOfProcessedSurface().getName();

            form.SurfaceRoughness.Text = ConversionRoughnessRzAndRa.RzToRa(parameters.getSurfaceRoughnessRz()).ToString();
            form.HoleDepth.Text        = parameters.getHoleDepth().ToString();
            form.Tolerance.Text        = parameters.getAllowance().ToString();
        }
Example #15
0
        private void открытьБДToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormOfWorkWithDatabase formOfWorkWithDatabase = new FormOfWorkWithDatabase("", this);

            formOfWorkWithDatabase.ShowDialog();
            TreeOfOperations.Enabled         = true;
            TreeOfSelectedOperations.Enabled = true;
            TypeOfMachining.Enabled          = true;
            ChoiceOfOperation.Enabled        = true;
            Backspace.Enabled           = true;
            CalculationOfSchema.Enabled = true;
            TypeOfInstrument.Enabled    = true;
            addSurfaceButton.Enabled    = true;
            delSurfaceButton.Enabled    = true;
            SurfacesTreeView.Enabled    = true;
        }
        public static void getSurfacesInComboBoxAndTextBoxes(FormOfWorkWithDatabase form, int selectedIndex)
        {
            form.Surfaces.Items.Clear();

            selectSurfaceInDB(form, selectedIndex);

            foreach (DependenceSurface surface in surfaces)
            {
                form.Surfaces.Items.Add(surface.getNameSurface());
            }

            try
            {
                form.Surfaces.SelectedIndex = 0;
            }
            catch { }
        }
Example #17
0
        public static void buttonSelectPartInFormOfWorkWithDatabase(FormOfWorkWithDatabase form, MainForm parrentForm)
        {
            try
            {
                insertParametersOfPart(form, parrentForm);
                Part.insertParametersOfPartInTextboxes(parrentForm);

                insertParametersOfWorkpriece(form);
                Part.insertNameOfWorkpieceInTreeViewAndTextBox(parrentForm);

                insertParametersOfOperations(form);
                Part.insertListOfOperationsInTreeView(parrentForm);

                form.Close();
            }

            catch { MessageBox.Show("Выбранная запись поврежденна", "Ошибка"); }
        }
Example #18
0
 private static void insertParametersOfPart(FormOfWorkWithDatabase form, MainForm parrentForm)
 {
     /* double lengthOfPart = Convert.ToDouble(form.dataGridView1.CurrentRow.Cells[3].Value.ToString());
      * double diameterOfPart = Convert.ToDouble(form.dataGridView1.CurrentRow.Cells[4].Value.ToString());
      *
      * string typeOfPart = form.dataGridView1.CurrentRow.Cells[8].Value.ToString();
      * string typeOfAllowance = form.dataGridView1.CurrentRow.Cells[10].Value.ToString();
      * string typeOfProcessedSurface = form.dataGridView1.CurrentRow.Cells[9].Value.ToString();
      *
      * TypeOfPart indexOfTypeOfPart = selectIndexOfTypesFromComboBox(typeOfPart, parrentForm.TypeOfPart);
      * TypeOfPart indexOfTypeOfAllowance = selectIndexOfTypesFromComboBox(typeOfAllowance, parrentForm.TypeOfAllowance);
      * TypeOfPart indexOfTypeOfProcessedSurface = selectIndexOfTypesFromComboBox(typeOfProcessedSurface, parrentForm.TypeOfProcessedSurface);
      *
      * double allowance = Convert.ToDouble(form.dataGridView1.CurrentRow.Cells[5].Value.ToString());
      * double holeDepth = Convert.ToDouble(form.dataGridView1.CurrentRow.Cells[7].Value.ToString());
      *
      * ParametersOfSurface parametersOfPart = new ParametersOfSurface(lengthOfPart, diameterOfPart, indexOfTypeOfPart, indexOfTypeOfAllowance, indexOfTypeOfProcessedSurface, allowance, holeDepth);
      * Part.setParametersOfPart(parametersOfPart);*/
 }
        public static void getListNamesAndCipherPartsInComboBox(FormOfWorkWithDatabase form)
        {
            selectPartsInDB();
            searchPart = parts;

            form.NamePart.Items.Clear();
            form.CipherPart.Items.Clear();

            foreach (DependencePart part in searchPart)
            {
                form.NamePart.Items.Add(part.getName());
                form.CipherPart.Items.Add(part.getId());
            }

            try
            {
                form.NamePart.SelectedIndex = 0;
            }
            catch { }
        }
        private static void saveSurfaceInPart(FormOfWorkWithDatabase form)
        {
            int countSurface    = surfaces.Count;
            int selectIndexPart = form.NamePart.SelectedIndex;

            double lengtPart = parts[selectIndexPart].getLengthPart();

            for (int i = 0; i < countSurface; i++)
            {
                int numberSurfaceInPart   = i + 1;
                DependenceSurface surface = surfaces[i];

                surface.getParametersOfSurface().setLengthOfPart(lengtPart);

                Part.getSurfaceOnIndex(numberSurfaceInPart).setNameSurface(surface.getNameSurface());
                Part.getSurfaceOnIndex(numberSurfaceInPart).setParametersOfSurface(surfaces[i].getParametersOfSurface());

                saveOperationsInSurface(i);
            }
            ;
        }
        public static void searchByName(FormOfWorkWithDatabase form)
        {
            string searchString = form.SearchByName.Text;

            form.SearchByCipher.Text = "";

            searchPart = new List <DependencePart>();

            foreach (DependencePart part in parts)
            {
                if (part.getName().ToLower().StartsWith(searchString.ToLower()))
                {
                    searchPart.Add(part);
                }
            }

            form.NamePart.Items.Clear();
            form.CipherPart.Items.Clear();

            foreach (DependencePart part in searchPart)
            {
                form.NamePart.Items.Add(part.getName());
                form.CipherPart.Items.Add(part.getId());
            }

            try
            {
                if (form.NamePart.Items.Count != 0)
                {
                    form.NamePart.SelectedIndex = 0;
                }
                else
                {
                    clearForm(form);
                }
            }
            catch { }
        }
        private static void clearForm(FormOfWorkWithDatabase form)
        {
            form.NamePart.Text   = "";
            form.CipherPart.Text = "";

            form.Calculation.Items.Clear();
            form.Calculation.Text = "";

            form.Surfaces.Text = "";
            form.Surfaces.Items.Clear();

            form.TechnologicalProcess.Nodes.Clear();
            form.Operations.Nodes.Clear();

            form.LengthPart.Text             = "";
            form.diameterOfSurface.Text      = "";
            form.typeOfPart.Text             = "";
            form.typeOfAllowance.Text        = "";
            form.TypeOfProcessedSurface.Text = "";
            form.HoleDepth.Text        = "";
            form.SurfaceRoughness.Text = "";
            form.Tolerance.Text        = "";
        }
        private static void selectSurfaceInDB(FormOfWorkWithDatabase form, int index)
        {
            DataTable tablesDataTable = new DataTable();
            DataTable tempDataTable   = new DataTable();

            DependenceCalculation calculation = calculations[index];

            dbConnection.GetDataUsingDataAdapter($@"SELECT * FROM surface WHERE idCalculation = {calculation.getId()}", ref tempDataTable, ref tableDataAdapter);

            surfaces = new List <DependenceSurface>();

            try
            {
                foreach (DataRow row in tempDataTable.Rows)
                {
                    surfaces.Add(createSurface(row, form));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }