public NotDoneActForm()
        {
            InitializeComponent();

            CommonElements.InitMaterials();
            MatCol.DataSource = CommonElements.Materials;
            MatCol.DisplayMember = "Name";
            MatCol.ValueMember = "ID";

            CommonElements.actions.TryGetValue("add", out add);
            CommonElements.actions.TryGetValue("del", out del);
            CommonElements.actions.TryGetValue("upd", out upd);
        }
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if ((sender as DataGridView).Rows[e.RowIndex].Cells[IDcol.Index].Value == null)
                {
                    (sender as DataGridView)[ActionCol.Index, e.RowIndex].Style.BackColor = add;
                }
                else if ((sender as DataGridView)[ActionCol.Index, e.RowIndex].Style.BackColor != add)
                {
                    (sender as DataGridView)[ActionCol.Index, e.RowIndex].Style.BackColor = upd;
                }

                if (e.ColumnIndex == MatCol.Index)
                {
                    if ((int)(sender as DataGridView)[MatCol.Index, e.RowIndex].Value == -1)
                    {
                        new NewMaterialForm().ShowDialog();
                        CommonElements.InitMaterials();
                    }
                    else
                    {
                        (sender as DataGridView)[measureCol.Index, e.RowIndex].Value =
                            CommonElements.Measures
                                .First(meas => meas.ID
                                        == CommonElements.Materials
                                            .First(mat => mat.ID
                                                == (int)(sender as DataGridView)[MatCol.Index, e.RowIndex].Value).Measure).ShortName;
                    }
                }

                if ((sender as DataGridView)[quantityCol.Index, e.RowIndex].Value == null ||
                            Convert.ToInt32((sender as DataGridView)[quantityCol.Index, e.RowIndex].Value) < 0)
                    (sender as DataGridView)[quantityCol.Index, e.RowIndex].Value = 0;

                if ((sender as DataGridView)[totalCol.Index, e.RowIndex].Value == null ||
                        Convert.ToDouble((sender as DataGridView)[totalCol.Index, e.RowIndex].Value) < 0)
                {
                    (sender as DataGridView)[totalCol.Index, e.RowIndex].Value = 0;
                }
                if (e.ColumnIndex == totalCol.Index)
                    RecountTotal();
            }
        }