public static bool AjouterContactAPI(ContactEntity.User user, System.Collections.Specialized.IOrderedDictionary newValues) { ContactEntity.Contact c = new ContactEntity.Contact(); Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user)); c.setIdcontact(0); c.setIduser(template.getIduser()); c.setDtcreation(DateTime.Now); c.setFavoris(false); c.setActif(true); if (c != null) { List <ContactEntity.Donnee> donnees = SetListeDonnees(newValues); c.setIduser(user.getIduser()); c.setDtcreation(DateTime.Now); c.setFavoris(false); c.setActif(true); c.setDonnees(donnees); c.setIduser(user.getIduser()); ContactWrapper cw = new ContactWrapper(); cw.setContact(c); cw.setIdtemplate(template.getIdtemplate()); ApiContact.SetContact(cw); return(true); } return(false); }
private void buttonModifier_Click(object sender, EventArgs e) { if (user == null || dataGridView1.CurrentRow == null) { return; } Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user)); if (template != null && ListeContacts != null) { DelegateChargerListeContact d = ChargerListeContacts; long idcontact = long.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()); if (ListeContacts != null) { Contact c = ListeContacts.Where(x => x.getIdcontact() == idcontact).FirstOrDefault(); if (c != null) { FicheContactForm w = new FicheContactForm(template, user.getIduser(), d, c); w.ShowDialog(); } } } }
private void buttonAjouter_Click(object sender, EventArgs e) { if (user == null) { return; } Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user)); if (template != null) { DelegateChargerListeContact d = ChargerListeContacts; FicheContactForm w = new FicheContactForm(template, user.getIduser(), d); w.ShowDialog(); } }
public static void SaveContactAPI(ContactEntity.User user, System.Collections.Specialized.IOrderedDictionary oldValues, System.Collections.Specialized.IOrderedDictionary newValues) { if (user == null) { return; } //charge la liste des contacts par l'API string strJson = ContactClasse.ApiContact.GetStringJSonContacts(user); List <ContactEntity.Contact> ListeContacts = ContactClasse.GestionContacts.GetContacts(strJson); List <EvalEntity.Champ> listeChamp = dao.DaoChamp.GetChamps(); int idcontact = 0; if (oldValues != null) { idcontact = Int32.Parse(oldValues["idcontact"] as string); } Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user)); if (template != null && ListeContacts != null) { ContactEntity.Contact c = ListeContacts.Where(x => x.getIdcontact() == idcontact).FirstOrDefault(); if (c != null) { List <ContactEntity.Donnee> donnees = SetListeDonnees(newValues); c.setIduser(user.getIduser()); c.setDtcreation(DateTime.Now); c.setFavoris(false); c.setActif(true); c.setDonnees(donnees); c.setIduser(user.getIduser()); ContactWrapper cw = new ContactWrapper(); cw.setContact(c); cw.setIdtemplate(template.getIdtemplate()); ApiContact.SetContact(cw); } } }
private void ChargerListeContacts() { this.Cursor = Cursors.WaitCursor; toolStripLabelInfo.Text = ""; dataGridView1.DataSource = null; user = null; try { string strJson = ApiContact.GetStringJSonUser(textBoxLogin.Text, textBoxPassword.Text); user = GestionContacts.GetUser(strJson); if (user == null) { toolStripLabelInfo.Text = "Utilisateur non valide."; } else { textBoxLogin.Enabled = false; textBoxPassword.Enabled = false; buttonConnexion.Text = "Déconnexion"; } strJson = ApiContact.GetStringJSonContacts(user); ListeContacts = GestionContacts.GetContacts(strJson); SetDataGridView(GetDataTableFromListContacts(ListeContacts)); } catch (Exception ex) { toolStripLabelInfo.Text = "Erreur de connexion: " + ex.Message; } finally { this.Cursor = Cursors.Default; } ConnecteVisible = (user != null); }