Example #1
0
        private void btnStergere_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var IdTipProdus = lb.tipprodus.FirstOrDefault(x => x.TipProdus1.Equals(currentEdit.TipProdus)).IdTipProdus;
                switch (IdTipProdus)
                {
                //Carte
                case 1:
                    var getCarte = lb.carte.Where(x => x.IdCarte.Equals(currentEdit.Id)).FirstOrDefault();
                    lb.carte.Remove(getCarte);
                    lb.SaveChanges();
                    var getProdusCarte = lb.produs.Where(x => x.Produs1 == getCarte.IdCarte && x.IdTipProdus == IdTipProdus).FirstOrDefault();
                    lb.produs.Remove(getProdusCarte);
                    lb.SaveChanges();
                    break;

                //Birotica
                case 2:
                    var getBirotica = lb.birotica.Where(x => x.IdBirotica.Equals(currentEdit.Id)).FirstOrDefault();
                    lb.birotica.Remove(getBirotica);
                    lb.SaveChanges();
                    var getProdusBirotica = lb.produs.Where(x => x.Produs1 == getBirotica.IdBirotica && x.IdTipProdus == IdTipProdus).FirstOrDefault();
                    lb.produs.Remove(getProdusBirotica);
                    lb.SaveChanges();
                    break;
                }
                UpdateGrid("Sterge");
            }
        }
Example #2
0
        private void btnModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var IdTipProdus = lb.tipprodus.FirstOrDefault(x => x.TipProdus1.Equals(currentEdit.TipProdus)).IdTipProdus;
                switch (IdTipProdus)
                {
                //Carte
                case 1:
                    var getCarte = lb.carte.Where(x => x.IdCarte.Equals(currentEdit.Id)).FirstOrDefault();
                    getCarte.ISBN      = currentEdit.ISBN;
                    getCarte.Titlu     = currentEdit.Titlu;
                    getCarte.Descriere = currentEdit.Descriere;
                    getCarte.IdEditura = lb.editura.FirstOrDefault(x => x.Nume.Equals(currentEdit.Editura)).IdEditura;
                    getCarte.An        = (int)currentEdit.An;
                    getCarte.NrPagini  = (int)currentEdit.NrPagini;
                    getCarte.Locatie   = currentEdit.Locatie;
                    getCarte.IdAutor   = lb.autor.FirstOrDefault(x => x.Nume.Equals(currentEdit.Autor)).IdAutor;
                    getCarte.IdDomeniu = lb.domeniu.FirstOrDefault(x => x.Domeniu1.Equals(currentEdit.Domeniu)).IdDomeniu;
                    lb.SaveChanges();
                    var getProdusCarte = lb.produs.Where(x => x.Produs1 == getCarte.IdCarte && x.IdTipProdus == IdTipProdus).FirstOrDefault();
                    getProdusCarte.Pret      = (double)currentEdit.Pret;
                    getProdusCarte.Cantitate = (int)currentEdit.Cantitate;
                    lb.SaveChanges();
                    break;

                //Birotica
                case 2:
                    var getBirotica = lb.birotica.Where(x => x.IdBirotica.Equals(currentEdit.Id)).FirstOrDefault();
                    getBirotica.Denumire  = currentEdit.Titlu;
                    getBirotica.Descriere = currentEdit.Descriere;
                    //lb.SaveChanges();
                    var getProdusBirotica = lb.produs.Where(x => x.Produs1 == getBirotica.IdBirotica && x.IdTipProdus == IdTipProdus).FirstOrDefault();
                    getProdusBirotica.Pret      = (double)currentEdit.Pret;
                    getProdusBirotica.Cantitate = (int)currentEdit.Cantitate;
                    lb.SaveChanges();
                    break;
                }
                UpdateGrid("Modifica");
            }
        }
Example #3
0
        private void btnOfertaStergere_Click(object sender, EventArgs e)
        {
            var          currentEdit  = GetEditOfertaItem();
            DialogResult dialogResult = MessageBox.Show("ATENTIE!\r\nEsti sigur ca vrei sa stergi aceasta oferta?\r\nVei sterge si toate detaliile pe produse la oferta!", "Sterge Oferta", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                using (LabDataContext lb = new LabDataContext())
                {
                    var liniiOferta = lb.linieoferta.Where(x => x.IdOferta == currentEdit.Id).ToList();
                    lb.linieoferta.RemoveRange(liniiOferta);
                    lb.SaveChanges();
                    var oferta = lb.oferta.FirstOrDefault(x => x.IdOferta == currentEdit.Id);
                    lb.oferta.Remove(oferta);
                    lb.SaveChanges();

                    UpdateOfertaGrid("");
                }
            }
        }
