예제 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Dostawcy    frm      = (Dostawcy)Application.OpenForms["Dostawcy"];
            int         row      = Convert.ToInt32(frm.dgvDostawca.CurrentRow.Cells[0].Value);;
            DM_Dostawca toUpdate = this.database.DM_Dostawca.Where(dostawce => dostawce.Id_dostawcy == row).First();

            toUpdate.Nazwa = txtNew.Text;
            toUpdate.NIP   = txtNIP.Text;
            toUpdate.Uwagi = txtUwagi.Text;
            database.SaveChanges();
            frm.dgvDostawca.DataSource = this.database.vDM_Dostawca.ToList();
            this.Close();
        }
예제 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DM_Dostawca newsnowy = new DM_Dostawca();

            newsnowy.Nazwa = txtNew.Text;
            newsnowy.NIP   = txtNIP.Text;
            newsnowy.Uwagi = txtUwagi.Text;

            this.database.DM_Dostawca.Add(newsnowy);
            this.database.SaveChanges();
            var MaterialForm = Application.OpenForms.OfType <Dostawcy>().Single();

            MaterialForm.initDataGridView();
            this.Close();
        }
예제 #3
0
        private void buttonUsunKlienta_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Czy chcesz usunąć dostawcę?", "Usuwanie dostawcy", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                int id = Convert.ToInt32(this.dgvDostawca.CurrentRow.Cells[0].Value);

                DM_Dostawca toRemove = this.database.DM_Dostawca.Where(dostawca => dostawca.Id_dostawcy == id).First();

                this.database.DM_Dostawca.Remove(toRemove); // DELETE

                this.database.SaveChanges();
                initDataGridView();
            }
            else
            {
                DialogResult dialog1Result = MessageBox.Show("Nie udało się usunąć narzędzia!");
            }
        }