protected void ButtonNew_Click(object sender, EventArgs e) { RelationContact NewObj = new RelationContact(); ModelTMSContainer Temp = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session); EntityKey TempKey = new EntityKey("ModelTMSContainer.RelationSet", "Id", Guid.Parse(Request.Params["Id"])); Relation TempObj = Temp.GetObjectByKey(TempKey) as Relation; NewObj.Relation = TempObj; NewObj.RelationType = "Other"; NewObj.PhoneNumber = ""; NewObj.PrivateEMail = ""; NewObj.PrivateMobilePhone = ""; NewObj.MobilePhone = ""; NewObj.HomePhone = ""; NewObj.EMail = ""; NewObj.Description = "Nieuwe relatie dd " + Common.CurrentClientDateTime(Session).ToString(); Temp.AddToRelationContactSet(NewObj); Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave); WebUserControlCustomerRelationContact1.KeyID = NewObj.Id; WebUserControlCustomerRelationContact1.Visible = true; WebUserControlCustomerRelationContactLogOverview1.Visible = true; WebUserControlCustomerRelationContactLogOverview1.RelationContactId = NewObj.Id; DetailTable.Visible = true; //WebUserControlCustomerRelationContactLogOverview1.Visible = false; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // get the relation description ModelTMSContainer _ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session); if (Request.Params["CustomerRelationId"] != null) { EntityKey TempKey = new EntityKey("ModelTMSContainer.RelationContactSet", "Id", Guid.Parse(Request.Params["CustomerRelationId"])); RelationContact TempObj = _ControlObjectContext.GetObjectByKey(TempKey) as RelationContact; RelationContactId = TempObj.Id; } } }
protected void ButtonNewContractMaterial_Click(object sender, EventArgs e) { RelationContactLog NewObj = new RelationContactLog(); ModelTMSContainer Temp = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session); EntityKey TempKey = new EntityKey("ModelTMSContainer.RelationContactSet", "Id", RelationContactId); RelationContact TempObj = Temp.GetObjectByKey(TempKey) as RelationContact; NewObj.RelationContact = TempObj; NewObj.ContactType = "Other"; NewObj.FollowUpDateTime = Common.CurrentClientDateTime(Session); NewObj.PausedUntilDateTime = Common.CurrentClientDateTime(Session); NewObj.ContactDateTime = Common.CurrentClientDateTime(Session); NewObj.FollowUpState = "Handled"; NewObj.Description = "Nieuw contactmoment dd " + Common.CurrentClientDateTime(Session).ToString(); Temp.AddToRelationContactLogSet(NewObj); Temp.SaveChanges(SaveOptions.DetectChangesBeforeSave); WebUserControlCustomerRelationContactLog1.KeyID = NewObj.Id; WebUserControlCustomerRelationContactLog1.Visible = true; }
protected void ButtonSave_Click(object sender, EventArgs e) { // check if the company and contact person exists // if not check if the user has flagged them as new // if they are new but nog flagged as new then warn user and set the new flags // response.redirect after OK for new call List <string> Result = new List <string>(); ModelTMSContainer ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session); ObjectQuery QueryResult; QueryResult = ControlObjectContext.CreateQuery <Relation>("select value rs from RelationSet as rs where rs.Description like @prefixText order by rs.description LIMIT(1)", new ObjectParameter("prefixText", TextBoxClient.Text)); Relation Rel = null; foreach (Relation Rel2 in QueryResult) { Rel = Rel2; } QueryResult = ControlObjectContext.CreateQuery <RelationContact>("select value rs from RelationContactSet as rs where rs.Description like @prefixText order by rs.description LIMIT(1)", new ObjectParameter("prefixText", TextBoxPerson.Text)); RelationContact RelCon = null; foreach (RelationContact RelCon2 in QueryResult) { RelCon = RelCon2; } string ErrorMessage = ""; if ((Rel == null) && (!CheckBoxNewRelation.Checked)) { ErrorMessage = "De aangegeven relatie bestaat niet en u heeft niet aangegeven of dit een nieuwe relatie is. Bekijk de informatie goed of het inderdaad een nieuwe relatie is en sla dan de gegevens op."; CheckBoxNewRelation.Checked = true; } if ((RelCon == null) && (!CheckBoxNewContact.Checked)) { ErrorMessage = ErrorMessage + "\nHet aangegeven contact bestaat niet en u heeft niet aangegeven dat dit een nieuw contact is. Bekijk de informatie goed of het inderdaad een nieuwe contactpersoon is en sla dan de gegevens op."; CheckBoxNewContact.Checked = true; } if ((TextBoxClient.Text.Trim() == "") || (TextBoxPerson.Text.Trim() == "") || (TextBoxMessage.Text.Trim() == "")) { ErrorMessage = ErrorMessage + "\nVul de velden bedrijf, contactpersoon en bericht in."; } if (ErrorMessage == "") { // create new relation if desired if ((CheckBoxNewContact.Checked) && (Rel == null)) { Rel = new Relation(); Rel.Description = TextBoxClient.Text.Trim(); ControlObjectContext.AddToRelationSet(Rel); } // create new contact if desired if ((CheckBoxNewContact.Checked) && (RelCon == null)) { RelCon = new RelationContact(); RelCon.Description = TextBoxPerson.Text.Trim(); RelCon.Relation = Rel; ControlObjectContext.AddToRelationContactSet(RelCon); } // create new message RelationContactLog rcl = new RelationContactLog(); rcl.Description = "Contact dd " + Common.CurrentClientDateTime(Session).ToString(); rcl.ContactDateTime = Common.CurrentClientDateTime(Session); rcl.FollowUpDateTime = CalendarWithTimeControlReminder.SelectedDateTime; rcl.PausedUntilDateTime = rcl.FollowUpDateTime; rcl.FollowUpState = "Unhandled"; if (CheckBoxNoReminder.Checked) { rcl.FollowUpState = "Handled"; } rcl.Handler = new Guid(ClassComboBoxHandler.SelectedValue); rcl.ContactType = "Phone"; rcl.RelationContact = RelCon; rcl.Comments = TextBoxMessage.Text; ControlObjectContext.AddToRelationContactLogSet(rcl); // save ControlObjectContext.SaveChanges(); // redirect Response.Redirect(Request.Url.AbsoluteUri); } else { LabelErrorMessage.Text = ErrorMessage; } }