Пример #1
0
        public void loadCellTypes()
        {
            if (sqlWorker == null)
            {
                throw new SQLWorkerException("SQLWorker is equal to null.");
            }

            cellTypes.Clear();
            cellTypes = sqlWorker.GetCellTypes();
        }
Пример #2
0
 public void loadCellTypes(ISQLWorker sqlWorker)
 {
     cellTypes.Clear();
     cellTypes = sqlWorker.GetCellTypes();
 }
Пример #3
0
        //add material or cell
        //comment EMPTY MATERIAL PROPERTIES
        private void btnADAddObj_Click(object sender, EventArgs e)
        {
            if (!IsNull(txtADAddName) && !IsNull(txtADAddDesc))
            {
                if (chooseMaterial.Checked)
                {
                    Material material = new Material();

                    //if (objProperties.Count == 0)
                    //{
                    //    DialogManager.showDialogError("Empty properties");
                    //    return;
                    //}

                    material.Name        = txtADAddName.Text;
                    material.Description = txtADAddDesc.Text;
                    material.Properties  = new List <Property>(objProperties);
                    foreach (Material mat in data.materials)
                    {
                        if (mat.Equals(material))
                        {
                            DialogManager.showDialogError("The material can not be repeated.");
                            return;
                        }
                    }

                    objProperties.Clear();
                    printListProperties(txtADAddProp, objProperties);

                    if (sqlWorker.AddMaterial(material))
                    {
                        loadMaterials();
                    }
                    else
                    {
                        DialogManager.showDialogError("Database Error.");
                    }
                }
                else
                {
                    Cell cell = new Cell();

                    cell.Name        = txtADAddName.Text;
                    cell.Description = txtADAddDesc.Text;

                    //if (objProperties.Count == 0)
                    //{
                    //    DialogManager.showDialogError("Empty properties");
                    //    return;
                    //}

                    cell.Properties = new List <Property>(objProperties);

                    if (!IsNull(cmbADCellTypes))
                    {
                        string txt = cmbADCellTypes.SelectedItem.ToString();
                        cell.CellType = sqlWorker.GetCellTypes().FindLast(x => x.TypeName.Equals(txt));
                    }
                    else
                    {
                        DialogManager.showDialogError("Select Cell Type please.");
                        return;
                    }

                    List <Cell> list = sqlWorker.GetCells();

                    foreach (Cell c in list)
                    {
                        if (c.Name.Equals(cell.Name))
                        {
                            DialogManager.showDialogError("The cell can not be repeated.");
                            return;
                        }
                    }

                    objProperties.Clear();
                    printListProperties(txtADAddProp, objProperties);

                    if (sqlWorker.AddCell(cell))
                    {
                        loadCells();
                    }
                    else
                    {
                        DialogManager.showDialogError("Database Error");
                    }
                }
            }
            else
            {
                DialogManager.showDialogError("Please enter correct information.");
            }
        }