private void SetFormState(bool isFormEnabled) { bool _isFormEnabled = isFormEnabled; CICHelper.EnableFields(this.Form.Controls, _isFormEnabled); if (_selectedJournal == "" || _selectedJournal.Equals(_dropDownNewValue)) { // New SetButtonVisibility(true, true, true, true, false, true, true); SetButtonStates(false, false, true, true, false, true, false); } else { if (_isFormEnabled) { // Populated Enabled Unlocked Form SetButtonVisibility(true, true, true, true, false, true, true); SetButtonStates(false, false, true, true, false, true, true); } else { // Populated Disabled Unlocked Form SetButtonVisibility(true, true, true, true, false, true, true); SetButtonStates(true, true, true, false, false, true, false); } } }
protected void SetFieldValues(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // get Status and Bizo (optional) string status = DataBinder.Eval(e.Item.DataItem, "Status").ToString(); Status biz = DataBinder.Eval(e.Item.DataItem, "Bizo") as Status; var inputs = CICHelper.GetCaisisInputControls(e.Item); HiddenField statusIdField = e.Item.FindControl("StatusId_Field") as HiddenField; ICaisisInputControl statusDateTextField = e.Item.FindControl("StatusDateText") as ICaisisInputControl; ICaisisInputControl statusDateField = e.Item.FindControl("StatusDate") as ICaisisInputControl; ICaisisInputControl statusField = e.Item.FindControl("Status") as ICaisisInputControl; HtmlTableRow rowElement = e.Item.FindControl("DataRecordRow") as HtmlTableRow; Control clearBtn = e.Item.FindControl("ClearBtn"); Control lockImg = e.Item.FindControl("LockImage"); clearBtn.Visible = false; lockImg.Visible = false; // populate statusField.Value = status; if (biz != null) { // populate fields CICHelper.SetFieldValues(inputs, biz); // set key field statusIdField.Value = biz[Status.StatusId] + ""; bool lockedByRecord = (biz[Status.LockedBy] + "") != ""; if (lockedByRecord) { CICHelper.EnableFields(e.Item.Controls, false); } lockImg.Visible = lockedByRecord; clearBtn.Visible = false; } // new records else { statusIdField.Value = ""; lockImg.Visible = false; clearBtn.Visible = true; // SPECIAL CASE: if calculated diagnosis date, lock status if (status == "Diagnosis Date") { DateTime?diagnosisDate = ProtocolMgmtServices.GetDateOfDiagnosis(patientId); if (diagnosisDate.HasValue) { CICHelper.EnableFields(e.Item.Controls, false); string displayDate = string.Format("{0:d}", diagnosisDate); statusDateField.Value = displayDate; statusDateTextField.Value = displayDate; lockImg.Visible = true; clearBtn.Visible = false; } } } } }
protected override void Page_Load(object sender, EventArgs e) { // validation if (!Request.QueryString.HasKeys()) { Response.End(); } if (!Page.IsPostBack) { IEnumerable <int> postedSpecimens = GetPostedSpecimenIds(); // set fields via QS SpecimenRequestId.Value = Request.QueryString["requestId"]; CollectionId.Value = Request.QueryString["collectionId"]; DistributionId.Value = Request.QueryString["distributionId"]; specimens.Value = Request.Form["specimens"]; string btnText = Request.QueryString["btnText"] + ""; if (!string.IsNullOrEmpty(btnText)) { DoTransferBtn.Text = btnText; } // set UI if (QueryMode == "request") { CICHelper.EnableFields(RequestFields.Controls, true); CICHelper.EnableFields(ReceivedFields.Controls, false); } else if (QueryMode == "received") { CICHelper.EnableFields(RequestFields.Controls, false); CICHelper.EnableFields(ReceivedFields.Controls, true); } else if (QueryMode == "readonly") { CICHelper.EnableFields(RequestFields.Controls, false); CICHelper.EnableFields(ReceivedFields.Controls, false); SpecimensGrid.Enabled = false; SpecimensGrid.Columns[0].Visible = false; DoTransferBtn.Visible = false; } // set default fields int protocolId = int.Parse(BaseProtocolId); string datasetSQL = base.GetSpecimenPatientsDatasetSQL(); // restrict to transfer of current type string nextRequestId = da.GetNextRequestIdByProtocol(base.ProtocolNumber); Protocol protocol = new Protocol(); protocol.Get(protocolId); string protocolNum = protocol[Protocol.ProtocolNum].ToString(); string requestIdentifier = nextRequestId; RequestIdentifier.Enabled = false; RequestIdentifier.Value = requestIdentifier; // on creation of transfer: allow to transfer to other if (QueryAction == "create") { // TODO: refactor string[] collectionStatuses = new string[] { QueryTransferStatus }; // get transfers and restrict to those not yet received DataTable currentTransfers = da.GetSpecimenTransfersByProtocol(protocolId, datasetSQL, collectionStatuses, new int[0]); var transferDataSource = from transfer in currentTransfers.AsEnumerable() where transfer.IsNull("ReceivedDate") select new { FieldText = transfer[SpecimenRequest.RequestIdentifier] + " (" + transfer["SpecimenCount"] + " Specimens)", FieldValue = string.Format("{0},{1},{2}", transfer[SpecimenRequest.SpecimenRequestId], transfer[SpecimenDistribution.DistributionId], transfer[SpecimenCollection.CollectionId]) }; ExistingTransferSelection.DataSource = transferDataSource; ExistingTransferSelection.DataBind(); ExistingTransferPanel.Visible = transferDataSource.Count() > 0; } else { ExistingTransferPanel.Visible = false; } // populate form values PopulateFormOnLoad(); } }