using System; using System.Data; using System.Data.SqlClient; using System.Collections; using System.Collections.Generic; using AIMSModel; using AIMSObjectQuery; using System.Reflection; using System.Text; namespace AIMSDAL { internal partial class DPatientKind { public static void Add(PatientKind PatientKindObj) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [PatientKind]("); strSql.Append("No,Name,HelpCode,IsValid,OperatorNo,OperatorName,OperateDate"); strSql.Append(")"); strSql.Append(" values ("); strSql.Append("'" + PatientKindObj.No + "',"); strSql.Append("'" + PatientKindObj.Name + "',"); strSql.Append("'" + PatientKindObj.HelpCode + "',"); strSql.Append("" + PatientKindObj.IsValid + ","); strSql.Append("'" + PatientKindObj.OperatorNo + "',"); strSql.Append("'" + PatientKindObj.OperatorName + "',"); strSql.Append("'" + PatientKindObj.OperateDate + "'"); strSql.Append(")"); HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString()); } public static PatientKind GetModel(int Id) { PatientKind PatientKindObj = new PatientKind(); StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append("Id,No,Name,HelpCode,IsValid,OperatorNo,OperatorName,OperateDate "); strSql.Append(" from PatientKind "); strSql.Append(" where Id=" + Id + ""); DataSet ds = HelperDB.DbHelperSQL.GetDataSet(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { PatientKindObj.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } PatientKindObj.No = ds.Tables[0].Rows[0]["No"].ToString(); PatientKindObj.Name = ds.Tables[0].Rows[0]["Name"].ToString(); PatientKindObj.HelpCode = ds.Tables[0].Rows[0]["HelpCode"].ToString(); if (ds.Tables[0].Rows[0]["IsValid"].ToString() != "") { PatientKindObj.IsValid = int.Parse(ds.Tables[0].Rows[0]["IsValid"].ToString()); } PatientKindObj.OperatorNo = ds.Tables[0].Rows[0]["OperatorNo"].ToString(); PatientKindObj.OperatorName = ds.Tables[0].Rows[0]["OperatorName"].ToString(); if (ds.Tables[0].Rows[0]["OperateDate"].ToString() != "") { PatientKindObj.OperateDate = DateTime.Parse(ds.Tables[0].Rows[0]["OperateDate"].ToString()); } } return PatientKindObj; } public static DataTable GetDataTable(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select [Id],[No],[Name],[HelpCode],CASE IsValid WHEN 1 THEN '有效' WHEN 0 THEN '无效' END AS IsValid"); strSql.Append(" FROM PatientKind "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString()); } public static DataTable GetDataTable() { StringBuilder strSql = new StringBuilder(); strSql.Append("select [Id],[No],[Name],[HelpCode],CASE IsValid WHEN 1 THEN '有效' WHEN 0 THEN '无效' END AS IsValid"); strSql.Append(" FROM PatientKind "); return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString()); } public static bool IsExit(string No) { string strSql = "select * from PatientKind where name ='" + No + "'"; DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql); if (dt.Rows.Count > 0) { return true; } else { return false; } } public static bool NameExit(string Name) { string strSql = "select * from PatientKind where name ='" + Name + "'"; DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql); if (dt.Rows.Count > 0) { return true; } else { return false; } } } }