private static string GetDescriptionFor(Changelog item, Member member, Contact contact) { switch (item.action) { case DBConstants.NewContact: return String.Format("Lisätty uusi yhteystieto jäsenelle {0} {1} ({2})", member.firstname, member.lastname, member.MemberDetais.membergroup); case DBConstants.DeleteContact: return String.Format("Yhteystieto poistettu jäseneltä {0} {1}", member.firstname, member.lastname); case DBConstants.EditContact: return String.Format("Yhteystiedolta {0} {1} ({2} {3}) muutettu {4}", contact.firstname, contact.lastname, member.firstname, member.lastname, item.oldvalue); case DBConstants.NewMember: return String.Format("Lisätty uusi jäsen {0} {1} ({2})", member.firstname, member.lastname, member.MemberDetais.membergroup); case DBConstants.EditMember: return String.Format("Muokattu jäsentä {0} {1} ({2}) tietoa {3}", member.firstname, member.lastname, member.MemberDetais.membergroup, item.oldvalue); case DBConstants.NewNonMember: return String.Format("Jäsen eronnut {0} {1} ({2}) syy: {3}", member.firstname, member.lastname, item.oldvalue, member.MemberDetais.membergroup); default: Debug.Assert(false, "Should not be reached"); return "<Empty>"; } }
/// <summary> /// Construct new EditContactWindowViewModel. /// </summary> /// <param name="container">The member container</param> /// <param name="member">The member to which this contact belongs</param> /// <param name="contact">The contact to edit or null to create new</param> public EditContactWindowViewModel(MembersContainer container, MemberViewModel member, Contact contact) { _container = container; _contact = contact; _member = member; if (_contact == null) _contact = CreateEmptyContact(_member); }
protected void ddDetector_OnSelectedIndexChanged(object sender, EventArgs e) { labelStatusSelectDetector.Text = ""; buttonDetectorContinue.Enabled = true; if (ddDetector.SelectedValue == Guid.Empty.ToString()) { buttonDetectorContinue.Enabled = false; labelDetectorInfo.Text = ""; return; } try { Database.Interface.open(); Database.RingtestReport report = new Database.RingtestReport(); if (report.select_all_where_accountID_detectorID_ringtestID( new Guid(hiddenAccountID.Value), new Guid(ddDetector.SelectedValue), new Guid(hiddenRingtestID.Value))) { labelDetectorInfo.Text = Lang.Evaluated + ": " + (report.Evaluated ? "Ja" : "Nei"); labelDetectorInfo.Text += "<br>Godkjent: " + (report.Approved ? "Ja" : "Nei"); if (report.ContactID != Guid.Empty) { Database.Contact contact = new Database.Contact(); contact.select_all_by_ID(report.ContactID); labelDetectorInfo.Text += "<br>" + Lang.Contact + ": " + contact.Name + " [" + (contact.Status == "Active" ? "Aktiv" : "Inaktiv") + "]"; if (contact.Status != "Active") { buttonDetectorContinue.Enabled = false; } } else { labelDetectorInfo.Text += "<br>" + Lang.Contact + ": " + Lang.None; } } else { labelDetectorInfo.Text = Lang.NoReportForDetector + ".<br>" + Lang.PressContinueForNewReport; } } catch (Exception ex) { Utils.reportStatus(ref labelStatusSelectDetector, Color.Red, "Ringtest.ddDetector_OnSelectedIndexChanged: " + ex.Message); } finally { Database.Interface.close(); } }
protected void buttonCreateActor_OnClick(object sender, EventArgs e) { if (String.IsNullOrEmpty(textBoxName.Text) || String.IsNullOrEmpty(textBoxEmail.Text)) { Utils.displayStatus(ref labelStatusActors, Color.Red, Resources.Localization.MissingInformation); return; } if (!Utils.isValidEmail(textBoxEmail.Text)) { Utils.displayStatus(ref labelStatusActors, Color.Red, Lang.Email_invalid_address); return; } try { MembershipUser User = Membership.GetUser(HttpContext.Current.User.Identity.Name); object UserGUID = User.ProviderUserKey; Database.Interface.open(); Database.Contact contact = new Database.Contact((Guid)UserGUID, textBoxName.Text, textBoxEmail.Text, textBoxPhone.Text, textBoxMobile.Text, ddStatus.SelectedValue); if (!contact.insert_with_ID(Guid.NewGuid())) { Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.buttonCreateActor_OnClick: Create contact failed"); return; } Utils.displayStatus(ref labelStatusActors, Color.SeaGreen, Lang.User + " '" + textBoxName.Text + "' " + Lang.created); textBoxName.Text = ""; textBoxEmail.Text = ""; textBoxPhone.Text = ""; textBoxMobile.Text = ""; ddStatus.SelectedIndex = -1; textBoxNameUpd.Text = ""; textBoxEmailUpd.Text = ""; textBoxPhoneUpd.Text = ""; textBoxMobileUpd.Text = ""; ddActors.DataBind(); } catch (Exception ex) { Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.buttonCreateActor_OnClick: " + ex.Message); } finally { Database.Interface.close(); } }
protected void ddCourses_OnSelectedIndexChanged(object sender, EventArgs e) { if (ddCourses.SelectedValue == Guid.Empty.ToString()) { textBoxCourseTitleUpd.Text = ""; textBoxCourseDescriptionUpd.Text = ""; textBoxCourseCommentUpd.Text = ""; checkBoxCourseCompleteUpd.Checked = false; lbMembers.Items.Clear(); return; } try { Database.Interface.open(); Database.Course course = new Database.Course(); if (!course.select_all_where_ID(new Guid(ddCourses.SelectedValue))) { Utils.displayStatus(ref labelStatusCreate, Color.Red, "Kurs '" + ddCourses.SelectedItem.Text + "' ikke funnet"); return; } textBoxCourseTitleUpd.Text = course.Title; textBoxCourseDescriptionUpd.Text = course.Description; textBoxCourseCommentUpd.Text = course.Comment; checkBoxCourseCompleteUpd.Checked = course.Completed; Database.Contact contact = new Database.Contact(); Database.Account account = new Database.Account(); string accountName = ""; List <Guid> idList = new List <Guid>(); Database.Contact.select_ID_from_courseID(new Guid(ddCourses.SelectedValue), ref idList); lbMembers.Items.Clear(); foreach (Guid id in idList) { contact.select_all_by_ID(id); account.select_String_where_ID(contact.AccountID, "vchName", ref accountName); lbMembers.Items.Add(new ListItem(contact.Name + " fra " + accountName + " [" + (contact.Status == "Active" ? "Aktiv" : "Inaktiv") + "]")); } } catch (Exception ex) { Utils.displayStatus(ref labelStatusEdit, Color.Red, ex.Message); } finally { Database.Interface.close(); } }
protected void cbCourseActorBit_OnCheckChanged(object sender, EventArgs e) { if (gridCourse.SelectedDataKey == null) { Utils.displayStatus(ref labelStatus, Color.Red, Lang.No_courses_selected); clearAllActorBits(); return; } Guid courseID = (Guid)gridCourse.SelectedDataKey.Value; try { Database.Interface.open(); for (int i = 0; i < gridCourseActors.Rows.Count; i++) { Database.Contact contact = new Database.Contact(); contact.select_all_by_ID((Guid)gridCourseActors.DataKeys[i][0]); CheckBox cb = (CheckBox)gridCourseActors.Rows[i].FindControl("cbCourseActorBit"); if (cb.Checked) { contact.link_with_courseID(courseID); } else { contact.unlink_with_courseID(courseID); } Utils.displayStatus(ref labelStatus, Color.SeaGreen, Resources.Localization.StatusCourseUpdated); } } catch (Exception ex) { Utils.reportStatus(ref labelStatus, Color.Red, "Course.cbCourseActorBit_OnCheckChanged: " + ex.Message); } finally { Database.Interface.close(); } }
protected void ddActors_OnSelectedIndexChanged(object sender, EventArgs e) { if (ddActors.SelectedValue == Guid.Empty.ToString()) { textBoxNameUpd.Text = ""; textBoxEmailUpd.Text = ""; textBoxPhoneUpd.Text = ""; textBoxMobileUpd.Text = ""; ddStatus.SelectedIndex = -1; return; } try { Database.Interface.open(); Database.Contact contact = new Database.Contact(); if (!contact.select_all_by_ID(new Guid(ddActors.SelectedValue))) { Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.ddActors_OnSelectedIndexChanged: Contact not found"); return; } textBoxNameUpd.Text = contact.Name; textBoxEmailUpd.Text = contact.Email; textBoxPhoneUpd.Text = contact.Phone; textBoxMobileUpd.Text = contact.Mobile; ddStatus.SelectedValue = contact.Status; } catch (Exception ex) { Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.ddActors_OnSelectedIndexChanged: " + ex.Message); } finally { Database.Interface.close(); } }
private static StringBuilder BuildContactColumn(Properties.Export export, Contact contact) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(export.FoFirstBlock, contact.lastname + " " + contact.firstname); AppendBlockOr(export, sb, contact.mobile, "Matkapuhelin puuttuu"); AppendBlockOr(export, sb, contact.email, "Sähköposti puuttuu"); if (contact.Address != null) { sb.AppendFormat(export.FoBlock, contact.Address.address); sb.AppendFormat(export.FoBlock, contact.Address.postalcode + " " + contact.Address.city); } else Debug.Print("Got null address for contact {0} {1}", contact.firstname, contact.lastname); sb.AppendFormat(export.FoBlock, contact.phone); return sb; }
protected void buttonUpdateActor_OnClick(object sender, EventArgs e) { if (ddActors.SelectedValue == Guid.Empty.ToString()) { return; } if (String.IsNullOrEmpty(textBoxNameUpd.Text) || String.IsNullOrEmpty(textBoxEmailUpd.Text)) { Utils.displayStatus(ref labelStatusActors, Color.Red, Resources.Localization.MissingInformation); return; } if (!Utils.isValidEmail(textBoxEmailUpd.Text)) { Utils.displayStatus(ref labelStatusActors, Color.Red, Lang.Email_invalid_address); return; } try { Database.Interface.open(); Database.Contact contact = new Database.Contact(); if (!contact.select_all_by_ID(new Guid(ddActors.SelectedValue))) { Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.buttonUpdateActor_OnClick: Contact not found"); return; } if (ddStatus.SelectedValue != "Active") { Database.Interface.open(); Database.Interface.command.Parameters.Clear(); Database.Interface.command.CommandText = @" SELECT COUNT(Contact.ID) FROM Contact, Course, Contact_Course WHERE Course.bitCompleted = 0 AND Contact.ID = Contact_Course.ContactID AND Course.ID = Contact_Course.CourseID AND Contact.ID = @contactID"; Database.Interface.command.CommandType = CommandType.Text; Database.Interface.command.Parameters.AddWithValue("@contactID", contact.ID); int count = (int)Database.Interface.command.ExecuteScalar(); if (count > 0) { Utils.displayStatus(ref labelStatusActors, Color.Red, "Kan ikke deaktivere. Den interne brukeren er oppmeldt til en eller flere kurs"); return; } Database.Interface.command.Parameters.Clear(); Database.Interface.command.CommandText = @" SELECT COUNT(RingtestReport.ID) FROM RingtestReport WHERE RingtestReport.bitApproved = 0 AND RingtestReport.ContactID = @contactID"; Database.Interface.command.CommandType = CommandType.Text; Database.Interface.command.Parameters.AddWithValue("@contactID", contact.ID); count = (int)Database.Interface.command.ExecuteScalar(); if (count > 0) { Utils.displayStatus(ref labelStatusActors, Color.Red, "Kan ikke deaktivere. Den interne brukeren har en eller flere ringtest rapporter"); return; } Database.Interface.command.Parameters.Clear(); } contact.Name = textBoxNameUpd.Text; contact.Email = textBoxEmailUpd.Text; contact.Phone = String.IsNullOrEmpty(textBoxPhoneUpd.Text) ? "" : textBoxPhoneUpd.Text; contact.Mobile = String.IsNullOrEmpty(textBoxMobileUpd.Text) ? "" : textBoxMobileUpd.Text; contact.Status = ddStatus.SelectedValue; if (!contact.update_all_by_ID()) { Utils.reportStatus(ref labelStatusActors, Color.Red, "Actors.buttonUpdateActor_OnClick: Update contact failed"); return; } Utils.displayStatus(ref labelStatusActors, Color.SeaGreen, Lang.Contact + " '" + textBoxNameUpd.Text + "' " + Lang.updated); textBoxNameUpd.Text = ""; textBoxEmailUpd.Text = ""; textBoxPhoneUpd.Text = ""; textBoxMobileUpd.Text = ""; ddStatus.SelectedIndex = -1; ddActors.DataBind(); } catch (Exception ex) { Utils.displayStatus(ref labelStatusActors, Color.Red, "Actors.buttonUpdateActor_OnClick: " + ex.Message); } finally { Database.Interface.close(); } }
/// <summary> /// Create a new Contact object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="firstname">Initial value of the firstname property.</param> /// <param name="lastname">Initial value of the lastname property.</param> /// <param name="mobile">Initial value of the mobile property.</param> /// <param name="email">Initial value of the email property.</param> /// <param name="phone">Initial value of the phone property.</param> public static Contact CreateContact(global::System.Int64 id, global::System.String firstname, global::System.String lastname, global::System.String mobile, global::System.String email, global::System.String phone) { Contact contact = new Contact(); contact.Id = id; contact.firstname = firstname; contact.lastname = lastname; contact.mobile = mobile; contact.email = email; contact.phone = phone; return contact; }
/// <summary> /// Deprecated Method for adding a new object to the ContactSet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToContactSet(Contact contact) { base.AddObject("ContactSet", contact); }
private void ShowEditContactWindow(Contact contact, MemberViewModel member) { var ecwvm = new EditContactWindowViewModel(_container, member, contact); var window = new View.EditContactWindow(); ecwvm.RequestClose += delegate { window.Close(); }; window.DataContext = ecwvm; window.Show(); }