Exemplo n.º 1
0
        public void insertNewBron(object sender, EventArgs e)
        {
            using (StrzelnicaEntities strzelnicaEntities = new StrzelnicaEntities())
            {
                BRONIE bron = new BRONIE
                {
                    PRODUCENT         = NBProdText.Text.ToUpper(),
                    MODEL             = NBModText.Text.ToUpper(),
                    TYP               = NBTypGrid.SelectedCells[0].RowIndex,
                    AMUNICJA          = NBAmuGrid.SelectedCells[0].RowIndex,
                    CENA_WYPOZYCZENIA = NBCenaNum.Value
                };

                strzelnicaEntities.BRONIE.Add(bron);
                strzelnicaEntities.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public void editBron(object sender, EventArgs e)
        {
            using (StrzelnicaEntities strz = new StrzelnicaEntities())
            {
                int    id     = (int)EBWybNum.Value;
                BRONIE bronie = strz.BRONIE.Find(id);

                if (EBAmuGrid.SelectedCells[0].RowIndex.Equals(null))
                {
                    bronie.AMUNICJA = EBAmuGrid.SelectedCells[0].RowIndex;
                }

                if (EBProdText.Text != "")
                {
                    bronie.PRODUCENT = EBProdText.Text;
                }

                if (EBModText.Text != "")
                {
                    bronie.MODEL = EBModText.Text;
                }

                if (!EBTypGrid.SelectedCells[0].RowIndex.Equals(null))
                {
                    bronie.TYP = EBTypGrid.SelectedCells[0].RowIndex;
                }

                if (!EBCenaNum.Value.Equals(null))
                {
                    bronie.CENA_WYPOZYCZENIA = EBCenaNum.Value;
                }

                strz.SaveChanges();
                this.Close();
            }
        }