Example #4
0
        private void btnAchizitieStergere_Click(object sender, EventArgs e)
        {
            var          currentEdit  = GetEditAchizitieItem();
            DialogResult dialogResult = MessageBox.Show("ATENTIE!\r\nEsti sigur ca vrei sa stergi aceasta achizitie?\r\nVei sterge si toate detaliile pe produse la achizitie!", "Sterge achizitia", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                using (LabDataContext lb = new LabDataContext())
                {
                    var liniiAchizitii = lb.linieachizitie.Where(x => x.IdAchizitie == currentEdit.Id).ToList();
                    lb.linieachizitie.RemoveRange(liniiAchizitii);
                    lb.SaveChanges();
                    var achizitie = lb.achizitie.FirstOrDefault(x => x.IdAchizitie == currentEdit.Id);
                    lb.achizitie.Remove(achizitie);
                    lb.SaveChanges();

                    UpdateAchizitieGrid("");
                }
            }
        }
Example #5
0
        private void btnModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var editura = lb.editura.FirstOrDefault(x => x.IdEditura == currentEdit.Id);
                editura.Nume = currentEdit.Nume;
                lb.SaveChanges();
                UpdateGrid("Modifica");
            }
        }
Example #6
0
        private void btnStergere_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var client = lb.client.FirstOrDefault(x => x.IdClient == currentEdit.Id);
                lb.client.Remove(client);
                lb.SaveChanges();
                UpdateGrid("Sterge");
            }
        }
Example #7
0
        private void btnProdusStergere_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditLinieAchizitieItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var linieachizitie = lb.linieachizitie.FirstOrDefault(x => x.IdAchizitie == currentEdit.IdAchizitie && x.IdProdus == currentEdit.IdProdus);
                lb.linieachizitie.Remove(linieachizitie);
                lb.SaveChanges();
                UpdateLinieAchizitieGrid("Sterge");
            }
        }
Example #8
0
        private void btnModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var domeniu = lb.domeniu.FirstOrDefault(x => x.IdDomeniu == currentEdit.Id);
                domeniu.Domeniu1 = currentEdit.Domeniu;
                lb.SaveChanges();
                UpdateGrid("Modifica");
            }
        }
Example #9
0
        private void btnProdusStergere_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditLinieOfertaItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var linieoferta = lb.linieoferta.FirstOrDefault(x => x.IdOferta == currentEdit.IdOferta && x.IdProdus == currentEdit.IdProdus);
                lb.linieoferta.Remove(linieoferta);
                lb.SaveChanges();
                UpdateOfertaGrid("Sterge");
            }
        }
Example #10
0
        private void btnOfertaModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditOfertaItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var oferta = lb.oferta.FirstOrDefault(x => x.IdOferta == currentEdit.Id);
                oferta.DataExpirare = currentEdit.DataExpirare;
                oferta.IdFurnizor   = currentEdit.Furnizor;

                lb.SaveChanges();
                UpdateOfertaGrid("Modifica");
            }
        }
Example #11
0
        private void btnProdusModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditLinieOfertaItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var linieoferta = lb.linieoferta.FirstOrDefault(x => x.IdOferta == currentEdit.IdOferta && x.IdProdus == currentEdit.IdProdus);
                linieoferta.IdProdus     = currentEdit.IdProdus;
                linieoferta.PretFurnizor = currentEdit.PretFurnizor;
                linieoferta.Cantitate    = currentEdit.Cantitate;

                lb.SaveChanges();
                UpdateLinieOfertaGrid("Modifica");
            }
        }
Example #12
0
        private void btnProdusModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditLinieAchizitieItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var linieachizitie = lb.linieachizitie.FirstOrDefault(x => x.IdAchizitie == currentEdit.IdAchizitie && x.IdProdus == currentEdit.IdProdus);
                linieachizitie.IdProdus  = currentEdit.IdProdus;
                linieachizitie.Pret      = currentEdit.Pret;
                linieachizitie.Cantitate = currentEdit.Cantitate;

                lb.SaveChanges();
                UpdateLinieAchizitieGrid("Modifica");
            }
        }
