コード例 #1
0
        private void btnZapisz_Click(object sender, EventArgs e)
        {
            WypozyczenieNarzedzia frm = (WypozyczenieNarzedzia)Application.OpenForms["WypozyczenieNarzedzia"];
            int row = Convert.ToInt32(frm.dgvWypozyczenie.CurrentRow.Cells[0].Value);;
            DM_Wypozyczenie_narzedzia toUpdate = this.database.DM_Wypozyczenie_narzedzia.Where(narzedzie => narzedzie.Id_wypozyczenia_narzedzia == row).First();

            toUpdate.Data_i_godzina_zwrotu = Convert.ToDateTime(dateTimePicker2.Value);
            toUpdate.Uwagi = textBox1.Text;

            database.SaveChanges();
            frm.dgvWypozyczenie.DataSource = this.database.vDM_Wypozyczenie_narzedzia.ToList();
            this.Close();
        }
コード例 #2
0
        private void btnZapisz_Click(object sender, EventArgs e)
        {
            WypozyczenieNarzedzia     frm       = (WypozyczenieNarzedzia)Application.OpenForms["WypozyczenieNarzedzia"];
            DM_Wypozyczenie_narzedzia narzedzie = new DM_Wypozyczenie_narzedzia();

            narzedzie.Id_pracownika_wypozyczajacego = Convert.ToInt32(comboBox1.SelectedValue);
            narzedzie.Data_i_godzina_wypozyczenia   = Convert.ToDateTime(dateTimePicker2.Value);
            narzedzie.Data_i_godzina_zwrotu         = Convert.ToDateTime(dateTimePicker2.Value);
            narzedzie.Uwagi = textBox1.Text;
            this.database.DM_Wypozyczenie_narzedzia.Add(narzedzie);
            database.SaveChanges();
            frm.dgvWypozyczenie.DataSource = this.database.vDM_Wypozyczenie_narzedzia.ToList();
            this.Close();
        }
コード例 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            /*int id = Convert.ToInt32(dgvWypozyczenie.CurrentRow.Cells[0].Value);
             * UsunNarzedzieZeSzczegolow usun = new UsunNarzedzieZeSzczegolow(this.database, Decimal.ToInt32(id));
             * usun.ShowDialog();*/
            DialogResult dialogResult = MessageBox.Show("Czy chcesz usunąć narzędzie?", "Usuwanie narzędzia", MessageBoxButtons.YesNo);

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

                DM_Wypozyczenie_narzedzia toRemove = this.database.DM_Wypozyczenie_narzedzia.Where(wypo => wypo.Id_wypozyczenia_narzedzia == id).First();

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

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