📄 physicianform.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 PhysiciansForm : DataEntryControl
{
protected ComboBox PhSpecialty;
protected HtmlSelect PhLevel;
protected HtmlSelect PhTitle;
protected HtmlInputText PhFirstName;
protected HtmlInputText PhMiddleName;
protected HtmlInputText PhLastName;
protected HtmlSelect PhSuffix;
protected HtmlInputText PhAddress1;
protected HtmlInputText PhAddress2;
protected HtmlInputText PhCity;
protected ComboBox PhState;
protected HtmlInputText PhPostalCode;
protected HtmlInputText PhCountry;
protected HtmlInputText PhWorkPhone;
protected HtmlInputText PhFax;
protected HtmlInputText PhEmail;
protected ComboBox PhInstitution;
protected HtmlInputCheckBox PhDoNotContact;
protected HtmlTextArea PhNotes;
protected HtmlInputHidden PhysicianId;
protected int physId = 0;
override protected void Page_Load(object sender, System.EventArgs e)
{
//populate look up and distinct value select boxes
PageUtil.FillLkpDropDown(PhLevel, "PhysicianLevel", ViewState);
PageUtil.FillLkpDropDown(PhTitle, "Title", ViewState);
PageUtil.FillLkpDropDown(PhSuffix, "Suffix", ViewState);
//create arrays that populate combo boxes
Page.RegisterClientScriptBlock("PhSpecialty", PageUtil.FillComboDropDown(PhSpecialty.RefBy, "PhSpecialty"));
Page.RegisterClientScriptBlock("PhState", PageUtil.FillComboDropDown(PhState.RefBy, "State"));
Page.RegisterClientScriptBlock("PhInstitution", PageUtil.FillComboDropDown(PhInstitution.RefBy, "Institution"));
//array created holding required fields
Page.RegisterArrayDeclaration("requiredFieldArray","'"+PhLastName.ClientID+"'");
base.Page_Load(sender, e);
}
override protected object SaveViewState()
{
//add select and combo boxes to view state
PageUtil.AddSelectToViewState(ViewState,PhLevel);
PageUtil.AddSelectToViewState(ViewState,PhTitle);
PageUtil.AddSelectToViewState(ViewState,PhSuffix);
PageUtil.AddComboToViewState(ViewState,PhSpecialty);
PageUtil.AddComboToViewState(ViewState,PhState);
PageUtil.AddComboToViewState(ViewState,PhInstitution);
return base.SaveViewState();
}
override public HtmlInputHidden GetPrimKeyField()
{
return PhysicianId;
}
override protected DataEntryController GetController()
{
return new DataEntryController(new PhysicianDa(), Physician.PhysicianId); //NOTE: fix args
}
override protected void SetDataEntryInfo()
{
this._tableInfo = "Physicians";
this._dataEntryTitle = "";
}
override protected BizObject GetParams()
{
Physician biz = new Physician();
DataRow dr = biz.Tables[Physician.Table_Physicians].NewRow();
if (!PhysicianId.Value.Equals(""))
{
dr[Physician.PhysicianId] = PhysicianId.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[Physician.PhSpecialty] = Request.Form[PhSpecialty.UniqueID].ToString();
if (Request.Form[PhLevel.UniqueID] != null)
{
dr[Physician.PhLevel] = Request.Form[PhLevel.UniqueID].ToString();
}
if (Request.Form[PhTitle.UniqueID] != null)
{
dr[Physician.PhTitle] = Request.Form[PhTitle.UniqueID].ToString();
}
dr[Physician.PhFirstName] = PhFirstName.Value;
dr[Physician.PhMiddleName] = PhMiddleName.Value;
dr[Physician.PhLastName] = PhLastName.Value;
if (Request.Form[PhSuffix.UniqueID] != null)
{
dr[Physician.PhSuffix] = Request.Form[PhSuffix.UniqueID].ToString();
}
dr[Physician.PhAddress1] = PhAddress1.Value;
dr[Physician.PhAddress2] = PhAddress2.Value;
dr[Physician.PhCity] = PhCity.Value;
dr[Physician.PhState] = Request.Form[PhState.UniqueID].ToString();
dr[Physician.PhPostalCode] = PhPostalCode.Value;
dr[Physician.PhCountry] = PhCountry.Value;
dr[Physician.PhWorkPhone] = PhWorkPhone.Value;
dr[Physician.PhFax] = PhFax.Value;
dr[Physician.PhEmail] = PhEmail.Value;
dr[Physician.PhInstitution] = Request.Form[PhInstitution.UniqueID].ToString();
dr[Physician.PhDoNotContact] = PhDoNotContact.Checked;
dr[Physician.PhNotes] = PhNotes.Value;
AddBaseParams(dr);
biz.Tables[Physician.Table_Physicians].Rows.Add(dr);
biz.AcceptChanges();
return biz;
}
protected override void SetFields(BizObject bz)
{
Physician biz = (Physician)bz;
DataRow dr = biz.Tables[Physician.Table_Physicians].Rows[0];
//selects use: PageUtil.SelectDropDownItem(fieldIdName, dr[Object.FieldName]);
PhysicianId.Value = dr[Physician.PhysicianId].ToString();
PhSpecialty.Value = dr[Physician.PhSpecialty].ToString();
PageUtil.SelectDropDownItem(PhLevel, dr[Physician.PhLevel]);
PageUtil.SelectDropDownItem(PhTitle, dr[Physician.PhTitle]);
PhFirstName.Value = dr[Physician.PhFirstName].ToString();
PhMiddleName.Value = dr[Physician.PhMiddleName].ToString();
PhLastName.Value = dr[Physician.PhLastName].ToString();
PageUtil.SelectDropDownItem(PhSuffix, dr[Physician.PhSuffix]);
PhAddress1.Value = dr[Physician.PhAddress1].ToString();
PhAddress2.Value = dr[Physician.PhAddress2].ToString();
PhCity.Value = dr[Physician.PhCity].ToString();
PhState.Value = dr[Physician.PhState].ToString();
PhPostalCode.Value = dr[Physician.PhPostalCode].ToString();
PhCountry.Value = dr[Physician.PhCountry].ToString();
PhWorkPhone.Value = dr[Physician.PhWorkPhone].ToString();
PhFax.Value = dr[Physician.PhFax].ToString();
PhEmail.Value = dr[Physician.PhEmail].ToString();
PhInstitution.Value = dr[Physician.PhInstitution].ToString();
PageUtil.SetCheckBox(PhDoNotContact, dr[Physician.PhDoNotContact]);
PhNotes.Value = dr[Physician.PhNotes].ToString();
SetBaseFields(dr);
// there's proabably a better place to put this - jf
if (PhysicianId.Value != null && PhysicianId.Value.Length > 0)
{
this._dataEntryTitle = dr[Physician.PhFirstName].ToString() + " " + dr[Physician.PhLastName].ToString();
}
}
public int PhysId
{
get
{
return physId;
}
set
{
physId = value;
}
}
override protected BizObject GetRecord()
{
string primKey = "";
string formPrimKey = (this.GetPrimKeyField()).Value;
if (formPrimKey != null && !formPrimKey.Equals(""))
{
primKey = formPrimKey;
}
else if (Request.QueryString.HasKeys() && Request.QueryString.Get("primKey") != null)
{
primKey = Request.QueryString.Get("primKey");
}
/* else if (Request.Form.HasKeys() && Request.Form["PhysicianId"] != null)
{
primKey = Request.Form["PhysicianId"];
}
*/
/* else if (physId != null)
{
primKey = physId;
}
*/
if (!primKey.Equals(""))
{
int keyValue = int.Parse(primKey);
DataEntryController ct = this.GetController();
BizObject bz = ct.GetRecord(keyValue);
return bz;
}
return null;
}
//the following methods are used to refresh teh Dataset SQL cache following changes to Physician tables
public override void SaveBtn_Click()
{
base.SaveBtn_Click ();
if (!this._userError)
{
CacheManager.ResetDatasetSqlCache();
}
}
public override void DeleteBtn_Click()
{
base.DeleteBtn_Click ();
if (!this._userError)
{
CacheManager.ResetDatasetSqlCache();
}
}
public override void LockBtn_Click()
{
base.LockBtn_Click ();
if (!this._userError)
{
CacheManager.ResetDatasetSqlCache();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -