private void btn_update_Click(object sender, EventArgs e) { string projDir = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName; string edi = System.IO.File.ReadAllText(projDir + "\\DadesClients.edi"); string[] subsEdi = edi.Split('|'); int actualContact = 0; for (int i = 0; i < subsEdi.Length;) { if (subsEdi[i].Trim() == "CON") // IDcontact, name, birth { //MessageBox.Show("CON :" + subsEdi[i + 1] + " # " + subsEdi[i + 2] + " # " + subsEdi[i + 3]); // if (EsNou) { NewContact newcont = new NewContact { idContact = actualContact, Name = subsEdi[i + 1], BirthDate = subsEdi[i + 2] }; db1.NewContacts.Add(newcont); } db1.SaveChanges(); i += 4; actualContact++; } else if (subsEdi[i].Trim() == "SYS") // IDcontact, description, value { //MessageBox.Show("SYS :" + subsEdi[i + 1] + " # " + subsEdi[i + 2]); // if (EsNou) { ContactSystem ctcsys = new ContactSystem { IdContact = actualContact, Description = subsEdi[i + 1], SystemValue = subsEdi[i + 2] }; db2.ContactSystems.Add(ctcsys); } db2.SaveChanges(); i += 3; } } }
private void btn_update_Click(object sender, EventArgs e) { if (EsNou) { ContactSystem ctcsys = new ContactSystem { //idContact = int.Parse(tbx_idcontact.Text), IdContact = int.Parse(tbx_idcontact.Text), Description = tbx_description.Text, SystemValue = tbx_systemvalue.Text }; db.ContactSystems.Add(ctcsys); } db.SaveChanges(); }