Example #13
0
        private void btnModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var client = lb.client.FirstOrDefault(x => x.IdClient == currentEdit.Id);
                client.Nume   = currentEdit.Nume;
                client.Varsta = (int)currentEdit.Varsta;
                client.Sex    = currentEdit.Sex;
                client.Email  = currentEdit.Email;
                lb.SaveChanges();
                UpdateGrid("Modifica");
            }
        }
Example #14
0
        private void btnModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var furnizor = lb.furnizor.FirstOrDefault(x => x.IdFurnizor == currentEdit.Id);
                furnizor.Nume    = currentEdit.Nume;
                furnizor.CUI     = currentEdit.CUI;
                furnizor.Sold    = (double)currentEdit.Sold;
                furnizor.Email   = currentEdit.Email;
                furnizor.Telefon = currentEdit.Telefon;
                lb.SaveChanges();
                UpdateGrid("Modifica");
            }
        }
Example #15
0
        private void btnOfertaAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditOfertaItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var newOferta = new oferta()
                {
                    IdFurnizor   = currentEdit.Furnizor,
                    DataExpirare = currentEdit.DataExpirare
                };
                lb.oferta.Add(newOferta);
                lb.SaveChanges();
                UpdateOfertaGrid("Adauga");
            }
        }
Example #16
0
        private void btnAchizitieModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditAchizitieItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var achizitie = lb.achizitie.FirstOrDefault(x => x.IdAchizitie == currentEdit.Id);
                achizitie.Data          = currentEdit.Data;
                achizitie.IdFurnizor    = currentEdit.Furnizor;
                achizitie.SerieDocument = currentEdit.SerieDocument;
                achizitie.NrDocument    = currentEdit.NrDocument;

                lb.SaveChanges();
                UpdateAchizitieGrid("Modifica");
            }
        }
Example #17
0
        private void btnStergere_Click(object sender, EventArgs e)
        {
            var          currentEdit  = GetEditItem();
            DialogResult dialogResult = MessageBox.Show("ATENTIE!\r\nEsti sigur ca vrei sa stergi aceasta plata?", "Sterge Plata", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                using (LabDataContext lb = new LabDataContext())
                {
                    var plata = lb.plata.FirstOrDefault(x => x.IdPlata == currentEdit.Id);
                    lb.plata.Remove(plata);
                    lb.SaveChanges();
                    UpdateGrid("Sterge");
                }
            }
        }
Example #18
0
        private void btnModifica_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var plata = lb.plata.FirstOrDefault(x => x.IdPlata == currentEdit.Id);

                plata.Data          = currentEdit.Data;
                plata.IdFurnizor    = currentEdit.Furnizor;
                plata.SerieDocument = currentEdit.SerieDocument;
                plata.NrDocument    = currentEdit.NrDocument;
                plata.Suma          = currentEdit.Suma;

                lb.SaveChanges();
                UpdateGrid("Modifica");
            }
        }
Example #19
0
        private void btnProdusAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditLinieOfertaItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var newLinieOferta = new linieoferta()
                {
                    IdOferta     = currentEdit.IdOferta,
                    IdProdus     = currentEdit.IdProdus,
                    PretFurnizor = currentEdit.PretFurnizor,
                    Cantitate    = currentEdit.Cantitate
                };
                lb.linieoferta.Add(newLinieOferta);
                lb.SaveChanges();
                UpdateLinieOfertaGrid("Adauga");
            }
        }
Example #20
0
        private void btnAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var newClient = new client()
                {
                    Nume   = currentEdit.Nume,
                    Varsta = (int)currentEdit.Varsta,
                    Sex    = currentEdit.Sex,
                    Email  = currentEdit.Email
                };
                lb.client.Add(newClient);
                lb.SaveChanges();
                UpdateGrid("Adauga");
            }
        }
Example #21
0
        private void btnProdusAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditLinieAchizitieItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var newLinieAchizitie = new linieachizitie()
                {
                    IdAchizitie = currentEdit.IdAchizitie,
                    IdProdus    = currentEdit.IdProdus,
                    Pret        = currentEdit.Pret,
                    Cantitate   = currentEdit.Cantitate
                };
                lb.linieachizitie.Add(newLinieAchizitie);
                lb.SaveChanges();
                UpdateLinieAchizitieGrid("Adauga");
            }
        }
