⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protocolsform.ascx.cs

📁 医疗决策支持系统
💻 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;

	public abstract class ProtocolsForm : DataEntryControl
	{

		protected HtmlInputHidden ProtocolId;
		protected HtmlInputText ProtocolNum;
		protected HtmlInputText ProtocolTitle;
		protected HtmlInputText ProtocolPI;
		protected HtmlInputText ProtocolDept;
		protected HtmlInputText ProtocolAlias;
		protected HtmlTextArea ProtocolNotes;
	

		override protected void Page_Load(object sender, System.EventArgs e)
		{
			//array created holding required fields
			Page.RegisterArrayDeclaration("requiredFieldArray", "'" + ProtocolNum.ClientID + "', '" + ProtocolTitle.ClientID + "'");

			base.Page_Load(sender, e);
		}

		override protected object SaveViewState()
		{			
			return base.SaveViewState();
		}

		override public HtmlInputHidden GetPrimKeyField()
		{
			return ProtocolId;
		}


		// override so we don't redirect if there's no patient id
		override protected void OnInit(System.EventArgs e)  
		{
			if (Session["patientId"] != null && Session["patientId"].ToString() != "") 
			{
				patientID = (int)Session[SessionKey.PatientId];
			}

			//executes method in the control to set the page name and title
			this.SetDataEntryInfo();

			//view state enabled to retain data on edit button click
			this.EnableViewState = true;
			
			InitializeComponent();
		}

		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);
		}

		override protected DataEntryController GetController()
		{
			return new DataEntryController(new ProtocolDa(), Protocol.ProtocolId); //NOTE: fix args
		}

		override protected void SetDataEntryInfo()
		{
			this._tableInfo = "Protocols";
			this._dataEntryTitle = "";
		}

		override protected BizObject GetParams()
		{
			Protocol biz = new Protocol();
			DataRow dr = biz.Tables[Protocol.Table_Protocols].NewRow();

			if (!ProtocolId.Value.Equals(""))
			{
				dr[Protocol.ProtocolId] = ProtocolId.Value;
			}
			
			dr[Protocol.ProtocolNum] = ProtocolNum.Value;
			dr[Protocol.ProtocolTitle] = ProtocolTitle.Value;
			dr[Protocol.ProtocolAlias] = ProtocolAlias.Value;
			dr[Protocol.ProtocolPI] = ProtocolPI.Value;
			dr[Protocol.ProtocolDept] = ProtocolDept.Value;
			dr[Protocol.ProtocolNotes] = ProtocolNotes.Value;

			AddBaseParams(dr);
			biz.Tables[Protocol.Table_Protocols].Rows.Add(dr);
			biz.AcceptChanges();
			return biz;
		}

		protected override void SetFields(BizObject bz)
		{
			Protocol biz = (Protocol)bz;
			DataRow dr = biz.Tables[Protocol.Table_Protocols].Rows[0];

			//selects use: PageUtil.SelectDropDownItem(fieldIdName, dr[Object.FieldName]);
			
			ProtocolId.Value = dr[Protocol.ProtocolId].ToString();
			ProtocolNum.Value = dr[Protocol.ProtocolNum].ToString();
			ProtocolTitle.Value = dr[Protocol.ProtocolTitle].ToString();
			ProtocolAlias.Value = dr[Protocol.ProtocolAlias].ToString();
			ProtocolPI.Value 	= dr[Protocol.ProtocolPI].ToString();
			ProtocolDept.Value = dr[Protocol.ProtocolDept].ToString();
			ProtocolNotes.Value = dr[Protocol.ProtocolNotes].ToString();

			SetBaseFields(dr);


			// there's proabably a better place to put this - jf
			if (ProtocolId.Value != null && ProtocolId.Value.Length > 0)
			{
				this._dataEntryTitle = dr[Protocol.ProtocolNum].ToString(); // + " " + dr[Protocol.ProtocolTitle].ToString();
			}
		}



		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["primKey"] != null)  
			{
				primKey = Request.QueryString["primKey"];
			}
			
			
			if (!primKey.Equals(""))  
			{
				int keyValue = int.Parse(primKey);
				
				DataEntryController ct = this.GetController();
						
				BizObject bz = ct.GetRecord(keyValue);
				
				return bz;
			}

			return null;
		}

		protected override void InsertRowAndPopulateForm()
		{
			BizObject bz = this.GetParams();

			DataEntryController ct = GetController();
			
			ct.InsertRecord(bz);
			
			this.PopulateForm();
		}


		public override void SaveBtn_Click()
		{
			base.SaveBtn_Click ();

			if (!this._userError)
			{
				CacheManager.ResetDatasetSqlCache();
			}
		}

		public override void LockBtn_Click()
		{
			//base.LockBtn_Click ();
			
			BizObject bz= GetParams();
			DataEntryController ct = GetController();
			ct.LockRecord(bz);
			this.PopulateForm();
			
			if (!this._userError)
			{
				CacheManager.ResetDatasetSqlCache();
			}
		}

		/* see revised DeleteBtn_Click() method below - checks for associated record.  -jf 8/19/04
		public override void DeleteBtn_Click()
		{
			base.DeleteBtn_Click ();
			if (!this._userError)
			{
				CacheManager.ResetDatasetSqlCache();
			}
		}
		*/
		
		


		override public void DeleteBtn_Click()  
		{
			ProtocolDa da = new ProtocolDa();
			DataTable dt = da.ValidateProtocolDeletion(Convert.ToInt32(this.ProtocolId.Value)).Tables[0];

			if (dt.Rows.Count.Equals(0))
			{	
				base.DeleteBtn_Click();
				if (!this._userError)
				{
					CacheManager.ResetDatasetSqlCache();
				}
			}
			else
			{

				int y = dt.Rows.Count;
				
				string validationMessageString;
				validationMessageString = "<script> alert('";
				validationMessageString += "This protocol record cannot be deleted at this time.\\n\\n";
				validationMessageString += "The following tables contain data associated with this protocol:\\n";

				for (int i=0; i < y ; i ++ )
				{
					validationMessageString += "    " + dt.Rows[i]["TableName"].ToString() + ": " + dt.Rows[i]["TableCount"].ToString() + " Record";
					if (((int)dt.Rows[i]["TableCount"]) > 1)
					{
						validationMessageString += 	"s";
					}
					validationMessageString += "\\n";
				}

				validationMessageString += "\\nReferences to this protocol in the records listed above must\\nbe removed before this protocol can be deleted from the database.";
				validationMessageString += "');</script>";

				Page.RegisterClientScriptBlock("validationMessage", validationMessageString);
			}
		}




	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -