/// <summary> /// 点击确定按钮执行的方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Maticsoft.BLL.record_Consultation bll = new Maticsoft.BLL.record_Consultation(); Maticsoft.Model.record_Consultation model = bll.GetModel(ConsultationID); if (model == null) { model = new Maticsoft.Model.record_Consultation(); model.C_UserID = UserID; } model.C_Cause = (string)Common.sink(this.C_Cause.UniqueID, MethodType.Post, 0, 0, DataType.Str); model.C_Comments = (string)Common.sink(this.C_Comments.UniqueID, MethodType.Post, 0, 0, DataType.Str); model.C_Time = (DateTime)Common.sink(this.C_Time.UniqueID, MethodType.Post, 0, 0, DataType.Dat); model.C_Dortor = UserData.GetUserDate.UserID; //当前登录的医生id switch (CMD) { case "New": CMD_Txt = "增加"; model.ConsultationID = bll.Add(model); break; case "Edit": CMD_Txt = "修改"; bll.Update(model); break; } All_Title_Txt = CMD_Txt + App_Txt; EventMessage.MessageBox(1, "操作成功", string.Format("{1}ID({0})成功!", model.ConsultationID, All_Title_Txt), Icon_Type.OK, Common.GetHomeBaseUrl("ConsultationList.aspx?UserID=" + model.C_UserID)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.record_Consultation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into record_Consultation("); strSql.Append("C_UserID,C_Cause,C_Comments,C_InstitutionDoctor,C_Time)"); strSql.Append(" values ("); strSql.Append("@C_UserID,@C_Cause,@C_Comments,@C_InstitutionDoctor,@C_Time)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@C_UserID", SqlDbType.Int, 4), new SqlParameter("@C_Cause", SqlDbType.Text), new SqlParameter("@C_Comments", SqlDbType.Text), new SqlParameter("@C_InstitutionDoctor", SqlDbType.Text), new SqlParameter("@C_Time", SqlDbType.DateTime) }; parameters[0].Value = model.C_UserID; parameters[1].Value = model.C_Cause; parameters[2].Value = model.C_Comments; parameters[3].Value = model.C_InstitutionDoctor; parameters[4].Value = model.C_Time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.record_Consultation DataRowToModel(DataRow row) { Maticsoft.Model.record_Consultation model=new Maticsoft.Model.record_Consultation(); if (row != null) { if(row["ConsultationID"]!=null && row["ConsultationID"].ToString()!="") { model.ConsultationID=int.Parse(row["ConsultationID"].ToString()); } if(row["C_UserID"]!=null && row["C_UserID"].ToString()!="") { model.C_UserID=int.Parse(row["C_UserID"].ToString()); } if(row["C_Cause"]!=null) { model.C_Cause=row["C_Cause"].ToString(); } if(row["C_Comments"]!=null) { model.C_Comments=row["C_Comments"].ToString(); } if(row["C_InstitutionDoctor"]!=null) { model.C_InstitutionDoctor=row["C_InstitutionDoctor"].ToString(); } if(row["C_Time"]!=null && row["C_Time"].ToString()!="") { model.C_Time=DateTime.Parse(row["C_Time"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.record_Consultation DataRowToModel(DataRow row) { Maticsoft.Model.record_Consultation model = new Maticsoft.Model.record_Consultation(); if (row != null) { if (row["ConsultationID"] != null && row["ConsultationID"].ToString() != "") { model.ConsultationID = int.Parse(row["ConsultationID"].ToString()); } if (row["C_UserID"] != null && row["C_UserID"].ToString() != "") { model.C_UserID = int.Parse(row["C_UserID"].ToString()); } if (row["C_Cause"] != null) { model.C_Cause = row["C_Cause"].ToString(); } if (row["C_Comments"] != null) { model.C_Comments = row["C_Comments"].ToString(); } if (row["C_InstitutionDoctor"] != null) { model.C_InstitutionDoctor = row["C_InstitutionDoctor"].ToString(); } if (row["C_Time"] != null && row["C_Time"].ToString() != "") { model.C_Time = DateTime.Parse(row["C_Time"].ToString()); } } return(model); }
private void ShowInfo(int ConsultationID) { Maticsoft.BLL.record_Consultation bll = new Maticsoft.BLL.record_Consultation(); Maticsoft.Model.record_Consultation model = bll.GetModel(ConsultationID); this.lblConsultationID.Text = model.ConsultationID.ToString(); this.lblC_UserID.Text = model.C_UserID.ToString(); this.lblC_Cause.Text = model.C_Cause; this.lblC_Comments.Text = model.C_Comments; this.lblC_InstitutionDoctor.Text = model.C_InstitutionDoctor; this.lblC_Time.Text = model.C_Time.ToString(); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtC_UserID.Text)) { strErr += "用户ID格式错误!\\n"; } if (this.txtC_Cause.Text.Trim().Length == 0) { strErr += "会诊原因不能为空!\\n"; } if (this.txtC_Comments.Text.Trim().Length == 0) { strErr += "会诊意见不能为空!\\n"; } if (this.txtC_InstitutionDoctor.Text.Trim().Length == 0) { strErr += "会诊医生及其所在机构名称不能为空!\\n"; } if (!PageValidate.IsDateTime(txtC_Time.Text)) { strErr += "会诊日期格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int ConsultationID = int.Parse(this.lblConsultationID.Text); int C_UserID = int.Parse(this.txtC_UserID.Text); string C_Cause = this.txtC_Cause.Text; string C_Comments = this.txtC_Comments.Text; string C_InstitutionDoctor = this.txtC_InstitutionDoctor.Text; DateTime C_Time = DateTime.Parse(this.txtC_Time.Text); Maticsoft.Model.record_Consultation model = new Maticsoft.Model.record_Consultation(); model.ConsultationID = ConsultationID; model.C_UserID = C_UserID; model.C_Cause = C_Cause; model.C_Comments = C_Comments; model.C_InstitutionDoctor = C_InstitutionDoctor; model.C_Time = C_Time; Maticsoft.BLL.record_Consultation bll = new Maticsoft.BLL.record_Consultation(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtC_UserID.Text)) { strErr+="用户ID格式错误!\\n"; } if(this.txtC_Cause.Text.Trim().Length==0) { strErr+="会诊原因不能为空!\\n"; } if(this.txtC_Comments.Text.Trim().Length==0) { strErr+="会诊意见不能为空!\\n"; } if(this.txtC_InstitutionDoctor.Text.Trim().Length==0) { strErr+="会诊医生及其所在机构名称不能为空!\\n"; } if(!PageValidate.IsDateTime(txtC_Time.Text)) { strErr+="会诊日期格式错误!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int ConsultationID=int.Parse(this.lblConsultationID.Text); int C_UserID=int.Parse(this.txtC_UserID.Text); string C_Cause=this.txtC_Cause.Text; string C_Comments=this.txtC_Comments.Text; string C_InstitutionDoctor=this.txtC_InstitutionDoctor.Text; DateTime C_Time=DateTime.Parse(this.txtC_Time.Text); Maticsoft.Model.record_Consultation model=new Maticsoft.Model.record_Consultation(); model.ConsultationID=ConsultationID; model.C_UserID=C_UserID; model.C_Cause=C_Cause; model.C_Comments=C_Comments; model.C_InstitutionDoctor=C_InstitutionDoctor; model.C_Time=C_Time; Maticsoft.BLL.record_Consultation bll=new Maticsoft.BLL.record_Consultation(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.record_Consultation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update record_Consultation set "); strSql.Append("C_UserID=@C_UserID,"); strSql.Append("C_Cause=@C_Cause,"); strSql.Append("C_Comments=@C_Comments,"); strSql.Append("C_InstitutionDoctor=@C_InstitutionDoctor,"); strSql.Append("C_Time=@C_Time"); strSql.Append(" where ConsultationID=@ConsultationID"); SqlParameter[] parameters = { new SqlParameter("@C_UserID", SqlDbType.Int, 4), new SqlParameter("@C_Cause", SqlDbType.Text), new SqlParameter("@C_Comments", SqlDbType.Text), new SqlParameter("@C_InstitutionDoctor", SqlDbType.Text), new SqlParameter("@C_Time", SqlDbType.DateTime), new SqlParameter("@ConsultationID", SqlDbType.Int, 4) }; parameters[0].Value = model.C_UserID; parameters[1].Value = model.C_Cause; parameters[2].Value = model.C_Comments; parameters[3].Value = model.C_InstitutionDoctor; parameters[4].Value = model.C_Time; parameters[5].Value = model.ConsultationID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.record_Consultation GetModel(int ConsultationID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ConsultationID,C_UserID,C_Cause,C_Comments,C_InstitutionDoctor,C_Time from record_Consultation "); strSql.Append(" where ConsultationID=@ConsultationID"); SqlParameter[] parameters = { new SqlParameter("@ConsultationID", SqlDbType.Int, 4) }; parameters[0].Value = ConsultationID; Maticsoft.Model.record_Consultation model = new Maticsoft.Model.record_Consultation(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.record_Consultation GetModel(int ConsultationID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ConsultationID,C_UserID,C_Cause,C_Comments,C_InstitutionDoctor,C_Time from record_Consultation "); strSql.Append(" where ConsultationID=@ConsultationID"); SqlParameter[] parameters = { new SqlParameter("@ConsultationID", SqlDbType.Int,4) }; parameters[0].Value = ConsultationID; Maticsoft.Model.record_Consultation model=new Maticsoft.Model.record_Consultation(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }