private void button1_Click(object sender, EventArgs e) { cls_Contact newContact = new cls_Contact(); try { DialogResult dr = MessageBox.Show(string.Format("آیا از تغییر اطلاعات بیمار به نام {0} با شماره پرونده {1} اطمینان دارید؟", selectedContact.FullName, selectedContact.PatientID), "پیغام اخطار", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { newContact.PatientID = TxtPatientID.Text; newContact.DiseaseName = cmbDiseaseName.Text; newContact.FirstName = TxtFName.Text; newContact.LastName = TxtLName.Text; newContact.FatherName = TxtFatherName.Text; newContact.SSID = TxtSSID.Text; newContact.Phone = TxtPhone.Text; newContact.Mobile = TxtMobile.Text; newContact.Notes = TxtNotes.Text; newContact.Birthday = TxtBirthday.Text; newContact.Email = TxtEmail.Text; newContact.Address = TxtAddress.Text; outlookManagement.UpdateContact(selectedContact, newContact); } RefreshGridView(); } catch (Exception) { MessageBox.Show("لطفا یکی از بیماران لیست شده را با Double Click اینتخاب کنید و بعد از تغییرات کلید ثبت را بزنید...", "پیغام خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign, true); } }
public bool AddNewContact(cls_Contact contact) { Outlook.MAPIFolder mAPIFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); Outlook.Items items = mAPIFolder.Items; try { Outlook.ContactItem newContact = items.Add(Outlook.OlItemType.olContactItem) as Outlook.ContactItem; newContact.Title = contact.PatientID; newContact.JobTitle = contact.DiseaseName; newContact.FirstName = contact.FirstName; newContact.LastName = contact.LastName; newContact.MiddleName = contact.FatherName; newContact.Suffix = contact.SSID; newContact.HomeTelephoneNumber = contact.Phone; newContact.MobileTelephoneNumber = contact.Mobile; newContact.Body = contact.Notes; newContact.User1 = contact.Birthday; newContact.Email1Address = contact.Email; newContact.HomeAddress = contact.Address; newContact.Save(); contacts.Add(contact); if (mAPIFolder != null) { Marshal.ReleaseComObject(mAPIFolder); } if (items != null) { Marshal.ReleaseComObject(items); } if (newContact != null) { Marshal.ReleaseComObject(newContact); } return(true); } catch (Exception) { return(false); } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { selectedContact = new cls_Contact(); string PatientID = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); string DiseaseName = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); string FirstName = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); string LastName = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); string FatherName = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); string SSID = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); string FullName = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); string Phone = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(); string Mobile = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString(); string Notes = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString(); string Birthday = dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString(); string Email = dataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString(); string Address = dataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString(); selectedContact = outlookManagement.contacts.ToList().Single(m => m.PatientID == PatientID & m.DiseaseName == DiseaseName & m.FirstName == FirstName & m.LastName == LastName & m.FatherName == FatherName & m.SSID == SSID & m.FullName == FullName & m.Phone == Phone & m.Mobile == Mobile & m.Notes == Notes); TxtPatientID.Text = selectedContact.PatientID; cmbDiseaseName.Text = selectedContact.DiseaseName; TxtFName.Text = selectedContact.FirstName; TxtLName.Text = selectedContact.LastName; TxtFatherName.Text = selectedContact.FatherName; TxtSSID.Text = selectedContact.SSID; TxtPhone.Text = selectedContact.Phone; TxtMobile.Text = selectedContact.Mobile; TxtNotes.Text = selectedContact.Notes; TxtBirthday.Text = selectedContact.Birthday; TxtEmail.Text = selectedContact.Email; TxtAddress.Text = selectedContact.Address; }
public cls_Appointment() { contact = new cls_Contact(); }
public bool UpdateContact(cls_Contact oldContact, cls_Contact newContact) { try { string FilterStr = ""; if (oldContact.PatientID != "") { FilterStr += "[Title] = '" + oldContact.PatientID + "'"; } if (oldContact.DiseaseName != "") { if (FilterStr.Length > 0) { FilterStr += " and [JobTitle] = '" + oldContact.DiseaseName + "'"; } else { FilterStr += "[JobTitle] = '" + oldContact.DiseaseName + "'"; } } if (oldContact.FirstName != "") { if (FilterStr.Length > 0) { FilterStr += " and [FirstName] = '" + oldContact.FirstName + "'"; } else { FilterStr += "[FirstName] = '" + oldContact.FirstName + "'"; } } if (oldContact.LastName != "") { if (FilterStr.Length > 0) { FilterStr += " and [LastName] = '" + oldContact.LastName + "'"; } else { FilterStr += "[LastName] = '" + oldContact.LastName + "'"; } } if (oldContact.FatherName != "") { if (FilterStr.Length > 0) { FilterStr += " and [MiddleName] = '" + oldContact.FatherName + "'"; } else { FilterStr += "[MiddleName] = '" + oldContact.FatherName + "'"; } } if (oldContact.SSID != "") { if (FilterStr.Length > 0) { FilterStr += " and [Suffix] = '" + oldContact.SSID + "'"; } else { FilterStr += "[Suffix] = '" + oldContact.SSID + "'"; } } if (oldContact.Phone != "") { if (FilterStr.Length > 0) { FilterStr += " and [HomeTelephoneNumber] = '" + oldContact.Phone + "'"; } else { FilterStr += "[HomeTelephoneNumber] = '" + oldContact.Phone + "'"; } } if (oldContact.Mobile != "") { if (FilterStr.Length > 0) { FilterStr += " and [MobileTelephoneNumber] = '" + oldContact.Mobile + "'"; } else { FilterStr += "[MobileTelephoneNumber] = '" + oldContact.Mobile + "'"; } } Outlook.ContactItem contact = OutlookContactsFind(FilterStr) as Outlook.ContactItem; if (contact != null) { contact.Title = newContact.PatientID; contact.JobTitle = newContact.DiseaseName; contact.FirstName = newContact.FirstName; contact.LastName = newContact.LastName; contact.MiddleName = newContact.FatherName; contact.Suffix = newContact.SSID; contact.HomeTelephoneNumber = newContact.Phone; contact.MobileTelephoneNumber = newContact.Mobile; contact.Body = newContact.Notes; contact.User1 = newContact.Birthday; contact.Email1Address = newContact.Email; contact.HomeAddress = newContact.Address; contact.Save(); oldContact.DiseaseName = newContact.DiseaseName; oldContact.FatherName = newContact.FatherName; oldContact.FirstName = newContact.FirstName; oldContact.LastName = newContact.LastName; oldContact.Mobile = newContact.Mobile; oldContact.Notes = newContact.Notes; oldContact.PatientID = newContact.PatientID; oldContact.Phone = newContact.Phone; oldContact.SSID = newContact.SSID; oldContact.Birthday = newContact.Birthday; oldContact.Email = newContact.Email; oldContact.Address = newContact.Address; oldContact.FullName = oldContact.FirstName + " " + oldContact.LastName; if (contact != null) { Marshal.ReleaseComObject(contact); } return(true); } } catch (Exception err) { logger.ErrorLog("Update Conact Info : " + err.Message); return(false); } return(false); }
private void FillContacts() { int counter = 0; Outlook.MAPIFolder mAPIFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); Outlook.Items items = mAPIFolder.Items; items.Sort("[Title]", true); ContactTotalCount = items.Count; contacts.Clear(); foreach (Outlook.ContactItem Ocontact in items) { try { bool chk = false; cls_Contact contact = new cls_Contact(); contact.PatientID = Ocontact.Title == null ? "" : Ocontact.Title; contact.DiseaseName = Ocontact.JobTitle == null ? "" : Ocontact.JobTitle; contact.FirstName = Ocontact.FirstName == null ? "" : Ocontact.FirstName; contact.LastName = Ocontact.LastName == null ? "" : Ocontact.LastName; contact.FatherName = Ocontact.MiddleName == null ? "" : Ocontact.MiddleName; contact.SSID = Ocontact.Suffix == null ? "" : Ocontact.Suffix; contact.FullName = contact.FirstName + " " + contact.LastName; contact.Birthday = Ocontact.User1 == null ? "" : Ocontact.User1; contact.Email = Ocontact.Email1Address == null ? "" : Ocontact.Email1Address; contact.Address = Ocontact.HomeAddress == null ? "" : Ocontact.HomeAddress; if (Ocontact.HomeTelephoneNumber == null) { contact.Phone = ""; } else { if (Ocontact.HomeTelephoneNumber.IndexOf(" ") != -1) { contact.Phone = Ocontact.HomeTelephoneNumber.Replace(" ", ""); Ocontact.HomeTelephoneNumber = Ocontact.HomeTelephoneNumber.Replace(" ", ""); chk = true; } else { contact.Phone = Ocontact.HomeTelephoneNumber; } } if (Ocontact.MobileTelephoneNumber == null) { contact.Mobile = ""; } else { if (Ocontact.MobileTelephoneNumber.IndexOf(" ") != -1) { contact.Mobile = Ocontact.MobileTelephoneNumber.Replace(" ", ""); Ocontact.MobileTelephoneNumber = Ocontact.MobileTelephoneNumber.Replace(" ", ""); chk = true; } else { contact.Mobile = Ocontact.MobileTelephoneNumber; } } if (!string.IsNullOrEmpty(Ocontact.MobileTelephoneNumber) && !Ocontact.MobileTelephoneNumber.StartsWith("0")) { contact.Mobile = Ocontact.MobileTelephoneNumber = Ocontact.MobileTelephoneNumber.StartsWith("0") ? Ocontact.MobileTelephoneNumber.Replace(" ", "") : "0" + Ocontact.MobileTelephoneNumber.Replace(" ", ""); chk = true; } contact.Notes = Ocontact.Body == null ? "" : Ocontact.Body; try { cls_Contact cls_Contact = contacts.Single(m => m.PatientID == contact.PatientID); //logger.ErrorLog(string.Format("Patient ID Conflict {0}", contact.PatientID)); } catch (Exception) { contacts.Add(contact); } if (chk) { Ocontact.Save(); } //if (counter++ > 500) // break; } catch (Exception ex) { logger.ErrorLog(ex.Message); } } if (mAPIFolder != null) { Marshal.ReleaseComObject(mAPIFolder); } if (items != null) { Marshal.ReleaseComObject(items); } }