Exemple #1
0
        private void btnCreateOrEdit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxName.Text) || string.IsNullOrEmpty(tbxValence.Text))
            {
                DialogsManager.ShowError("Not all required fields are filled.");
                return;
            }

            Dopant dopant = new Dopant(0, tbxName.Text, tbxValence.Text);

            string message;

            if (this._currentDopant == null)
            {
                this._dopantRepository.InsertDopant(dopant);
                message = "New dopant was created.";
            }
            else
            {
                this._dopantRepository.UpdateDopantWithId(this._currentDopant.Id, dopant);
                message = "Changes were successfully saved.";
            }

            this.DialogResult = DialogResult.OK;
            DialogsManager.ShowSuccessAndClose(message, this);
        }
        private void DataDeleteButton_Cliked(int currentId)
        {
            // TODO: Realise DataDeleteButton_Cliked() method
            switch (this.tbdropdShowSettings.Text)
            {
            case "Dopants":
                if (DialogsManager.DeletingConfirmation("dopant"))
                {
                    this._dopantRepository.DeleteDopant(currentId);
                    FillDataGridView(null, null);
                }
                break;

            case "Matrixes":
                if (DialogsManager.DeletingConfirmation("matrix"))
                {
                    this._matrixRepository.DeleteMatrixWithId(currentId);
                    FillDataGridView(null, null);
                }
                break;

            case "Compuonds":
                if (DialogsManager.DeletingConfirmation("compound"))
                {
                    // TODO: Realise compound deleting
                    FillDataGridView(null, null);
                }
                break;

            default:
                DialogsManager.ShowError("Wrong settings where to search and what to display is setted");
                break;
            }
        }
        private void DataEditButton_Cliked(int currentId)
        {
            switch (this.tbdropdShowSettings.Text)
            {
            case "Dopants":
                CreateOrEditDopand EditDopantForm = new CreateOrEditDopand(currentId);

                if (EditDopantForm.ShowDialog() == DialogResult.OK)
                {
                    FillDataGridView(null, null);
                }
                break;

            case "Matrixes":
                CreateOrEditMatrix EditMatrixForm = new CreateOrEditMatrix(currentId);

                if (EditMatrixForm.ShowDialog() == DialogResult.OK)
                {
                    FillDataGridView(null, null);
                }
                break;

            case "Compuonds":
                // TODO: Realise compound editing
                break;

            default:
                DialogsManager.ShowError("Wrong settings where to search and what to display is setted");
                break;
            }
        }
        private void FillDataGridView(object sender, EventArgs e)
        {
            this.dgvData.Rows.Clear();
            this.dgvData.Columns.Clear();
            this.dgvData.Visible = true;
            AddButtonColumn("View");

            {
                string name = "";
                if (this.tbtbxSearch.Text != null)
                {
                    name = this.tbtbxSearch.Text;
                }

                switch (this.tbdropdShowSettings.Text)
                {
                case "Dopants":
                    FillWithDopantsWithName(name);
                    break;

                case "Matrixes":
                    FillWithMatrixesWithName(name);
                    break;

                case "Compounds":
                    // TODO: Fill data grid view with compounds must be realised
                    break;

                default:
                    DialogsManager.ShowError("Wrong settings where to search and what to display is setted");
                    break;
                }
            }

            AddButtonColumn("Edit");
            AddButtonColumn("Delete");

            for (int i = 0; i < this.dgvData.RowCount; i++)
            {
                this.dgvData.Rows[i].Cells["View"].Value   = "View";
                this.dgvData.Rows[i].Cells["Edit"].Value   = "Edit";
                this.dgvData.Rows[i].Cells["Delete"].Value = "Delete";
            }

            if (this.dgvData.RowCount == 0)
            {
                this.dgvData.Columns.Clear();
                this.dgvData.Visible = false;
            }
        }
Exemple #5
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxName.Text))
            {
                DialogsManager.ShowError("Field 'Name' must be filled.");
                return;
            }

            double energyGap       = 0;
            double maxPhononEnergy = 0;

            tbxEnergyGap.Text       = tbxEnergyGap.Text.Replace('.', ',');
            tbxMaxPhononEnergy.Text = tbxMaxPhononEnergy.Text.Replace('.', ',');

            if (!string.IsNullOrEmpty(tbxEnergyGap.Text) && !double.TryParse(tbxEnergyGap.Text, out energyGap))
            {
                DialogsManager.ShowError("Value of energy gap was entered incorrectly");
                return;
            }

            if (!string.IsNullOrEmpty(tbxMaxPhononEnergy.Text) && !double.TryParse(tbxMaxPhononEnergy.Text, out maxPhononEnergy))
            {
                DialogsManager.ShowError("Value of maximum phonon energy was entered incorrectly");
                return;
            }

            Matrix matrix = new Matrix(0, tbxName.Text, energyGap, maxPhononEnergy, tbxSymmetry.Text, tbxComment.Text);

            string message;

            if (this._currentMatrix == null)
            {
                _matrixRepository.InsertMatrix(matrix);
                message = "New matrix was created.";
            }
            else
            {
                _matrixRepository.UpdateMatrixWithId(this._currentMatrix.Id, matrix);
                message = "Changes were successfully saved.";
            }

            this.DialogResult = DialogResult.OK;
            DialogsManager.ShowSuccessAndClose(message, this);
        }
        private void DataViewButton_Cliked(int currentId)
        {
            // TODO: Realise DataViewButton_Cliked() method
            switch (this.tbdropdShowSettings.Text)
            {
            case "Dopants":
                break;

            case "Matrixes":
                break;

            case "Compuonds":
                break;

            default:
                DialogsManager.ShowError("Wrong settings where to search and what to display is setted");
                break;
            }
        }