Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: Saving objects with Cross-reference Pin
Bernhard Hiller7-May-13 22:56
Bernhard Hiller7-May-13 22:56 
GeneralRe: Saving objects with Cross-reference Pin
larsp7778-May-13 2:24
larsp7778-May-13 2:24 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen8-May-13 6:53
professionalEddy Vluggen8-May-13 6:53 
GeneralRe: Saving objects with Cross-reference Pin
larsp7779-May-13 20:19
larsp7779-May-13 20:19 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 9:40
professionalEddy Vluggen11-May-13 9:40 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 10:57
larsp77711-May-13 10:57 
AnswerRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 11:02
professionalEddy Vluggen11-May-13 11:02 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 11:12
larsp77711-May-13 11:12 
Eddy Vluggen wrote:
dunno, and this is the place where things get complicated.
 
Let's
say I borrowed Pratchetts' book "Small Gods". You have three books of this story
- how are you gonna track each book you lent?
 
Answer; give every
book a unique number (yeah, like a GUID) Smile | :)


Yes, but as I said it's a controlled environment where I make sure that there is only one copy of each book.

The question is if this actually is the reason to why it doesn´t work? Or could it be that the list I am trying to save is a empty list even if I use the same name?

This is the event for the button where I register the loan.

C#
private void btnRegister_Click(object sender, EventArgs e)
        {
             Kund lender = null;
             Bok bookToLend = null;
                                     
            //Search for chosen customer
            foreach (Kund K in CustomerList)
            {
                //Om rätt kund hittas
                if (txtPersonNr.Text.Equals(K.PersonNr.ToString()))
                    lender = K; //Kunden som hittats läggs i ny variabel.
            }
            
            //If customer wasn't found.
            if (lender == null)
            {
                textBox7.Text = "Kund saknas!";
                return;
            }

            //Search for chosen book.
            foreach (Bok B in BookList)
            {
                //Om rätt bok hittas
                if (textBox6.Text.Equals(B.ISBN.ToString()))
                    bookToLend = B;
            }

            //if book wasn´t found.
            if (bookToLend == null)
            {
                textBox7.Text = "Bok saknas!";
                return;
            }

                                 

            if (bookToLend.BiblioteksKund == null) //If book doesn´t have its customer object set.
            {
                bookToLend.BiblioteksKund = lender; //Sets the customerobject of the book.

                lender.Loan.Add(bookToLend);    //Places the book to lend in the customers booklist.

                textBox7.Text = "Lån registrerat!";
            }

           


            
        }

GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 22:08
professionalEddy Vluggen11-May-13 22:08 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 22:18
larsp77711-May-13 22:18 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 22:36
professionalEddy Vluggen11-May-13 22:36 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 22:59
larsp77711-May-13 22:59 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 23:17
professionalEddy Vluggen11-May-13 23:17 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 23:21
larsp77711-May-13 23:21 
QuestionRe: Saving objects with Cross-reference Pin
Eddy Vluggen12-May-13 1:10
professionalEddy Vluggen12-May-13 1:10 
AnswerRe: Saving objects with Cross-reference Pin
larsp77712-May-13 2:09
larsp77712-May-13 2:09 
AnswerRe: Saving objects with Cross-reference Pin
Eddy Vluggen13-May-13 0:32
professionalEddy Vluggen13-May-13 0:32 
GeneralRe: Saving objects with Cross-reference Pin
larsp77713-May-13 0:34
larsp77713-May-13 0:34 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen13-May-13 5:08
professionalEddy Vluggen13-May-13 5:08 
AnswerRe: Saving objects with Cross-reference Pin
Anna King8-May-13 3:24
professionalAnna King8-May-13 3:24 
GeneralRe: Saving objects with Cross-reference Pin
larsp7778-May-13 4:21
larsp7778-May-13 4:21 
Questionclosing and opening balance Pin
Er.Praveen Sharma6-May-13 21:38
Er.Praveen Sharma6-May-13 21:38 
AnswerRe: closing and opening balance Pin
Richard MacCutchan6-May-13 22:05
mveRichard MacCutchan6-May-13 22:05 
GeneralRe: closing and opening balance Pin
Er.Praveen Sharma6-May-13 23:48
Er.Praveen Sharma6-May-13 23:48 
AnswerRe: closing and opening balance Pin
Keith Barrow6-May-13 23:12
professionalKeith Barrow6-May-13 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.