protected void lnkRemove_Click(object sender, EventArgs e) { string sDelContactIDs = this.hdnDelContactIDs.Value; string sDirections = this.hdnDirections.Value; string[] DelContactIDArray = sDelContactIDs.Split(','); string[] DirectionArray = sDirections.Split(','); // delete Contact_Relationship RelationshipManager = new Contact_Relationship(); try { // delete RelationshipManager.DeleteContactRelationship(this.iContactID, DelContactIDArray, DirectionArray); } catch (Exception ex) { string sExMsg = string.Format("Exception occurred while trying to delete the relationship (ContactID={0}): {1}", this.iContactID, ex.Message); LPLog.LogMessage(LogType.Logerror, ex.Message); PageCommon.WriteJsEnd(this, "Exception occurred while trying to delete the relationship.", "window.location.href=window.location.href;"); } // success PageCommon.WriteJsEnd(this, "Deleted the relationship successfully.", "window.location.href=window.location.href;"); }
protected void btnAddRelationship_Click(object sender, EventArgs e) { string sToContactIDs = this.hdnToContactIDs.Value; string sToRelationships = this.hdnToRelationships.Value; string sFromRelationships = this.hdnFromRelationships.Value; string[] ToContactIDArray = sToContactIDs.Split(','); string[] ToRelationshipArray = sToRelationships.Split(','); string[] FromRelationshipArray = sFromRelationships.Split(','); string[] sRelationshipTypeArray = new string[ToContactIDArray.Length]; for (int i = 0; i < ToRelationshipArray.Length; i++) { string sToRelationship = ToRelationshipArray[i]; string sFromRelationship = FromRelationshipArray[i]; DataRow[] RelationTypeRows = null; if (sFromRelationship != string.Empty) { RelationTypeRows = this.RelationshipRoles.Select("RelFromName='" + sFromRelationship + "' and RelToName='" + sToRelationship + "'"); } else { RelationTypeRows = this.RelationshipRoles.Select("RelToName='" + sToRelationship + "'"); } string sRelationTypeID = RelationTypeRows[0]["RelTypeId"].ToString(); sRelationshipTypeArray.SetValue(sRelationTypeID, i); } // insert Contact_Relationship RelationshipManager = new Contact_Relationship(); RelationshipManager.InsertContactRelationship(this.iContactID, ToContactIDArray, sRelationshipTypeArray); // success PageCommon.WriteJsEnd(this, "Add relationship successfully.", "window.parent.location.href=window.parent.location.href;"); }