using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CallCenterApi.DB; using System.Data; using System.Data.SqlClient; namespace CallCenterApi.DAL { public class T_Sys_Patirnt { public T_Sys_Patirnt() { } public CallCenterApi.Model.T_Sys_Patirnt DataRowToModel(DataRow row) { CallCenterApi.Model.T_Sys_Patirnt model = new Model.T_Sys_Patirnt(); if (row != null) { if (row["PatirntID"] != null && row["PatirntID"].ToString() != "") { model.PatirntID = int.Parse(row["PatirntID"].ToString()); } if (row["Department"] != null) { model.Department = row["Department"].ToString(); } if (row["PatirntName"] != null) { model.PatirntName = row["PatirntName"].ToString(); } if (row["PTime"] != null && row["PTime"].ToString() != "") { model.PTime = DateTime.Parse(row["PTime"].ToString()); } if (row["Phone"] != null) { model.Phone = row["Phone"].ToString(); } if (row["Sex"] != null && row["Sex"].ToString() != "") { model.Sex = int.Parse(row["Sex"].ToString()); } if (row["Age"] != null && row["Age"].ToString() != "") { model.Age = int.Parse(row["Age"].ToString()); } if (row["Diagnosis"] != null) { model.Diagnosis = row["Diagnosis"].ToString(); } if (row["Doctor"] != null) { model.Doctor = row["Doctor"].ToString(); } if (row["FollowUp"] != null) { model.FollowUp = int.Parse(row["FollowUp"].ToString()); } if (row["DeleteFlag"] != null) { model.DeleteFlag = int.Parse(row["DeleteFlag"].ToString()); } if (row["Satisfaction"] != null) { if (!string.IsNullOrEmpty(row["Satisfaction"].ToString())) { model.Satisfaction = int.Parse(row["Satisfaction"].ToString()); } } if (row["Note"] != null) { model.Note = row["Note"].ToString(); } if (row["FollowUpTime"] != null && row["FollowUpTime"].ToString() != "") { model.PTime = DateTime.Parse(row["FollowUpTime"].ToString()); } if (row["CallId"] != null) { model.CallId =Convert.ToInt32(row["CallId"].ToString()); } if (row["ActionID"] != null) { if (!string.IsNullOrEmpty(row["ActionID"].ToString())) { model.ActionID = Convert.ToInt32(row["ActionID"].ToString()); } } } return model; } public CallCenterApi.Model.T_Sys_Patirnt GetModel(int PatirntID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from T_Sys_Patirnt "); strSql.Append(" where PatirntID=@PatirntID"); SqlParameter[] parameters = { new SqlParameter("@PatirntID", SqlDbType.Int,4) }; parameters[0].Value = PatirntID; CallCenterApi.Model.T_Sys_Patirnt model = new CallCenterApi.Model.T_Sys_Patirnt(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } } } }