protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CheckAdminLevel("Civil"); //判断操作权限 action = DTRequest.GetQueryString("action"); if (action == "edit") { patient = BLL_Patient.GetPatientById(int.Parse(DTRequest.GetQueryString("id"))); } BindInfo(action); if (action != "edit") { this.txtCliBalance.Enabled = false; this.txtPhaBalance.Enabled = false; this.txtHelpMax.Text = ""; this.txtHelpNums.Text = ""; this.txtHelpScale.Text = ""; this.txtPhaMoney.Text = ""; this.txtCliMoney.Text = ""; return; } //绑定救助对象 BindPatientById(); } }
public void AddPatientTest() { Patient patient = new Patient(); // TODO: 初始化为适当的值 patient.Name = "zhangxiao"; int expected = 0; // TODO: 初始化为适当的值 int actual; actual = BLL_Patient.AddPatient(patient); Assert.AreEqual(expected, actual); //Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> /// 导出当前页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOutputCuttentPage_Click(object sender, EventArgs e) { List<Med_Model.Patient> listPatient = new List<Med_Model.Patient>(); Med_Model.Patient patient = new Med_Model.Patient(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); patient = BLL_Patient.GetPatientById(id); listPatient.Add(patient); patient = null; } NPOIHelper.DataTable3Excel(listPatient.ToADOTable(), "当前页救助对象列表", GetExportColumn()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CheckAdminLevel("DrugStore");//判断操作权限 listPurDrug = Session[GetAdminInfo().UserName] as List<Med_Model.PurDrug>;//读取session中刚刚的购药记录 if (listPurDrug != null) { patient = Med_BLL.BLL_Patient.GetPatientById(listPurDrug[0].PatientId); this.rptList.DataSource = listPurDrug; this.rptList.DataBind(); Session[GetAdminInfo().UserName] = null; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string actionType = DTRequest.GetQueryString("action"); int inHosId = Convert.ToInt32(DTRequest.GetQueryString("InhosId")); Hashtable hashTable = BLL_InHos.GetHospitalSettleInfomrationByPatientIdAndHosId(inHosId); Patient = hashTable["Patient"] as Patient; InHospital = hashTable["InHospital"] as InHospital; //helpedFee = Convert.ToDecimal((hashTable["HelpedItems"] as Hashtable)["HelpedFee"]); helpedNums = Convert.ToInt32((hashTable["HelpedItems"] as Hashtable)["HelpedNums"]); listDept = BLL_Department.GetDepartmentList(" TypeId=1 or TypeId=6 or TypeId=5 or TypeId=2 "); //获取,医院 患者类别 乡镇 的部门数据 } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CheckAdminLevel("Hospital");//判断操作权限 int patientId = Convert.ToInt32(DTRequest.GetQueryString("patientId")); hashTable = BLL_InHos.GetHospitalSettleInfomrationByPatientId(patientId); Patient = hashTable["Patient"] as Patient; InHospital = hashTable["InHospital"] as InHospital; helpedFee = Convert.ToDecimal(((hashTable["HelpedItems"] as Hashtable)[patientId] as Hashtable)["HelpedFee"]); helpedNums = Convert.ToInt32(((hashTable["HelpedItems"] as Hashtable)[patientId] as Hashtable)["HelpedNums"]); listDept = BLL_Department.GetDepartmentList(" TypeId=1 or TypeId=6 or TypeId=5 or TypeId=2 "); //获取,医院 患者类别 乡镇 的部门数据 this.hiddenHelpDetails.Value = BLL_HelpStandard.SelectHelpStandardById(Patient.HelpClass).HelpDetails; DataTable table = BLL_InHos.GetHelpedTotalMoney(" and B.State=8 and A.Id=" + patientId); } }
/// <summary> /// 更新一条救助对象信息 /// </summary> /// <param name="patient"></param> /// <returns> /// 成功:true /// 失败:false /// </returns> public bool UpdataePatient(Patient patient) { bool result = false; try { StringBuilder strSql = new StringBuilder(); strSql.Append(" update T_Med_Patient set "); strSql.Append(" Name=@Name, "); strSql.Append(" Sex=@Sex, "); strSql.Append(" Tel=@Tel, "); strSql.Append(" HomeId=@HomeId, "); strSql.Append(" HomeDetails=@HomeDetails, "); strSql.Append(" HelpId=@HelpId, "); strSql.Append(" PatientClass=@PatientClass, "); strSql.Append(" HelpClass=@HelpClass, "); strSql.Append(" HelpNums=@HelpNums, "); strSql.Append(" HelpScale=@HelpScale, "); strSql.Append(" HelpMax=@HelpMax, "); strSql.Append(" CliMoney=@CliMoney, "); strSql.Append(" CliBalance=@CliBalance, "); strSql.Append(" PhaMoney=@PhaMoney, "); strSql.Append(" PhaBalance=@PhaBalance, "); strSql.Append(" IsHos=@IsHos, "); strSql.Append(" HosId=@HosId,"); strSql.Append(" IsLock=@IsLock, "); strSql.Append(" AddTime=@AddTime, "); strSql.Append(" InHosId=@InHosId "); strSql.Append(" where IdCard=@IdCard "); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar,50), new SqlParameter("@Sex", SqlDbType.NVarChar,10), new SqlParameter("@Tel", SqlDbType.NVarChar,15), new SqlParameter("@HomeId", SqlDbType.Int,4), new SqlParameter("@HomeDetails", SqlDbType.NVarChar,100), new SqlParameter("@HelpId", SqlDbType.NVarChar,50), new SqlParameter("@PatientClass", SqlDbType.Int,4), new SqlParameter("@HelpClass", SqlDbType.Int,4), new SqlParameter("@HelpNums", SqlDbType.Int,4), new SqlParameter("@HelpScale", SqlDbType.NVarChar,20), new SqlParameter("@HelpMax", SqlDbType.Decimal), new SqlParameter("@CliMoney", SqlDbType.Decimal), new SqlParameter("@CliBalance", SqlDbType.Decimal), new SqlParameter("@PhaMoney", SqlDbType.Decimal), new SqlParameter("@PhaBalance", SqlDbType.Decimal), new SqlParameter("@IsHos", SqlDbType.Int,2), new SqlParameter("@HosId", SqlDbType.Int,4), new SqlParameter("@IsLock", SqlDbType.Int,2), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@InHosId", SqlDbType.Int), new SqlParameter("@IdCard", SqlDbType.NVarChar,20) }; parameters[0].Value = patient.Name; parameters[1].Value = patient.Sex; parameters[2].Value = patient.Tel; parameters[3].Value = patient.HomeId; parameters[4].Value = patient.HomeDetails; parameters[5].Value = patient.HelpId; parameters[6].Value = patient.PatientClass; parameters[7].Value = patient.HelpClass; parameters[8].Value = patient.HelpNums; parameters[9].Value = patient.HelpScale; parameters[10].Value = patient.HelpMax; parameters[11].Value = patient.CliMoney; parameters[12].Value = patient.CliBalance; parameters[13].Value = patient.PhaMoney; parameters[14].Value = patient.PhaBalance; parameters[15].Value = patient.IsHos; parameters[16].Value = patient.HosId; parameters[17].Value = patient.IsLock; parameters[18].Value = patient.AddTime; parameters[19].Value = patient.InHosId; parameters[20].Value = patient.IdCard; if (SqlHelper.ExecuteNonQuery(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters) > 0) //更改成功 影响条数为1 { result = true; //更新成功设置为true } } catch (Exception e) { Log4Net.LogWrite("err", "Med_DAL:DAL_Patient//UpdataePatient" + e.Message); //发生异常,记录 } return result; }
/// <summary> /// 添加救助对象 /// </summary> /// <param name="patient">救助对象实体 model</param> /// <returns> /// 成功返回刚刚插入数据库的救助对象编号 /// 失败 返回0 /// </returns> public int AddPatient(Patient patient) { int result = 0; try { StringBuilder strSql = new StringBuilder(); strSql.Append(" insert into T_Med_Patient ("); strSql.Append(" Name,Sex,IdCard,Birthday,Tel,HomeId,HomeDetails,HelpId,PatientClass,HelpClass,HelpNums,HelpScale,"); strSql.Append(" HelpMax,CliMoney,CliBalance,PhaMoney,PhaBalance,IsHos,HosId,IsLock,AddTime,InHosId)"); strSql.Append(" values("); strSql.Append(" @Name,@Sex,@IdCard,@Birthday,@Tel,@HomeId,@HomeDetails,@HelpId,@PatientClass,@HelpClass,@HelpNums,@HelpScale,"); strSql.Append(" @HelpMax,@CliMoney,@CliBalance,@PhaMoney,@PhaBalance,@IsHos,@HosId,@IsLock,@AddTime,@InHosId) "); strSql.Append(" ;select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar,50), new SqlParameter("@Sex", SqlDbType.NVarChar,10), new SqlParameter("@IdCard", SqlDbType.NVarChar,20), new SqlParameter("@Birthday", SqlDbType.NVarChar,10), new SqlParameter("@Tel", SqlDbType.NVarChar,15), new SqlParameter("@HomeId", SqlDbType.Int,4), new SqlParameter("@HomeDetails", SqlDbType.NVarChar,100), new SqlParameter("@HelpId", SqlDbType.NVarChar,50), new SqlParameter("@PatientClass", SqlDbType.Int,4), new SqlParameter("@HelpClass", SqlDbType.Int,4), new SqlParameter("@HelpNums", SqlDbType.Int,4), new SqlParameter("@HelpScale", SqlDbType.NVarChar,20), new SqlParameter("@HelpMax", SqlDbType.Decimal), new SqlParameter("@CliMoney", SqlDbType.Decimal), new SqlParameter("@CliBalance", SqlDbType.Decimal), new SqlParameter("@PhaMoney", SqlDbType.Decimal), new SqlParameter("@PhaBalance", SqlDbType.Decimal), new SqlParameter("@IsHos", SqlDbType.Int,2), new SqlParameter("@HosId", SqlDbType.Int,4), new SqlParameter("@IsLock", SqlDbType.Int,2), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@InHosId", SqlDbType.Int) }; parameters[0].Value = patient.Name; parameters[1].Value = patient.Sex; parameters[2].Value = patient.IdCard; parameters[3].Value = patient.Birthday; parameters[4].Value = patient.Tel; parameters[5].Value = patient.HomeId; parameters[6].Value = patient.HomeDetails; parameters[7].Value = patient.HelpId; parameters[8].Value = patient.PatientClass; parameters[9].Value = patient.HelpClass; parameters[10].Value = patient.HelpNums; parameters[11].Value = patient.HelpScale; parameters[12].Value = patient.HelpMax; parameters[13].Value = patient.CliMoney; parameters[14].Value = patient.CliBalance; parameters[15].Value = patient.PhaMoney; parameters[16].Value = patient.PhaBalance; parameters[17].Value = patient.IsHos; parameters[18].Value = patient.HosId; parameters[19].Value = patient.IsLock; parameters[20].Value = patient.AddTime; parameters[21].Value = patient.InHosId; object obj = SqlHelper.ExecuteScalar(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters); if (obj != null) { result = Convert.ToInt32(obj); } } catch (Exception e) { Log4Net.LogWrite("err", "Med_DAL:DAL_Patient//AddPatient" + e.Message); //发生异常,记录 } return result; }
/// <summary> /// 根据救助对象身份证号得到相应实体model信息 /// </summary> /// <param name="idCard">救助对象身份证号</param> /// <returns></returns> public Patient SelectPatientByIdCard(string idCard) { Patient patient = new Patient(); try { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,Name,Sex, IdCard,Birthday,Tel,HomeId,HomeDetails,HelpId,PatientClass,HelpClass,HelpNums,HelpScale,HelpMax,CliMoney,CliBalance,PhaMoney,PhaBalance,IsHos,HosId,AddTime,InHosId from T_Med_Patient"); strSql.Append(" where IsLock=0 and IdCard=@IdCard"); SqlParameter[] parameters = { new SqlParameter("@IdCard", SqlDbType.NVarChar,30)}; parameters[0].Value = idCard; patient = SqlHelper.ExecuteDataset(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters).Tables[0].ToList<Patient>()[0]; //当前List 中 只有一个Patient 取出 } catch (Exception e) { Log4Net.LogWrite("err", "Med_DAL:DAL_Patient//SelectPatientByIdCard" + e.Message); //发生异常,记录 } return patient; }
/// <summary> /// 添加救助对象 /// </summary> /// <param name="patient">救助对象实体 model</param> /// <returns> /// 成功返回刚刚插入数据库的救助对象编号 /// 失败 返回0 /// </returns> public static int AddPatient(Patient patient) { return DalPatient.AddPatient(patient); }
/// <summary> /// 更新救助对象信息 /// </summary> /// <param name="patient"></param> /// <returns></returns> public static bool UpdatePatient(Patient patient) { return DalPatient.UpdataePatient(patient); }
/// <summary> /// 管理救助对象 添加or 修改 /// </summary> /// <param name="type">修改or 添加</param> /// <returns></returns> private bool AdminPatient(string type) { var patient = new Med_Model.Patient(); CheckTheData(ref patient, action); //检查数据合法性 if (type == "add") { //如果添加救助对象成功 同时成功记录操作日志的话 返回true return (BLL_Patient.AddPatient(patient) > 0) && (AddSysLog(CommonEnum.ActionType.Add.ToString(), "添加救助对象") ? true : false); } if (type == "edit") //如果是修改事件 { //如果更新救助对象信息成功,同时添加日志成功 返回true 否则返回false return (BLL_Patient.UpdatePatient(patient)) && (AddSysLog(CommonEnum.ActionType.Update.ToString(), "修改救助对象信息") ? true : false); } return false; //目前只有添加 修改两种操作,以后可能扩展 }