Esempio n. 1
0
        private void buttonAddSparePart_Click(object sender, EventArgs e)
        {
            SpareMapper sm = new SpareMapper();

            if (part == null)
            {
                part = new SparePart(textBoxUniqNumb.Text, float.Parse(textBoxNumb.Text),
                                     double.Parse(textBoxCost.Text), textBoxDescr.Text, Converter.ConvertUnit(comboBoxUnit.Text));
                try
                {
                    sm.Insert(part);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else
            {
                part.Articul     = textBoxUniqNumb.Text;
                part.Description = textBoxDescr.Text;
                part.Number      = float.Parse(textBoxNumb.Text);
                part.Cost        = double.Parse(textBoxCost.Text);
                part.Unit        = Converter.ConvertUnit(comboBoxUnit.Text);
                try
                {
                    sm.Update(part);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            Form1.AddSparePartInStock(mainForm.dataGridView);
            this.Close();
        }