Exemplo n.º 1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3) {

                try
                {
                foreach (DataGridViewRow row in dataGridView2.Rows)
                {
                    if (((Egzemplarz)row.Cells["Egzemplarz"].Value).IdEgzemplarza == (int)dataGridView1.Rows[e.RowIndex].Cells["IdEgzemplarza"].Value)
                        return;
                }
                    using (var db = new KsiegarniaEntities())
                    {
                        Egzemplarz egzemplarz = ((Egzemplarz)egzemplarzBindingSource[0]);
                         var oferta = new OfertaOferenta
                        {
                            CenaHurtowa = 11 ,
                            Egzemplarz_IdEgzemplarza =(int)dataGridView1.Rows[e.RowIndex].Cells["IdEgzemplarza"].Value,
                            Oferent_IdOferenta = db.Oferents.First().IdOferenta
                        };

                        db.OfertaOferentas.Add(oferta);
                        db.SaveChanges();
                        reload(sender, e);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            }
        }
Exemplo n.º 2
0
        private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
            {
                try
                {
                    if (!DesignMode)
                    {
                        using (var db = new KsiegarniaEntities())
                        {
                            int tmp = Convert.ToInt32(dataGridView3.Rows[e.RowIndex].Cells["idEgzemplarzaDataGridViewTextBoxColumn1"].Value);

                            foreach (DataGridViewRow row in dataGridView2.Rows)
                            {
                                try
                                {
                                    if (((int)(row.Cells["idEgzemplarzaDataGridViewTextBoxColumn"]).Value) == tmp)
                                    {
                                        return;
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }


                            var element = new ElementyZamowienia
                            {
                                IdEgzemplarza = Convert.ToInt32(dataGridView3.Rows[e.RowIndex].Cells["idEgzemplarzaDataGridViewTextBoxColumn1"].Value),
                                IdZamowienia  = nrZamowienia,
                                Ilosc         = 1
                            };

                            db.ElementyZamowienias.Add(element);
                            db.SaveChanges();
                            zaladujElementyZamowienia();

                            potwierdzButton.Visible = true;
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            }
        }
Exemplo n.º 3
0
        private void StworzKontoKlientaButton_Click(object sender, EventArgs e)
        {
            using (var db = new KsiegarniaEntities())
            {
                try
                {
                    var klienci = from b in db.Klients
                                  where b.Login.Equals(KlientLoginTextBox.Text)
                                  select b;


                    if (klienci.Count() > 0)
                    {
                        MessageBox.Show("login jest juz zajety");
                        return;
                    }
                    if (KlientHasloTextBox.Text == "")
                    {
                        MessageBox.Show("Musisz podac jakies haslo");
                        return;
                    }
                    if (KlientLoginTextBox.Text == "")
                    {
                        MessageBox.Show("Musisz podac jakis login");
                        return;
                    }

                    var klient = new Klient
                    {
                        Email    = KlientEmailTextBox.Text,
                        Haslo    = KlientHasloTextBox.Text,
                        Imie     = KlientImieTextBox.Text,
                        Nazwisko = KlientNazwiskoTextBox.Text,
                        Login    = KlientLoginTextBox.Text
                    };
                    db.Klients.Add(klient);
                    db.SaveChanges();
                    MessageBox.Show("Poprawnie zarejestrowano, możesz teraz się zalogować");
                    return;
                }
                catch (Exception)
                {
                    MessageBox.Show("Wystąpił nieznany błąd");
                    return;
                }
            }
        }
Exemplo n.º 4
0
        private void StworzKontoKlientaButton_Click(object sender, EventArgs e)
        {
            using (var db = new KsiegarniaEntities())
            {
                try
                {
                    var klienci = from b in db.Klients
                                  where b.Login.Equals(KlientLoginTextBox.Text)
                                  select b;

                    if (klienci.Count() > 0)
                    {
                        MessageBox.Show("login jest juz zajety");
                        return;
                    }
                    if (KlientHasloTextBox.Text == "")
                    {
                        MessageBox.Show("Musisz podac jakies haslo");
                        return;
                    }
                    if (KlientLoginTextBox.Text == "")
                    {
                        MessageBox.Show("Musisz podac jakis login");
                        return;
                    }

                    var klient = new Klient
                    {
                        Email = KlientEmailTextBox.Text,
                        Haslo = KlientHasloTextBox.Text,
                        Imie = KlientImieTextBox.Text,
                        Nazwisko = KlientNazwiskoTextBox.Text,
                        Login = KlientLoginTextBox.Text
                    };
                    db.Klients.Add(klient);
                    db.SaveChanges();
                    MessageBox.Show("Poprawnie zarejestrowano, możesz teraz się zalogować");
                    return;
                }
                catch (Exception)
                {
                    MessageBox.Show("Wystąpił nieznany błąd");
                    return ;
                }
            }
        }
Exemplo n.º 5
0
        private void StworzKontoOferentaButton_Click(object sender, EventArgs e)
        {
            using (var db = new KsiegarniaEntities())
            {
                try
                {
                    var oferenci = from b in db.Oferents
                                   where b.Login.Equals(OferentLoginTextBox.Text)
                                   select b;


                    if (oferenci.Count() > 0)
                    {
                        MessageBox.Show("login jest juz zajety");
                        return;
                    }
                    if (OferentHasloTextBox.Text == "")
                    {
                        MessageBox.Show("Musisz podac jakies haslo");
                        return;
                    }
                    if (OferentLoginTextBox.Text == "")
                    {
                        MessageBox.Show("Musisz podac jakis login");
                        return;
                    }

                    var oferent = new Oferent
                    {
                        NazwaFirmy = OferentNazwaTextBox.Text,
                        Adres      = OferentAdresTextBox.Text,
                        Login      = OferentLoginTextBox.Text,
                        Haslo      = OferentHasloTextBox.Text,
                    };
                    db.Oferents.Add(oferent);
                    db.SaveChanges();
                    MessageBox.Show("Poprawnie zarejestrowano, możesz teraz się zalogować");
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            }
        }
Exemplo n.º 6
0
        private void StworzKontoOferentaButton_Click(object sender, EventArgs e)
        {
            using (var db = new KsiegarniaEntities())
            {
                try
                {
                    var oferenci = from b in db.Oferents
                                  where b.Login.Equals(OferentLoginTextBox.Text)
                                  select b;

                    if (oferenci.Count() > 0)
                    {
                        MessageBox.Show("login jest juz zajety");
                        return;
                    }
                    if (OferentHasloTextBox.Text == "")
                    {
                        MessageBox.Show("Musisz podac jakies haslo");
                        return;
                    }
                    if (OferentLoginTextBox.Text == "")
                    {
                        MessageBox.Show("Musisz podac jakis login");
                        return;
                    }

                    var oferent = new Oferent
                    {
                        NazwaFirmy = OferentNazwaTextBox.Text,
                        Adres = OferentAdresTextBox.Text,
                        Login = OferentLoginTextBox.Text,
                        Haslo = OferentHasloTextBox.Text,
                    };
                    db.Oferents.Add(oferent);
                    db.SaveChanges();
                    MessageBox.Show("Poprawnie zarejestrowano, możesz teraz się zalogować");
                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(""+ex);
                    return ;
                }
            }
        }
Exemplo n.º 7
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                try
                {
                    Funkcje.Instance._context.ElementyDostawies.Load();
                    elementyDostawyBindingSource.DataSource = Funkcje.Instance._context.ElementyDostawies.Local.ToBindingList().Where(n => (n.IdDostawy == (Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["idDostawyDataGridViewTextBoxColumn"].Value))));
                    DajNazwy();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            }
            if (e.ColumnIndex == 2)
            {
                try
                {
                    using (var db = new KsiegarniaEntities())
                    {
                        var reklamacja = new Reklamacja
                        {
                            Typ = false,
                            RealizacjeReklamacji_IdRealizacji = db.RealizacjeReklamacjis.FirstOrDefault().IdRealizacji,
                            IdTypu = (Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["idDostawyDataGridViewTextBoxColumn"].Value)),
                        };

                        db.Reklamacjas.Add(reklamacja);
                        db.SaveChanges();
                        MessageBox.Show("Utworzono reklamacje");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            }
        }
Exemplo n.º 8
0
        private void dodajDostaweButton_Click(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                using (var db = new KsiegarniaEntities())
                {
                    var dostawa = new Dostawa
                    {
                        Oferent_IdOferenta     = (Funkcje.Instance._context.Oferents.ToList()[(int)(comboBox1.SelectedValue) - 1].IdOferenta),
                        Pracownik_IdPracownika = Funkcje.Instance.pracownik.IdPracownika,
                        Status = false
                    };

                    db.Dostawas.Add(dostawa);
                    db.SaveChanges();
                    DostawaControl_Load(sender, e);
                    return;
                }
            }
        }
Exemplo n.º 9
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
                try
                {

                    Funkcje.Instance._context.ElementyDostawies.Load();
                    elementyDostawyBindingSource.DataSource = Funkcje.Instance._context.ElementyDostawies.Local.ToBindingList().Where(n => (n.IdDostawy ==(Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["idDostawyDataGridViewTextBoxColumn"].Value))));
                    DajNazwy();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            if (e.ColumnIndex == 2)
                try
                {

                    using (var db = new KsiegarniaEntities())
                    {
                        var reklamacja = new Reklamacja
                        {
                            Typ=false,
                            RealizacjeReklamacji_IdRealizacji = db.RealizacjeReklamacjis.FirstOrDefault().IdRealizacji,
                            IdTypu = (Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["idDostawyDataGridViewTextBoxColumn"].Value)),
                        };

                        db.Reklamacjas.Add(reklamacja);
                        db.SaveChanges();
                        MessageBox.Show("Utworzono reklamacje");
                        return;
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
        }
Exemplo n.º 10
0
        private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
            {
                try
                {
                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        if (Convert.ToInt32(dataGridView3.Rows[e.RowIndex].Cells["egzemplarzIdEgzemplarzaDataGridViewTextBoxColumn"].Value) == Convert.ToInt32(row.Cells["idEgzemplarzaDataGridViewTextBoxColumn"].Value))
                        {
                            return;
                        }
                    }

                    using (var db = new KsiegarniaEntities())
                    {
                        var oferta = new ElementyDostawy
                        {
                            IdDostawy     = iddostawy,
                            IdEgzemplarza = (int)dataGridView3.Rows[e.RowIndex].Cells["egzemplarzIdEgzemplarzaDataGridViewTextBoxColumn"].Value,
                            Ilosc         = 0
                        };

                        db.ElementyDostawies.Add(oferta);
                        db.SaveChanges();
                        zaladujElementyDostawy();
                        DajNazwy();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            }
            DajNazwy();
        }
Exemplo n.º 11
0
        private void zatwierdzButton_Click(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                using (var db = new KsiegarniaEntities())
                {
                    var zamow = new Zamowieny
                    {
                        KosztZamowienia                   = 0,
                        Klient_IdKlienta                  = Funkcje.Instance.klient.IdKlienta,
                        Pracownik_IdPracownika            = Funkcje.Instance._context.Pracowniks.FirstOrDefault().IdPracownika,
                        Rabat_IdRabatu                    = Funkcje.Instance._context.Rabats.FirstOrDefault().IdRabatu,
                        RealizacjaZamowienia_IdRealizacji = Funkcje.Instance._context.RealizacjaZamowienias.FirstOrDefault().IdRealizacji,
                        RodzajuWysylki_IdRodzajWysylki    = (Funkcje.Instance._context.RodzajWysylkis.ToList()[(int)(comboBox1.SelectedValue) - 1].IdRodzajWysylki)
                    };

                    db.Zamowienies.Add(zamow);
                    db.SaveChanges();
                    KlientZamowControl_Load(sender, e);
                    return;
                }
            }
        }
Exemplo n.º 12
0
        private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                try
                {
                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        if (Convert.ToInt32(dataGridView3.Rows[e.RowIndex].Cells["idAutoraDataGridViewTextBoxColumn"].Value) == Convert.ToInt32(row.Cells["autorIdAutoraDataGridViewTextBoxColumn"].Value))
                        {
                            return;
                        }
                    }

                    using (var db = new KsiegarniaEntities())
                    {
                        var autorKsiazki = new AutorzyKsiazki
                        {
                            Autor_IdAutora      = Convert.ToInt32(dataGridView3.Rows[e.RowIndex].Cells["idAutoraDataGridViewTextBoxColumn"].Value),
                            IdKsiazka_IdKsiazki = idKsiazki
                        };

                        db.AutorzyKsiazkis.Add(autorKsiazki);
                        db.SaveChanges();
                        zaladujAutorow();
                        DajNazwy();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            }
            DajNazwy();
        }
Exemplo n.º 13
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3)
            {
                try
                {
                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        if (((Egzemplarz)row.Cells["Egzemplarz"].Value).IdEgzemplarza == (int)dataGridView1.Rows[e.RowIndex].Cells["IdEgzemplarza"].Value)
                        {
                            return;
                        }
                    }
                    using (var db = new KsiegarniaEntities())
                    {
                        Egzemplarz egzemplarz = ((Egzemplarz)egzemplarzBindingSource[0]);
                        var        oferta     = new OfertaOferenta
                        {
                            CenaHurtowa = 11,
                            Egzemplarz_IdEgzemplarza = (int)dataGridView1.Rows[e.RowIndex].Cells["IdEgzemplarza"].Value,
                            Oferent_IdOferenta       = db.Oferents.First().IdOferenta
                        };

                        db.OfertaOferentas.Add(oferta);
                        db.SaveChanges();
                        reload(sender, e);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            }
        }
Exemplo n.º 14
0
        private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
                try
                {
                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        if (Convert.ToInt32(dataGridView3.Rows[e.RowIndex].Cells["egzemplarzIdEgzemplarzaDataGridViewTextBoxColumn"].Value) == Convert.ToInt32(row.Cells["idEgzemplarzaDataGridViewTextBoxColumn"].Value))
                            return;

                    }

                    using (var db = new KsiegarniaEntities())
                    {
                        var oferta = new ElementyDostawy
                        {
                            IdDostawy = iddostawy,
                            IdEgzemplarza = (int)dataGridView3.Rows[e.RowIndex].Cells["egzemplarzIdEgzemplarzaDataGridViewTextBoxColumn"].Value,
                            Ilosc = 0
                        };

                        db.ElementyDostawies.Add(oferta);
                        db.SaveChanges();
                        zaladujElementyDostawy();
                        DajNazwy();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                    return;
                }
            DajNazwy();
        }
Exemplo n.º 15
0
        private void dodajDostaweButton_Click(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                using (var db = new KsiegarniaEntities())
                {
                    var dostawa = new Dostawa
                    {
                        Oferent_IdOferenta = (Funkcje.Instance._context.Oferents.ToList()[(int)(comboBox1.SelectedValue) - 1].IdOferenta),
                        Pracownik_IdPracownika = Funkcje.Instance.pracownik.IdPracownika,
                        Status = false
                    };

                    db.Dostawas.Add(dostawa);
                    db.SaveChanges();
                    DostawaControl_Load(sender, e);
                    return;
                }
            }
        }