Exemple #1
0
        private void treeViewCustomerOrders_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            if (isFörfattare)
            {
                Förlag förlag           = null;
                var    userInputBokInfo = new string[5];

                if ((dataGridView.Rows.Count - AmountOfRows) < 1)
                {
                    return;
                }


                for (var j = AmountOfRows; j < dataGridView.Rows.Count; j++)
                {
                    for (var x = 0; x < 5; x++)
                    {
                        if (string.IsNullOrEmpty(dataGridView.Rows[j].Cells[x].Value as string))
                        {
                            break;
                        }


                        userInputBokInfo[x] = dataGridView.Rows[j].Cells[x].Value.ToString();
                    }
                    if (!userInputBokInfo.Contains(null))
                    {
                        förlag = dataGridView.Rows[j].Cells["Förlag"].Value as Förlag;
                        db.Böcker.Add(EntityAdder.AddNyBok(userInputBokInfo));
                        db.SaveChanges();

                        db.FörfattareBöckerFörlags.Add(EntityAdder.AddNyFörfattareBöckerFörlag(userInputBokInfo, förlag, activeFörfattare));
                        db.SaveChanges();
                    }
                }
            }
        }
Exemple #2
0
 public static FörfattareBöckerFörlag AddNyFörfattareBöckerFörlag(string[] userInputBok, Förlag inputFörlag, Författare nyFörfattare)
 {
     return(new FörfattareBöckerFörlag()
     {
         Isbn = userInputBok[0],
         FörfattareId = nyFörfattare.FörfattareId,
         FörlagsId = inputFörlag.FörlagsId
     });
 }