예제 #1
0
        private void PartRmv_Click(object sender, EventArgs e)
        {
            int index = partsDataGridView.SelectedCells.Count > 0 ? partsDataGridView.SelectedCells[0].RowIndex : -1;

            index = index != -1 ? Int32.Parse(partsDataGridView.Rows[index].Cells[0].Value.ToString()) : 0;
            if (index == 0)
            {
                MessageBox.Show("Please select row!", "No record selected?", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            DialogResult result = MessageBox.Show("Сигурни ли сте, че искате да изтриете записа?", "Изтриване?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (PartRepository.IsUsed(index))
                {
                    MessageBox.Show("Частта се използва в карта!", "Използвана част!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    PartRepository.Remove(PartRepository.Get(index));
                    this.getRecords();
                }
            }
        }
예제 #2
0
        public PartForm(int id = 0)
        {
            InitializeComponent();

            numberPictureBox.Visible = false;
            namePictureBox.Visible   = false;
            pricePictureBox.Visible  = false;

            SpareParts part = null;

            if (id != 0)
            {
                this.id = id;
                part    = PartRepository.Get(id);
            }
            if (part != null)
            {
                numberTextBox.Text = part.Number;
                nameTextBox.Text   = part.Name;
                priceTextBox.Text  = part.Price.ToString();
            }
        }