protected void UpdateClick(object sender, EventArgs e) { string username = new Security.SecurityController().GetUserName(); // update item timeline (insert, delete) UpdateItemTimelines(username); // update timeline (fix schedules) UpdateTimelines(username); // re-bind BuildSchemaTimeline(sender, e); }
/// <summary> /// Saves the status in the current control /// </summary> /// <param name="container"></param> private void SaveStatus(Control container) { HiddenField StatusIdField = container.FindControl("StatusIdField") as HiddenField; ICaisisInputControl Status_Field = container.FindControl("Status_Field") as ICaisisInputControl; ICaisisInputControl StatusDateText = container.FindControl("StatusDateText") as ICaisisInputControl; // get pri key int?statusId = null; if (!string.IsNullOrEmpty(StatusIdField.Value)) { statusId = int.Parse(StatusIdField.Value); } // validate if (string.IsNullOrEmpty(StatusDateText.Value)) { return; } // create/edit entry Status status = new Status(); // load existing if (statusId.HasValue) { status.Get(statusId.Value); } // create new entry else { status[Status.PatientId] = patientId; // required status[Status.StatusDisease] = STATUS_DISEASE; status[Status.Status_Field] = Status_Field.Value; } CICHelper.SetBOValues(container.Controls, status, patientId); status.Save(); // update pri key field statusId = (int)status[Status.StatusId]; StatusIdField.Value = statusId.Value.ToString(); // run dependency scheduling int patientSchemaId = int.Parse(PatientSchemaId); string username = new Security.SecurityController().GetUserName(); ProtocolMgmtDa.ScheduleDependentPatientItemsByStatus(patientSchemaId, username); }
protected override void Page_Load(object sender, EventArgs e) { // validate GROUP access string userName = new Security.SecurityController().GetUserName(); GroupDa da = new GroupDa(); var userGroupNames = da.GetUserGroups(userName).Tables[0].AsEnumerable().Select(r => r[BOL.Group.GroupName].ToString()); // if user is not in special group, end response if (RESTRICTED_GROUPS.Intersect(userGroupNames).Count() == 0) { Page.Visible = false; Response.End(); } base.Page_Load(sender, e); base.EnableViewState = true; if (!Page.IsPostBack) { // default dates FromDate.Text = DateTime.Today.AddMonths(-1).ToShortDateString(); ToDate.Text = DateTime.Today.ToShortDateString(); } }
private void AddGrid(GridView grid, ImageButton addNewRowButton, string tableName) { Panel panel = new Panel(); panel.CssClass = "PDSectionHolder"; panel.Style["padding"] = "5px"; panel.Style["width"] = "auto"; grid.Style["margin-left"] = "15px"; grid.Style["margin-top"] = "0px"; // add clear items columns GridRowClearImage clearBtnColumn = new GridRowClearImage(); grid.Columns.Add(clearBtnColumn); string[] keyNames = grid.DataKeyNames; // validate: LockedBy bool validateAuditField = lockableTables.Contains(tableName); // add delete button in special cases if (ALLOW_TABLE_DELETES.Contains(tableName)) { string priKeyName = BOL.BusinessObject.GetPrimaryKeyName(tableName); GridRowDeleteImage deleteButton = new GridRowDeleteImage(); grid.Columns.Add(deleteButton); grid.RowDeleting += (o, e) => { GridViewRow gridRow = grid.Rows[e.RowIndex]; HiddenField priKeyField = gridRow.FindControl(priKeyName) as HiddenField; if (priKeyField != null && !string.IsNullOrEmpty(priKeyField.Value)) { // delete record int priKey = int.Parse(priKeyField.Value); BusinessObject bo = BusinessObjectFactory.BuildBusinessObject(tableName); bo.Delete(priKey); // reset patient item fields Dictionary <string, IEnumerable <int> > destTableToKeys = new Dictionary <string, IEnumerable <int> >(); destTableToKeys.Add(tableName, new int[] { priKey }); string username = new Security.SecurityController().GetUserName(); ProtocolMgmtDa.ClearProtocolMgrPatientFieldsWithPKey(PatientItemId, destTableToKeys, username); // TODO: proper redirect Response.Redirect(Request.Url.PathAndQuery, true); } }; } // add hidden keys as input fields (used for UI) var hiddenKeyNames = keyNames.Except(new string[] { Patient.PatientId }); grid.RowCreated += (sender, e) => { int lastCellIndex = e.Row.Cells.Count - 1; if (lastCellIndex > -1) { TableCell lastCell = e.Row.Cells[lastCellIndex]; foreach (string key in hiddenKeyNames) { HiddenField hidden = new HiddenField(); hidden.ID = key; // add field to cell lastCell.Controls.Add(hidden); } } }; // suppress clear button for existing records grid.RowDataBound += (sender, e) => { // data retriever DataRowView dataRow = e.Row.DataItem as DataRowView; Func <string, object> getRowValue = (fieldName) => { return(dataRow != null && dataRow.Row.Table.Columns[fieldName] != null ? dataRow[fieldName] : null); }; if (e.Row.RowType == DataControlRowType.DataRow && e.Row.DataItem != null) { bool hasEmptyKeys = false; // for each key field, set associated hidden field foreach (string key in keyNames) { string keyValue = getRowValue(key) + ""; HiddenField hidden = e.Row.FindControl(key) as HiddenField; if (hidden != null) { hidden.Value = keyValue; } hasEmptyKeys = hasEmptyKeys || string.IsNullOrEmpty(keyValue); } // suppress clear on "real" rows IEnumerable <HyperLink> clearBtn = Caisis.UI.Core.Classes.PageUtil.GetControls <HyperLink>(e.Row).Where(btn => btn.CssClass.Contains("ClearGridRowLink")); if (!hasEmptyKeys) { clearBtn.ForEach(b => b.Style["display"] = "none"); } // suppress delete button on "fake" rows IEnumerable <ImageButton> deleteBtn = Caisis.UI.Core.Classes.PageUtil.GetControls <ImageButton>(e.Row).Where(btn => btn.CommandName == "Delete"); if (hasEmptyKeys) { deleteBtn.ForEach(b => b.Style["display"] = "none"); } // validate: LockedBy if (validateAuditField) { object lockedBy = getRowValue(BusinessObject.LockedBy); bool rowIsLocked = lockedBy != null && lockedBy + "" != ""; if (rowIsLocked) { // special case var fields = CICHelper.GetCaisisInputControlDictionary(e.Row); if (fields.ContainsKey(LabTest.LabClinicalSignificance)) { var input = fields[LabTest.LabClinicalSignificance]; input.PreRender += (a, b) => input.Enabled = true; } } } // c13-124 if (MatchProtocol("c13-124") && tableName == "Medications" && includeAnalgesicMedications.HasValue) { string medType = getRowValue(Medication.MedType) + ""; bool showRow = string.IsNullOrEmpty(medType) || (includeAnalgesicMedications.Value ? medType == "Analgesic" : medType != "Analgesic"); e.Row.Visible = showRow; } } }; gridsToValidate.Add(tableName, grid); grid.DataBind(); grid.DataKeyNames = null; // workaround for ControlState bogosity panel.Controls.Add(grid); panel.Controls.Add(addNewRowButton); container.Controls.Add(panel); }