Exemplo n.º 1
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.º 2
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();
        }