Example #22
0
        private void btnAchizitieAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditAchizitieItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var newAchizitie = new achizitie()
                {
                    IdFurnizor    = currentEdit.Furnizor,
                    Data          = currentEdit.Data,
                    SerieDocument = currentEdit.SerieDocument,
                    NrDocument    = currentEdit.NrDocument
                };
                lb.achizitie.Add(newAchizitie);
                lb.SaveChanges();
                UpdateAchizitieGrid("Adauga");
            }
        }
Example #23
0
        private void btnStergere_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                if (lb.carte.Any(x => x.IdEditura == currentEdit.Id))
                {
                    MessageBox.Show("Editura nu poate fi stearsa.\r\nExista carti care folosesc aceasta editura.");
                }
                else
                {
                    var editura = lb.editura.FirstOrDefault(x => x.IdEditura == currentEdit.Id);
                    lb.editura.Remove(editura);
                    lb.SaveChanges();
                    UpdateGrid("Sterge");
                }
            }
        }
Example #24
0
        private void btnStergere_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                if (lb.carte.Any(x => x.IdAutor == currentEdit.Id))
                {
                    MessageBox.Show("Domeniul nu poate fi sters.\r\nExista carti care folosesc acest domeniu.");
                }
                else
                {
                    var domeniu = lb.domeniu.FirstOrDefault(x => x.IdDomeniu == currentEdit.Id);
                    lb.domeniu.Remove(domeniu);
                    lb.SaveChanges();
                    UpdateGrid("Sterge");
                }
            }
        }
Example #25
0
        private void btnAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var newFurnizor = new furnizor()
                {
                    Nume    = currentEdit.Nume,
                    CUI     = currentEdit.CUI,
                    Sold    = (double)currentEdit.Sold,
                    Email   = currentEdit.Email,
                    Telefon = currentEdit.Telefon
                };
                lb.furnizor.Add(newFurnizor);
                lb.SaveChanges();
                UpdateGrid("Adauga");
            }
        }
Example #26
0
        private void btnStergere_Click(object sender, EventArgs e)
        {
            var          currentEdit  = GetEditItem();
            DialogResult dialogResult = MessageBox.Show("ATENTIE!\r\nDaca stergi acest furnizor vei sterge si toate tranzactiile legate de furnizor\r\nVrei sa continui?", "StergeFurnizor", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                using (LabDataContext lb = new LabDataContext())
                {
                    var furnizor = lb.furnizor.FirstOrDefault(x => x.IdFurnizor == currentEdit.Id);
                    lb.furnizor.Remove(furnizor);
                    lb.SaveChanges();
                    UpdateGrid("Sterge");
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                UpdateGrid("");
            }
        }
Example #27
0
        private void btnAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                var newPlata = new plata()
                {
                    Data          = currentEdit.Data,
                    IdAchizitie   = IdAchizitieSelected,
                    IdFurnizor    = currentEdit.Furnizor,
                    SerieDocument = currentEdit.SerieDocument,
                    NrDocument    = currentEdit.NrDocument,
                    Suma          = currentEdit.Suma
                };
                lb.plata.Add(newPlata);
                lb.SaveChanges();
                UpdateGrid("Adauga");
            }
        }
Example #28
0
        private void btnAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                if (lb.editura.Any(x => x.Nume.Equals(currentEdit.Nume, StringComparison.OrdinalIgnoreCase)))
                {
                    MessageBox.Show("Exista deja editura cu acest nume.");
                }
                else
                {
                    var newEditura = new editura()
                    {
                        Nume = currentEdit.Nume,
                    };
                    lb.editura.Add(newEditura);
                    lb.SaveChanges();
                    UpdateGrid("Adauga");
                }
            }
        }
Example #29
0
        private void btnAdaugare_Click(object sender, EventArgs e)
        {
            var currentEdit = GetEditItem();

            using (LabDataContext lb = new LabDataContext())
            {
                if (lb.domeniu.Any(x => x.Domeniu1.Equals(currentEdit.Domeniu, StringComparison.OrdinalIgnoreCase)))
                {
                    MessageBox.Show("Exista deja domeniu cu acest nume.");
                }
                else
                {
                    var newDomeniu = new domeniu()
                    {
                        Domeniu1 = currentEdit.Domeniu,
                    };
                    lb.domeniu.Add(newDomeniu);
                    lb.SaveChanges();
                    UpdateGrid("Adauga");
                }
            }
        }
Example #30
0
 public void Adicionar(TEntity entity)
 {
     LabDataContext.Set <TEntity>().Add(entity);
     LabDataContext.SaveChanges();
 }