private void Button_dodaj_Click(object sender, EventArgs e) { if (id_dokumentu_magazynowego == null) { if (numericUpDown_numerKlienta.Value == 0) { MessageBox.Show("Wprowadź numer klienta.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(textBox_nazwa.Text)) { MessageBox.Show("Wprowadź nazwę kontrahenta.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var dokumentMagazynowy = new DokumentMagazynowy.Model.DokumentMagazynowy() { data = dateTimePicker_data.Value.Date, numer_klienta = (int)numericUpDown_numerKlienta.Value, nazwa = textBox_nazwa.Text }; using (var entity = new TaskDokMagEntities()) { var dokumentMagazynowyController = new DokumentMagazynowyController(entity); id_dokumentu_magazynowego = dokumentMagazynowyController.ZapiszDokumentMagazynowy(dokumentMagazynowy); } } var pozycjaDokumentuMagazynowego_form = new Form_pozycjaDokumentuMagazynowego(id_dokumentu_magazynowego ?? 0, null); if (pozycjaDokumentuMagazynowego_form.ShowDialog() == DialogResult.Yes) { ZaladujDaneNaFormularz(); } }
private void Button_usun_Click(object sender, EventArgs e) { if (dataGridView_dokumentyMagazynowe.SelectedRows.Count != 0) { int idDokumentuMagazynowego = int.Parse(dataGridView_dokumentyMagazynowe["id_dokumentu_magazynowego", dataGridView_dokumentyMagazynowe.SelectedRows[0].Index].Value.ToString()); if (MessageBox.Show("Jesteś pewien?", "Pytanie", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (var entity = new TaskDokMagEntities()) { var dokumentMagazynowyController = new DokumentMagazynowyController(entity); dokumentMagazynowyController.UsunDokumentMagazynowy(idDokumentuMagazynowego); } ZaladujDokumentyMagazynowe(); } } }
private void ZaladujDokumentyMagazynowe() { using (var entity = new TaskDokMagEntities()) { var dokMagazynoweController = new DokumentMagazynowyController(entity); var dokumentyMagazynowe = dokMagazynoweController.pobierzDokumentyMagazynowe(); dataGridView_dokumentyMagazynowe.DataSource = null; dataGridView_dokumentyMagazynowe.DataSource = dokumentyMagazynowe; if (dokumentyMagazynowe.Count() > 0) { button_usun.Enabled = button_edytuj.Enabled = true; } else { button_usun.Enabled = button_edytuj.Enabled = false; } } }
private void Button_edytuj_Click(object sender, EventArgs e) { if (id_dokumentu_magazynowego != null) { if (numericUpDown_numerKlienta.Value == 0) { MessageBox.Show("Wprowadź numer klienta.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(textBox_nazwa.Text)) { MessageBox.Show("Wprowadź nazwę kontrahenta.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var dokumentMagazynowy = new DokumentMagazynowy.Model.DokumentMagazynowy() { data = dateTimePicker_data.Value.Date, numer_klienta = (int)numericUpDown_numerKlienta.Value, nazwa = textBox_nazwa.Text, id_dokumentu_magazynowego = id_dokumentu_magazynowego ?? 0 }; using (var entity = new TaskDokMagEntities()) { var dokumentMagazynowyController = new DokumentMagazynowyController(entity); dokumentMagazynowyController.PoprawDokumentMagazynowy(dokumentMagazynowy); } } if (dataGridView_pozycjeDokumentuMagazynowego.SelectedRows.Count != 0) { int idPozycjiDokumentuMagazynowego = int.Parse(dataGridView_pozycjeDokumentuMagazynowego["id_pozycji_dokumentu_magazynowego", dataGridView_pozycjeDokumentuMagazynowego.SelectedRows[0].Index].Value.ToString()); var pozycjaDokumentuMagazynowego_form = new Form_pozycjaDokumentuMagazynowego(id_dokumentu_magazynowego ?? 0, idPozycjiDokumentuMagazynowego); if (pozycjaDokumentuMagazynowego_form.ShowDialog() == DialogResult.Yes) { ZaladujDaneNaFormularz(); } } }