/// <summary> /// Creates a new stage record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void CreateOrganizationStageRecord(object sender, EventArgs e) { CaisisCheckBox eventCheckBox = sender as CaisisCheckBox; // Only need to save if checked if (eventCheckBox.Checked) { ProjectStage biz = new ProjectStage(); RepeaterItem rptrItem = eventCheckBox.NamingContainer as RepeaterItem; HiddenField orgIdField = rptrItem.FindControl("OrgIdField") as HiddenField; HiddenField stageIdField = rptrItem.FindControl("OrgStageIdField") as HiddenField; HiddenField projectStageId = rptrItem.NamingContainer.NamingContainer.FindControl("ProjectStageId") as HiddenField; Label sName = rptrItem.NamingContainer.NamingContainer.FindControl("StageLabel") as Label; HiddenField sColor = rptrItem.NamingContainer.NamingContainer.FindControl("StageColor") as HiddenField; // Only save a new stage record if one doesn't exist if (string.IsNullOrEmpty(stageIdField.Value)) { int orgId = int.Parse(orgIdField.Value); int projStageId = int.Parse(projectStageId.Value); string stageName = sName.Text; ProjectStage stageBiz = new ProjectStage(); stageBiz[ProjectStage.ProjectId] = projectId; stageBiz[ProjectStage.OrganizationId] = orgId; stageBiz[ProjectStage.Name] = stageName; stageBiz[ProjectStage.ColorCode] = sColor.Value; stageBiz.Save(); int orgStageId = int.Parse(stageBiz[ProjectStage.StageId].ToString()); stageIdField.Value = orgStageId.ToString(); } } }
/// <summary> /// Sets the checkbox for the specified type (dataset or tab) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetCheckBoxes(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // get checkbox CaisisCheckBox keyField = e.Item.FindControl("KeyField") as CaisisCheckBox; // get value field ICaisisInputControl valueField = e.Item.FindControl("ValueField") as ICaisisInputControl; // handle dataset access if (sender == DatasetsRptr) { int rowDatasetId = (int)DataBinder.Eval(e.Item.DataItem, Dataset.DatasetId); var found = from g in currentGroupDatasets let d = (int)g[GroupDataset.DatasetId] where d == rowDatasetId select g; if (found.Count() > 0) { keyField.Checked = true; // set pri key valueField.Value = found.First()[GroupDataset.GroupDatasetId].ToString(); } } // handle tab access else if (sender == TabsRptr) { string tabName = e.Item.DataItem.ToString(); // check if tab is in access code keyField.Checked = currentGroupAccessTabs.Contains(tabName); } } }
protected void UpdateClick(object sender, EventArgs e) { foreach (GridViewRow row in DiseasesGrid.DirtyGridRows) { var lookup = CICHelper.GetCaisisInputControlDictionary(row); int?diseaseId = null; if (!string.IsNullOrEmpty(lookup[Disease.DiseaseId].Value)) { diseaseId = int.Parse(lookup[Disease.DiseaseId].Value); } string diseaseName = lookup[Disease.DiseaseName].Value; string diseaseAttributeValueId = lookup[DiseaseAttributeValue.DiseaseAttributeValueId].Value; string diseaseAttributeValue = (lookup[DiseaseAttributeValue.DiseaseAttributeValue_Field] as CheckBox).Checked.ToString(); ICaisisInputControl isViewAttributeId = lookup[DiseaseAttributeValue.DiseaseAttributeValueId]; CaisisCheckBox isViewAttribute = lookup[DiseaseAttributeValue.DiseaseAttributeValue_Field] as CaisisCheckBox; // insert/update disease Disease dBiz = new Disease(); if (diseaseId.HasValue) { dBiz.Get(diseaseId.Value); } dBiz[Disease.DiseaseName] = diseaseName; dBiz.Save(); diseaseId = (int)dBiz[Disease.DiseaseId]; // check if disease attribute exists, update if (isViewAttribute.Checked) { if (string.IsNullOrEmpty(isViewAttributeId.Value)) { DiseaseAttributeValue dav = new DiseaseAttributeValue(); dav[DiseaseAttributeValue.DiseaseId] = diseaseId; dav[DiseaseAttributeValue.DiseaseAttributeId] = GetDiseaseIsViewAttribute(); dav[DiseaseAttributeValue.DiseaseAttributeValue_Field] = true.ToString().ToLower(); dav.Save(); isViewAttributeId.Value = dav[dav.PrimaryKeyName].ToString(); } } else { // only delete if key exists if (!string.IsNullOrEmpty(isViewAttributeId.Value)) { DiseaseAttributeValue dav = new DiseaseAttributeValue(); dav.Delete(int.Parse(isViewAttributeId.Value)); isViewAttributeId.Value = string.Empty; } } } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "reloadMainAdmin", "reloadMainAdmin();", true); }
protected void SetGridView(ICaisisInputControl icic, string tableName, string tableAttributeValue) { CaisisCheckBox cb = icic as CaisisCheckBox; bool isGrid = BusinessObject.GetParentKeyName(tableName) != BusinessObject.GetPrimaryKeyName(tableName); if (!isGrid) { SetNAField(icic); } // set value icic.Value = tableAttributeValue; }
/// <summary> /// Sets the IsView checkbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetDiseaseIsViewRow(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // determine if the current attribute value (if any) is true string isViewValue = DataBinder.Eval(e.Row.DataItem, DiseaseAttributeValue.DiseaseAttributeValue_Field).ToString(); CaisisCheckBox isViewCheckBox = e.Row.FindControl("IsViewAttributeValue") as CaisisCheckBox; if (!string.IsNullOrEmpty(isViewValue) && isViewValue.Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase)) { isViewCheckBox.Checked = true; } } }
public string GetAllCheckedDiseaseStates() { string strDiseaseState = ""; List <string> disStates = new List <string>(); foreach (RepeaterItem item in DiseaseStateRptr.Items) { CaisisCheckBox diseaseState = item.FindControl("DiseaseStateCheckBox") as CaisisCheckBox; if (diseaseState.Checked) { disStates.Add(diseaseState.Text); } } return(string.Join(",", disStates.ToArray())); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OnLookupGridRowUpdaing(object sender, GridViewUpdateEventArgs e) { GridViewRow row = LookupCodeGrid.Rows[e.RowIndex]; List <ICaisisInputControl> cicList = PageUtil.GetCaisisInputControlsInContainer(row); LookupCode biz = new LookupCode(); object priKey = LookupCodeGrid.DataKeys[e.RowIndex].Value; // Insert/No Key Present if (!priKey.ToString().Equals(string.Empty)) { int lkpCodeId = (int)priKey; biz.Get(lkpCodeId); } if (Request.Form["lkpName"] != null) { biz[LookupCode.LkpFieldName] = Request.Form["lkpName"]; } else if (!string.IsNullOrEmpty(lkpFieldName.Value)) { biz[LookupCode.LkpFieldName] = lkpFieldName.Value; } else if (!string.IsNullOrEmpty(fieldName.SelectedValue)) { biz[LookupCode.LkpFieldName] = fieldName.SelectedValue; } else { return; } // Manually Extract values to fix issues with LkpSupress foreach (ICaisisInputControl cic in cicList) { if (cic is CaisisCheckBox) { CaisisCheckBox cb = cic as CaisisCheckBox; biz[cic.Field] = cb.Checked; } else { biz[cic.Field] = cic.Value; } } biz.Save(); }
/// <summary> /// Sets the checkbox for the specified type (dataset or tab) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetCheckBoxes(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // get checkbox CaisisCheckBox keyField = e.Item.FindControl("KeyField") as CaisisCheckBox; // get value field ICaisisInputControl valueField = e.Item.FindControl("ValueField") as ICaisisInputControl; // handle dataset access if (sender == DatasetsRptr) { int rowDatasetId = (int)DataBinder.Eval(e.Item.DataItem, "DatasetId"); keyField.Checked = currentGroupDatasets.Contains(rowDatasetId); } // handle tab access else if (sender == TabsRptr) { string rowTabName = DataBinder.Eval(e.Item.DataItem, "Name").ToString(); // check if tab is in access code keyField.Checked = currentGroupAccessTabs.Contains(rowTabName.ToUpper()); } } }
/// <summary> /// /// </summary> private void Save() { // get the name of the pri key, i.e., "TableId" string priKeyName = BOL.BusinessObject.GetPrimaryKeyName(QueryTable); // get disease attribute, i.e., "TableId" DiseaseAttribute_Table attributeBiz = dc.GetDiseaseAttribute(priKeyName); // if none exists, create if (attributeBiz == null) { attributeBiz = dc.CreateDiseaseAttribute(priKeyName); } // get required foreign keys int diseaseId = QueryDiseaseId.Value; int diseaseAttributeId = (int)attributeBiz[DiseaseAttribute_Table.DiseaseAttributeId]; foreach (GridViewRow row in DiseaseTableGrid.DirtyGridRows) { CaisisCheckBox cb = row.FindControl("DiseaseCheckBox") as CaisisCheckBox; int tablePriKey = (int)DiseaseTableGrid.DataKeys[row.RowIndex][priKeyName]; object diseaseValuePriKey = DiseaseTableGrid.DataKeys[row.RowIndex][DiseaseAttributeValue.DiseaseAttributeValueId]; // insert if no value exists if (cb.Checked && string.IsNullOrEmpty(diseaseValuePriKey.ToString())) { dc.CreateDiseaseAttributeValue(diseaseId, diseaseAttributeId, tablePriKey.ToString()); } // delete if there is a pri key else if (!cb.Checked && !string.IsNullOrEmpty(diseaseValuePriKey.ToString())) { int priKey = int.Parse(diseaseValuePriKey.ToString()); DiseaseAttributeValue biz = new DiseaseAttributeValue(); biz.Delete(priKey); } } }
/// <summary> /// Initalizes variables and attaches event handlers for populating/updating DxImageFindingFields /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InitEvents(object sender, EventArgs e) { List <CaisisCheckBox> checkBoxList = new List <CaisisCheckBox>(IMG_FIND_SUBSITES.Length); // setup event handlers foreach (string bodyPart in IMG_FIND_SUBSITES) { // Main Checkbox for each body part CaisisCheckBox subSiteCheckBox = this.FindControl(bodyPart + "_Check") as CaisisCheckBox; checkBoxList.Add(subSiteCheckBox); CaisisHidden basicSubSiteId = this.FindControl(bodyPart + "_BasicId") as CaisisHidden; string basicFindSubSite = bodyPart; // Populate basic basic image finding by subsite this.PopulateDxImagingField += new DxImageFindingEvent(delegate(int diagnosticId) { // Check if a basic record is found for subsite and set prikey and check box DataRow basicFind = FindDxBoneRecordBasic(diagnosticId, basicFindSubSite); if (basicFind != null) { basicSubSiteId.Value = basicFind[ImageFinding.DxImageFindingId].ToString(); subSiteCheckBox.Checked = true; } }); // Update event for basic image finding by subsite, no ImgFindNew,ImgFindSide or ImgFindAP DxImageFindingEvent basicSubSiteUpdateEvent = new DxImageFindingEvent(delegate(int diagnosticId) { ImageFinding biz = new ImageFinding(); if (subSiteCheckBox.Checked) { if (!string.IsNullOrEmpty(basicSubSiteId.Value)) { biz.Get(int.Parse(basicSubSiteId.Value)); } else { biz[ImageFinding.DiagnosticId] = diagnosticId; } biz[ImageFinding.ImgFindSite] = ImageTypes[0]; biz[ImageFinding.ImgFindSubsite] = basicFindSubSite; biz.Save(); // update prikey field basicSubSiteId.Value = biz[ImageFinding.DxImageFindingId].ToString(); } else { if (!string.IsNullOrEmpty(basicSubSiteId.Value)) { biz.Delete(int.Parse(basicSubSiteId.Value)); // update prikey field basicSubSiteId.Value = string.Empty; } } }); // When subsite checkbox changed, mark as dirty subSiteCheckBox.ValueChanged += GetValueChangeEventHandler(subSiteCheckBox, basicSubSiteUpdateEvent); // DETAIL ORIENTED FIELDS // iterate through specific subsite fields and set update and populate events foreach (string view in IMG_FIND_AP) { foreach (string side in IMG_FIND_SIDES) { CaisisTextBox bodyPartViewSide = this.FindControl(view + "_" + bodyPart + "_" + side) as CaisisTextBox; CaisisHidden bodyPartViewSideId = this.FindControl(view + "_" + bodyPart + "_" + side + "_Id") as CaisisHidden; // Static Values string imgFindAP = view; string imgFindSide = side; string imgFindSubsite = bodyPart; // EVENT HANDLER which populates fields DxImageFindingEvent populateEvent = new DxImageFindingEvent(delegate(int diagnosticId) { // Populate when not posting back DataRow foundBodyPartViewSide = FindDxBoneRecord(diagnosticId, imgFindAP, imgFindSide, imgFindSubsite); if (bodyPartViewSideId != null && foundBodyPartViewSide != null) { // set pri key bodyPartViewSideId.Value = foundBodyPartViewSide[ImageFinding.DxImageFindingId].ToString(); // set textbox value bodyPartViewSide.Value = foundBodyPartViewSide[ImageFinding.ImgFindNew].ToString(); // check box to indicate record found and has value subSiteCheckBox.Checked = true; // COLLECT MORE ACTIVATED CollectMore.Checked = true; } }); // EVENT HANDLER which updates the DxImageFindings table DxImageFindingEvent updateEvent = new DxImageFindingEvent(delegate(int diagnosticId) { // Create new Biz ImageFinding biz = new ImageFinding(); // load record if exists if (!string.IsNullOrEmpty(bodyPartViewSideId.Value)) { int priKey = int.Parse(bodyPartViewSideId.Value); if (!string.IsNullOrEmpty(bodyPartViewSide.Value)) { biz.Get(priKey); } // otherwise, do not save empty ImgFindNew, remove record else { biz.Delete(priKey); return; } } else { // set par key field biz[ImageFinding.DiagnosticId] = diagnosticId; } // set ImgFindNew from text field biz[ImageFinding.ImgFindNew] = bodyPartViewSide.Value; // Get static values from dictionary biz[ImageFinding.ImgFindSite] = ImageTypes[0]; biz[ImageFinding.ImgFindAP] = imgFindAP; biz[ImageFinding.ImgFindSide] = imgFindSide; biz[ImageFinding.ImgFindSubsite] = imgFindSubsite; // save/update record biz.Save(); // update prikeyfield bodyPartViewSideId.Value = biz[ImageFinding.DxImageFindingId].ToString(); // Since we're creating a specific subsite find location, we need to remove generic subsite find record if (!string.IsNullOrEmpty(basicSubSiteId.Value)) { ImageFinding basicFinding = new ImageFinding(); biz.Delete(int.Parse(basicSubSiteId.Value)); // update basic finding field basicSubSiteId.Value = string.Empty; } }); // Attach event for tracking dirty fields bodyPartViewSide.ValueChanged += GetValueChangeEventHandler(bodyPartViewSide, updateEvent);; // Attach events for populating fields this.PopulateDxImagingField += new DxImageFindingEvent(populateEvent); } } } // EVENTS for Total Lesions compared to BASELINE SCAN //// Create populating event which will set hidden field and radio button value if an image finding found //DxImageFindingEvent totalNewLesionsUpdate = new DxImageFindingEvent(delegate(int diagnosticId) // { // DataRow found = FindDxBoneRecord(diagnosticId); // if (found != null) // { // DxTotalNumNewTumors.Value = found[ImageFinding.ImgFindNew].ToString(); // TotalNewLesionsId.Value = found[ImageFinding.DxImageFindingId].ToString(); // } // }); //this.PopulateDxImagingField += new DxImageFindingEvent(totalNewLesionsUpdate); //// Create an update event which is used for updating the total number of lesions //DxImageFindingEvent basicBareUpdate = new DxImageFindingEvent(delegate(int diagnosticId) //{ // ImageFinding biz = new ImageFinding(); // if (!string.IsNullOrEmpty(TotalNewLesionsId.Value)) // { // biz.Get(int.Parse(TotalNewLesionsId.Value)); // } // else // { // biz[ImageFinding.DiagnosticId] = diagnosticId; // } // //biz[ImageFinding.ImgFindNew] = DxTotalNumNewTumors.Value; // biz[ImageFinding.ImgFindNotes] = "New total findings compared to BASELINE SCAN."; // biz[ImageFinding.ImgFindSite] = ImageTypes[0]; // // var q = // //from c in checkBoxList // //let v = c.Value // //where c.Checked // //select v; // //string checkedValues = string.Join(",", checkBoxList.Where(c => c.Checked).Select(c => c.Value).ToArray()); // biz.Save(); //}); //// When chnaging total lesion, trigger dirty field //DxTotalNumNewTumors.ValueChanged += GetValueChangeEventHandler(DxTotalNumNewTumors, basicBareUpdate); }