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

📄 categoriesform.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;
	using Caisis.UI.Core.Classes.CustomControls;
	

	public abstract class CategoriesForm : DataEntryControl
	{

		protected ComboBox CategoryFld;
		protected HtmlSelect CategoryType;
		protected HtmlInputHidden CategoryId;
		protected Caisis.UI.Core.Classes.PDLabel PdLabel1; //add all tool tip Ids

		override protected void Page_Load(object sender, System.EventArgs e)
		{
			//populate look up and distinct value select boxes
			
			PageUtil.FillLkpDropDown(CategoryType, "CategoryType", ViewState);

			//create arrays that populate combo boxes
			//Need to create select distinct, so this may not apply
			
			Page.RegisterClientScriptBlock("CategoryFld", this.FillCategoryComboDropDown(CategoryFld.RefBy));

			string reqFieldArray = PageUtil.CreateValidationScript("'"+CategoryFld.ClientID+"', '"+CategoryType.ClientID+"'");
			Page.RegisterClientScriptBlock("requiredFieldArray", reqFieldArray);

			base.Page_Load(sender, e);
		}
		
		//categories is an exception to filling combo box; uses distinct values and username as input parameter
		public string FillCategoryComboDropDown(string refById)
		{
			
			CategoryDa catDa = new CategoryDa();
			DataSet ds = catDa.GetDistinctCategories(System.Web.HttpContext.Current.User.Identity.Name);

			DataTable dt = new DataTable();

			
			dt = ds.Tables[0];
			
			string strJScript	 = "<SCRIPT LANGUAGE=javascript>\n";
			strJScript			+= "<!-- \n";
			strJScript			+= "var "+refById+"OptionsArray = new Array();\n";
			int i = 0;
			
			foreach(DataRow myRow in dt.Rows)
			{
				strJScript	+= refById+"OptionsArray["+i+"] = new Array('"+PageUtil.EscapeSingleQuotes(myRow["Category"].ToString())+"', '"+PageUtil.EscapeSingleQuotes(myRow["CategoryType"].ToString())+"');\n";		
				i++;
			}
			
			strJScript			+= "var "+refById+"OptionsArrayLength = "+refById+"OptionsArray.length;";
			strJScript			+= "\n//--></SCRIPT>";

			return strJScript;
		}

		override protected object SaveViewState()
		{
			//add select and combo boxes to view state
			
			PageUtil.AddSelectToViewState(ViewState,CategoryType);
			
			//PageUtil.AddComboToViewState(ViewState,CategoryFld);

			return base.SaveViewState();
		}

		override public HtmlInputHidden GetPrimKeyField()
		{
			return CategoryId;
		}

		override protected DataEntryController GetController()
		{
			return new CategoryController(new CategoryDa()); //NOTE: fix args
		}

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

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

			if (!CategoryId.Value.Equals(""))
			{
				dr[Category.CategoryId] = CategoryId.Value;
			}

			//below assignment only valid for text and textarea input.. need to modify for other form elements
			//selects use: Request.Form[FieldName.UniqueID].ToString();
			//dates use: PageUtil.ObjToDateTime(FieldName.Value);
			//checkbox use: if(SurgPending.Checked){dr[Surgery.SurgPending] = 1;}
			//Patient ID should = this.patientID
			
			dr[Category.PatientId] = this.patientID;
			 
			dr[Category.CategoryFld] = Request.Form[CategoryFld.UniqueID].ToString();
			dr[Category.CategoryType] = Request.Form[CategoryType.UniqueID].ToString();

			AddBaseParams(dr);
			biz.Tables[Category.Table_Categories].Rows.Add(dr);
			biz.AcceptChanges();
			return biz;

		}

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

			//below assignment good only for text and input fields, checkboxes, selects, radios need additional logic
			//selects use: PageUtil.SelectDropDownItem(fieldIdName, dr[Object.FieldName]);
			
			CategoryId.Value = dr[Category.CategoryId].ToString();
			CategoryFld.Value = dr[Category.CategoryFld].ToString();
			PageUtil.SelectDropDownItem(CategoryType, dr[Category.CategoryType]);

			SetBaseFields(dr);
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion
	}
}

⌨️ 快捷键说明

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