protected void btnSave_Click(object sender, EventArgs e) { // //verify if exists selected event type // if (!(rbtAlert.Checked || rbtInformation.Checked || rbtSugestion.Checked || rbtError.Checked)) { ShowError(Resources.Exception.UnselectedEventType); return; } EventManager eventManager = new EventManager(this); Vivina.Erp.DataClasses.Event ev = new Vivina.Erp.DataClasses.Event(); Vivina.Erp.DataClasses.Event original_ev = new Vivina.Erp.DataClasses.Event(); if (Page.ViewState["EventId"] != null) { original_ev = eventManager.GetEvent(Convert.ToInt32(Page.ViewState["EventId"])); ev.CopyPropertiesFrom(original_ev); } // ev.CompanyId = Company.CompanyId; ev.Name = txtName.Text; ev.Message = txtMessage.Value; ev.ApplicationId = Application.ApplicationId; ev.Rating = rtnPriority.CurrentRating; //if (!String.IsNullOrEmpty(cboTechnicalUser.SelectedValue)) // ev.TechnicalUserId = Convert.ToInt32(cboTechnicalUser.SelectedValue); if (!String.IsNullOrEmpty(cboEventStatus.SelectedValue)) ev.EventStatusId = Convert.ToInt32(cboEventStatus.SelectedValue); //set event type if (rbtAlert.Checked) ev.EventType = (Int32)InfoControl.Web.Auditing.EventType.Warning; if (rbtInformation.Checked) ev.EventType = (Int32)InfoControl.Web.Auditing.EventType.Information; if (rbtSugestion.Checked) ev.EventType = (Int32)InfoControl.Web.Auditing.EventType.Sugestion; //verify if is update or insert if (Page.ViewState["EventId"] != null) eventManager.Update(original_ev, ev); else { //where insert mode set creator's ID ev.UserId = User.Identity.UserId; eventManager.Insert(ev); } if (Company.CompanyId == HostCompany.CompanyId) Server.Transfer("EventViewer.aspx"); else Server.Transfer("../Site/1/WishList.aspx"); }
/// <summary> /// This method updates a record in the table. /// Change this method to alter how records are updated. /// </summary> /// <param name=original_entity>original_entity</param> /// <param name=entity>entity</param> public void Update(Event original_entity, Event entity) { original_entity.CopyPropertiesFrom(entity); DbContext.SubmitChanges(); }
protected void btnSave_Click(object sender, EventArgs e) { // //verify if exists selected event type // if (!(rbtAlert.Checked || rbtInformation.Checked || rbtSugestion.Checked || rbtError.Checked)) { ShowError(Resources.Exception.UnselectedEventType); return; } EventManager eventManager = new EventManager(this); Vivina.Erp.DataClasses.Event ev = new Vivina.Erp.DataClasses.Event(); Vivina.Erp.DataClasses.Event original_ev = new Vivina.Erp.DataClasses.Event(); if (Page.ViewState["EventId"] != null) { original_ev = eventManager.GetEvent(Convert.ToInt32(Page.ViewState["EventId"])); ev.CopyPropertiesFrom(original_ev); } // ev.CompanyId = Company.CompanyId; ev.Name = txtName.Text; ev.Message = txtMessage.Value; ev.ApplicationId = Application.ApplicationId; ev.Rating = rtnPriority.CurrentRating; //if (!String.IsNullOrEmpty(cboTechnicalUser.SelectedValue)) // ev.TechnicalUserId = Convert.ToInt32(cboTechnicalUser.SelectedValue); if (!String.IsNullOrEmpty(cboEventStatus.SelectedValue)) { ev.EventStatusId = Convert.ToInt32(cboEventStatus.SelectedValue); } //set event type if (rbtAlert.Checked) { ev.EventType = (Int32)InfoControl.Web.Auditing.EventType.Warning; } if (rbtInformation.Checked) { ev.EventType = (Int32)InfoControl.Web.Auditing.EventType.Information; } if (rbtSugestion.Checked) { ev.EventType = (Int32)InfoControl.Web.Auditing.EventType.Sugestion; } //verify if is update or insert if (Page.ViewState["EventId"] != null) { eventManager.Update(original_ev, ev); } else { //where insert mode set creator's ID ev.UserId = User.Identity.UserId; eventManager.Insert(ev); } if (Company.CompanyId == HostCompany.CompanyId) { Server.Transfer("EventViewer.aspx"); } else { Server.Transfer("../Site/1/WishList.aspx"); } }