📄 medicaltherapyform.ascx.cs
字号:
namespace Caisis.UI.Modules.All.DataEntryForms
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Specialized;
using Caisis.Controller;
using Caisis.DataAccess;
using Caisis.BusinessObject;
using Caisis.UI.Core.Classes;
using Caisis.UI.Core.Classes.CustomControls;
public abstract class MedicalTherapiesForm : DataEntryControl
{
protected HtmlSelect ProtocolId;
protected HtmlInputCheckBox MedTxPending;
protected HtmlInputText MedTxDateText;
protected HtmlInputText MedTxDate;
protected HtmlSelect MedTxType;
protected ComboBox MedTxIndication;
protected ComboBox MedTxAgent;
protected ComboBox MedTxIntent;
protected HtmlInputText MedTxStopDateText;
protected HtmlInputText MedTxStopDate;
protected HtmlInputText MedTxDose;
protected HtmlInputText MedTxTotalDose;
protected HtmlSelect MedTxUnits;
protected HtmlSelect MedTxRoute;
protected ComboBox MedTxSchedule;
protected HtmlInputText MedTxCycle;
protected HtmlInputText MedTxWeek;
protected ComboBox MedTxInstitution;
protected HtmlTextArea MedTxNotes;
protected ComboBox MedTxDataSource;
protected HtmlSelect MedTxQuality;
protected HtmlInputHidden MedicalTherapyId;
protected HtmlImage MedTxDateTextCal, MedTxStopDateTextCal;
override protected void Page_Load(object sender, System.EventArgs e)
{
//Get Protocols for dropdown
//populate protocols from distinct values
ProtocolDa protDa = new ProtocolDa();
DataSet protDs = protDa.GetDistinctProtocols();
ProtocolId.DataSource = protDs.Tables[0].DefaultView;
ProtocolId.DataValueField = "protocolID";
ProtocolId.DataTextField = "protocolNum";
ProtocolId.DataBind();
ProtocolId.Items.Insert(0,new ListItem("",""));
//Values are lost if this is used!
//PageUtil.FillLkpDropDown(ProtocolId, "ProtocolId", ViewState);
//populate look up and distinct value select boxes
PageUtil.FillLkpDropDown(MedTxType, "MedTxType", ViewState);
PageUtil.FillLkpDropDown(MedTxUnits, "MedUnits", ViewState);
PageUtil.FillLkpDropDown(MedTxRoute, "MedRoute", ViewState);
PageUtil.FillLkpDropDown(MedTxQuality, "DataQuality", ViewState);
//create arrays that populate combo boxes
Page.RegisterClientScriptBlock("MedTxInstitution", PageUtil.FillComboDropDown(MedTxInstitution.RefBy, "Institution"));
Page.RegisterClientScriptBlock("MedTxIndication", PageUtil.FillComboDropDown(MedTxIndication.RefBy, "Indication"));
Page.RegisterClientScriptBlock("MedTxIntent", PageUtil.FillComboDropDown(MedTxIntent.RefBy, "TxIntent"));
Page.RegisterClientScriptBlock("MedTxAgent", PageUtil.FillComboDropDown(MedTxAgent.RefBy, "MedTxAgent"));
Page.RegisterClientScriptBlock("MedTxSchedule", PageUtil.FillComboDropDown(MedTxSchedule.RefBy, "MedSchedule"));
Page.RegisterClientScriptBlock("MedTxDataSource", PageUtil.FillComboDropDown(MedTxDataSource.RefBy, "DataSource"));
string reqFieldArray = PageUtil.CreateValidationScript("'"+MedTxType.ClientID+"'");
Page.RegisterClientScriptBlock("requiredFieldArray", reqFieldArray);
PageUtil.AddCalendarFunction(MedTxDateTextCal, MedTxDateText);
PageUtil.AddFuzzyDateFunction(MedTxDateText, MedTxDate);
PageUtil.AddCalendarFunction(MedTxStopDateTextCal, MedTxStopDateText);
PageUtil.AddFuzzyDateFunction(MedTxStopDateText, MedTxStopDate);
/* prior to version 3.5
//selection of medTxAgent should populate med Tx Type. JS script defined on page
MedTxType.Attributes.Add("OnFocus", "populateMedTxType()");
//var fieldOneValue = dataForm.medTxAgent.value;
//var putItem = MedTxAgentOptionsArray[fieldOneValue];
//alert(putItem);
//dataForm.medTxType.value = putItem;
string strJScript = "<SCRIPT LANGUAGE=javascript><!-- \n";
strJScript += "function populateMedTxType(){\n";
strJScript += "var fieldOneValue = dataForm." + MedTxAgent.ClientID + ".value;\n";
strJScript += "var putItem = '';\n";
strJScript += "for(var i=0; i < MedTxAgentOptionsArray.length; i++){\n";
strJScript += " if(MedTxAgentOptionsArray[i][0] == fieldOneValue){\n";
strJScript += " putItem = MedTxAgentOptionsArray[i][1];\n";
strJScript += " }\n";
strJScript += "}\n";
strJScript += "dataForm." + MedTxType.ClientID + ".options[0] = new Option(putItem, putItem, false, true);\n";
strJScript += "}";
strJScript += "//--></SCRIPT>";
Page.RegisterStartupScript("xyz", strJScript);
*/
base.Page_Load(sender, e);
}
override protected object SaveViewState()
{
//add select and combo boxes to view state
PageUtil.AddSelectToViewState(ViewState,ProtocolId);
PageUtil.AddSelectToViewState(ViewState,MedTxType);
PageUtil.AddSelectToViewState(ViewState,MedTxUnits);
PageUtil.AddSelectToViewState(ViewState,MedTxRoute);
PageUtil.AddSelectToViewState(ViewState,MedTxQuality);
PageUtil.AddComboToViewState(ViewState,MedTxInstitution);
PageUtil.AddComboToViewState(ViewState,MedTxIntent);
PageUtil.AddComboToViewState(ViewState,MedTxIndication);
PageUtil.AddComboToViewState(ViewState,MedTxAgent);
PageUtil.AddComboToViewState(ViewState,MedTxSchedule);
PageUtil.AddComboToViewState(ViewState,MedTxDataSource);
return base.SaveViewState();
}
override public HtmlInputHidden GetPrimKeyField()
{
return MedicalTherapyId;
}
override protected DataEntryController GetController()
{
return new DataEntryController(new MedicalTherapyDa(), MedicalTherapy.MedicalTherapyId); //NOTE: fix args
}
override protected void SetDataEntryInfo()
{
this._tableInfo = "MedicalTherapy";
this._dataEntryTitle = "Medical Therapy";
}
override protected BizObject GetParams()
{
MedicalTherapy biz = new MedicalTherapy();
DataRow dr = biz.Tables[MedicalTherapy.Table_MedicalTherapy].NewRow();
if (!MedicalTherapyId.Value.Equals(""))
{
dr[MedicalTherapy.MedicalTherapyId] = MedicalTherapyId.Value;
}
//selects use: Request.Form[FieldName.UniqueID].ToString();
//dates use: PageUtil.ObjToDateTime(FieldName.Value);
//checkbox use: if(FieldName.Checked){dr[BizObject.FieldName] = 1;}
//Patient ID should = this.patientID
dr[MedicalTherapy.PatientId] = this.patientID;
dr[MedicalTherapy.ProtocolId] = PageUtil.ObjToInt(Request.Form[ProtocolId.UniqueID].ToString());
dr[MedicalTherapy.MedTxPending] = MedTxPending.Checked;
dr[MedicalTherapy.MedTxDateText] = Request.Form[MedTxDateText.UniqueID].ToString();
dr[MedicalTherapy.MedTxDate] = PageUtil.ObjToDateTime(MedTxDate.Value);
dr[MedicalTherapy.MedTxType] = Request.Form[MedTxType.UniqueID].ToString();
dr[MedicalTherapy.MedTxIntent] = Request.Form[MedTxIntent.UniqueID].ToString();
dr[MedicalTherapy.MedTxIndication] = Request.Form[MedTxIndication.UniqueID].ToString();
dr[MedicalTherapy.MedTxAgent] = Request.Form[MedTxAgent.UniqueID].ToString();
dr[MedicalTherapy.MedTxStopDateText] = Request.Form[MedTxStopDateText.UniqueID].ToString();
dr[MedicalTherapy.MedTxStopDate] = PageUtil.ObjToDateTime(MedTxStopDate.Value);
dr[MedicalTherapy.MedTxDose] = MedTxDose.Value;
dr[MedicalTherapy.MedTxTotalDose] = MedTxTotalDose.Value;
dr[MedicalTherapy.MedTxUnits] = Request.Form[MedTxUnits.UniqueID].ToString();
dr[MedicalTherapy.MedTxRoute] = Request.Form[MedTxRoute.UniqueID].ToString();
dr[MedicalTherapy.MedTxSchedule] = Request.Form[MedTxSchedule.UniqueID].ToString();
dr[MedicalTherapy.MedTxCycle] = MedTxCycle.Value;
dr[MedicalTherapy.MedTxWeek] = MedTxWeek.Value;
dr[MedicalTherapy.MedTxInstitution] = Request.Form[MedTxInstitution.UniqueID].ToString();
dr[MedicalTherapy.MedTxNotes] = MedTxNotes.Value;
dr[MedicalTherapy.MedTxDataSource] = Request.Form[MedTxDataSource.UniqueID].ToString();
dr[MedicalTherapy.MedTxQuality] = Request.Form[MedTxQuality.UniqueID].ToString();
AddBaseParams(dr);
biz.Tables[MedicalTherapy.Table_MedicalTherapy].Rows.Add(dr);
biz.AcceptChanges();
return biz;
}
protected override void SetFields(BizObject bz)
{
MedicalTherapy biz = (MedicalTherapy)bz;
DataRow dr = biz.Tables[MedicalTherapy.Table_MedicalTherapy].Rows[0];
//selects use: PageUtil.SelectDropDownItem(fieldIdName, dr[Object.FieldName]);
PageUtil.SelectDropDownItem(ProtocolId, dr[MedicalTherapy.ProtocolId]);
MedicalTherapyId.Value = dr[MedicalTherapy.MedicalTherapyId].ToString();
PageUtil.SetCheckBox(MedTxPending, dr[MedicalTherapy.MedTxPending]);
MedTxDateText.Value = dr[MedicalTherapy.MedTxDateText].ToString();
MedTxDate.Value = PageUtil.ObjToDateString(dr[MedicalTherapy.MedTxDate]);
PageUtil.SelectDropDownItem(MedTxType, dr[MedicalTherapy.MedTxType]);
MedTxIntent.Value = dr[MedicalTherapy.MedTxIntent].ToString();
MedTxIndication.Value = dr[MedicalTherapy.MedTxIndication].ToString();
MedTxAgent.Value = dr[MedicalTherapy.MedTxAgent].ToString();
MedTxStopDateText.Value = dr[MedicalTherapy.MedTxStopDateText].ToString();
MedTxStopDate.Value = PageUtil.ObjToDateString(dr[MedicalTherapy.MedTxStopDate]);
MedTxDose.Value = dr[MedicalTherapy.MedTxDose].ToString();
MedTxTotalDose.Value = dr[MedicalTherapy.MedTxTotalDose].ToString();
PageUtil.SelectDropDownItem(MedTxUnits, dr[MedicalTherapy.MedTxUnits]);
PageUtil.SelectDropDownItem(MedTxRoute, dr[MedicalTherapy.MedTxRoute]);
MedTxCycle.Value = dr[MedicalTherapy.MedTxCycle].ToString();
MedTxWeek.Value = dr[MedicalTherapy.MedTxWeek].ToString();
MedTxInstitution.Value = dr[MedicalTherapy.MedTxInstitution].ToString();
MedTxNotes.Value = dr[MedicalTherapy.MedTxNotes].ToString();
MedTxSchedule.Value = dr[MedicalTherapy.MedTxSchedule].ToString();
MedTxDataSource.Value = dr[MedicalTherapy.MedTxDataSource].ToString();
PageUtil.SelectDropDownItem(MedTxQuality, dr[MedicalTherapy.MedTxQuality]);
SetBaseFields(dr);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -