/// <summary> /// 得到一个对象实体 /// </summary> public RuRo.Model.BasedInfo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,PatientName,IPSeqNoText,PatientCardNo,SexFlag,Birthday,BloodTypeFlag,Phone,ContactPhone,ContactPerson,NativePlace,RegisterSeqNO,PatientID,RegisterID,InPatientID,ADDTIME from BasedInfo "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; RuRo.Model.BasedInfo model = new RuRo.Model.BasedInfo(); DataSet ds = DbHelperSQL_SY.QuerySY(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 得到一个对象实体 /// </summary> public RuRo.Model.BasedInfo DataRowToModel(DataRow row) { RuRo.Model.BasedInfo model = new RuRo.Model.BasedInfo(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["PatientName"] != null) { model.PatientName = row["PatientName"].ToString(); } if (row["IPSeqNoText"] != null) { model.IPSeqNoText = row["IPSeqNoText"].ToString(); } if (row["PatientCardNo"] != null) { model.PatientCardNo = row["PatientCardNo"].ToString(); } if (row["SexFlag"] != null) { model.SexFlag = row["SexFlag"].ToString(); } if (row["Birthday"] != null && row["Birthday"].ToString() != "") { model.Birthday = DateTime.Parse(row["Birthday"].ToString()); } if (row["BloodTypeFlag"] != null) { model.BloodTypeFlag = row["BloodTypeFlag"].ToString(); } if (row["Phone"] != null) { model.Phone = row["Phone"].ToString(); } if (row["ContactPhone"] != null) { model.ContactPhone = row["ContactPhone"].ToString(); } if (row["ContactPerson"] != null) { model.ContactPerson = row["ContactPerson"].ToString(); } if (row["NativePlace"] != null) { model.NativePlace = row["NativePlace"].ToString(); } if (row["RegisterSeqNO"] != null) { model.RegisterSeqNO = row["RegisterSeqNO"].ToString(); } if (row["PatientID"] != null && row["PatientID"].ToString() != "") { model.PatientID = int.Parse(row["PatientID"].ToString()); } if (row["RegisterID"] != null && row["RegisterID"].ToString() != "") { model.RegisterID = int.Parse(row["RegisterID"].ToString()); } if (row["InPatientID"] != null && row["InPatientID"].ToString() != "") { model.InPatientID = decimal.Parse(row["InPatientID"].ToString()); } if (row["ADDTIME"] != null && row["ADDTIME"].ToString() != "") { model.ADDTIME = DateTime.Parse(row["ADDTIME"].ToString()); } } return model; }
protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtPatientName.Text.Trim().Length==0) { strErr+="PatientName不能为空!\\n"; } if(this.txtIPSeqNoText.Text.Trim().Length==0) { strErr+="IPSeqNoText不能为空!\\n"; } if(this.txtPatientCardNo.Text.Trim().Length==0) { strErr+="PatientCardNo不能为空!\\n"; } if(this.txtSexFlag.Text.Trim().Length==0) { strErr+="SexFlag不能为空!\\n"; } if(!PageValidate.IsDateTime(txtBirthday.Text)) { strErr+="Birthday格式错误!\\n"; } if(this.txtBloodTypeFlag.Text.Trim().Length==0) { strErr+="BloodTypeFlag不能为空!\\n"; } if(this.txtPhone.Text.Trim().Length==0) { strErr+="Phone不能为空!\\n"; } if(this.txtContactPhone.Text.Trim().Length==0) { strErr+="ContactPhone不能为空!\\n"; } if(this.txtContactPerson.Text.Trim().Length==0) { strErr+="ContactPerson不能为空!\\n"; } if(this.txtNativePlace.Text.Trim().Length==0) { strErr+="NativePlace不能为空!\\n"; } if(this.txtRegisterSeqNO.Text.Trim().Length==0) { strErr+="RegisterSeqNO不能为空!\\n"; } if(!PageValidate.IsNumber(txtPatientID.Text)) { strErr+="PatientID格式错误!\\n"; } if(!PageValidate.IsNumber(txtRegisterID.Text)) { strErr+="RegisterID格式错误!\\n"; } if(!PageValidate.IsNumber(txtInPatientID.Text)) { strErr+="InPatientID格式错误!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } string PatientName=this.txtPatientName.Text; string IPSeqNoText=this.txtIPSeqNoText.Text; string PatientCardNo=this.txtPatientCardNo.Text; string SexFlag=this.txtSexFlag.Text; DateTime Birthday=DateTime.Parse(this.txtBirthday.Text); string BloodTypeFlag=this.txtBloodTypeFlag.Text; string Phone=this.txtPhone.Text; string ContactPhone=this.txtContactPhone.Text; string ContactPerson=this.txtContactPerson.Text; string NativePlace=this.txtNativePlace.Text; string RegisterSeqNO=this.txtRegisterSeqNO.Text; int PatientID=int.Parse(this.txtPatientID.Text); int RegisterID=int.Parse(this.txtRegisterID.Text); int InPatientID=int.Parse(this.txtInPatientID.Text); RuRo.Model.BasedInfo model=new RuRo.Model.BasedInfo(); model.PatientName=PatientName; model.IPSeqNoText=IPSeqNoText; model.PatientCardNo=PatientCardNo; model.SexFlag=SexFlag; model.Birthday=Birthday; model.BloodTypeFlag=BloodTypeFlag; model.Phone=Phone; model.ContactPhone=ContactPhone; model.ContactPerson=ContactPerson; model.NativePlace=NativePlace; model.RegisterSeqNO=RegisterSeqNO; model.PatientID=PatientID; model.RegisterID=RegisterID; model.InPatientID=InPatientID; RuRo.BLL.BasedInfo bll=new RuRo.BLL.BasedInfo(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }