/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.education_Prescription DataRowToModel(DataRow row) { Maticsoft.Model.education_Prescription model=new Maticsoft.Model.education_Prescription(); if (row != null) { if(row["PrescriptionID"]!=null && row["PrescriptionID"].ToString()!="") { model.PrescriptionID=int.Parse(row["PrescriptionID"].ToString()); } if(row["P_Object"]!=null && row["P_Object"].ToString()!="") { model.P_Object=decimal.Parse(row["P_Object"].ToString()); } if(row["P_Name"]!=null) { model.P_Name=row["P_Name"].ToString(); } if(row["P_Content"]!=null) { model.P_Content=row["P_Content"].ToString(); } if(row["P_Doctor"]!=null && row["P_Doctor"].ToString()!="") { model.P_Doctor=int.Parse(row["P_Doctor"].ToString()); } if(row["P_Date"]!=null && row["P_Date"].ToString()!="") { model.P_Date=DateTime.Parse(row["P_Date"].ToString()); } } return model; }
/// <summary> /// 根据信息类型返回对应的信息名称 /// </summary> /// <param name="superision_type"></param> /// <returns></returns> /// <summary> /// 点击确定按钮执行的方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { Maticsoft.BLL.education_Prescription education_Prescription_bll = new Maticsoft.BLL.education_Prescription(); Maticsoft.Model.education_Prescription education_Prescription_model = education_Prescription_bll.GetModel(PrescriptionID); if (education_Prescription_model == null) { education_Prescription_model = new Maticsoft.Model.education_Prescription(); } //获取客户端通过Post方式传递过来的值的 education_Prescription_model.P_Date = (DateTime)Common.sink(this.P_Date.UniqueID, MethodType.Post, 255, 0, DataType.Dat); education_Prescription_model.P_Content = (string)Common.sink(this.P_Content.UniqueID, MethodType.Post, 0, 0, DataType.Str); education_Prescription_model.P_Object = Convert.ToInt32(this.P_Object.Value); education_Prescription_model.P_Doctor = Convert.ToInt32(this.P_Doctor.Value); education_Prescription_model.P_Name = P_Name.Text; switch (CMD) { case "New": CMD_Txt = "增加"; //增加操作调用Add方法 PrescriptionID = education_Prescription_bll.Add(education_Prescription_model); break; case "Edit": CMD_Txt = "修改"; //是修改操作调用Update方法 education_Prescription_bll.Update(education_Prescription_model); break; } All_Title_Txt = CMD_Txt + App_Txt; EventMessage.MessageBox(1, "操作成功", string.Format("{1}ID({0})成功!", PrescriptionID, All_Title_Txt), Icon_Type.OK, Common.GetHomeBaseUrl("default.aspx")); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.education_Prescription model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into education_Prescription("); strSql.Append("P_Object,P_Name,P_Content,P_Doctor,P_Date)"); strSql.Append(" values ("); strSql.Append("@P_Object,@P_Name,@P_Content,@P_Doctor,@P_Date)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@P_Object", SqlDbType.Money, 8), new SqlParameter("@P_Name", SqlDbType.NVarChar, 100), new SqlParameter("@P_Content", SqlDbType.Text), new SqlParameter("@P_Doctor", SqlDbType.Int, 4), new SqlParameter("@P_Date", SqlDbType.DateTime) }; parameters[0].Value = model.P_Object; parameters[1].Value = model.P_Name; parameters[2].Value = model.P_Content; parameters[3].Value = model.P_Doctor; parameters[4].Value = model.P_Date; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.education_Prescription DataRowToModel(DataRow row) { Maticsoft.Model.education_Prescription model = new Maticsoft.Model.education_Prescription(); if (row != null) { if (row["PrescriptionID"] != null && row["PrescriptionID"].ToString() != "") { model.PrescriptionID = int.Parse(row["PrescriptionID"].ToString()); } if (row["P_Object"] != null && row["P_Object"].ToString() != "") { model.P_Object = decimal.Parse(row["P_Object"].ToString()); } if (row["P_Name"] != null) { model.P_Name = row["P_Name"].ToString(); } if (row["P_Content"] != null) { model.P_Content = row["P_Content"].ToString(); } if (row["P_Doctor"] != null && row["P_Doctor"].ToString() != "") { model.P_Doctor = int.Parse(row["P_Doctor"].ToString()); } if (row["P_Date"] != null && row["P_Date"].ToString() != "") { model.P_Date = DateTime.Parse(row["P_Date"].ToString()); } } return(model); }
private void ShowInfo(int PrescriptionID) { Maticsoft.BLL.education_Prescription bll = new Maticsoft.BLL.education_Prescription(); Maticsoft.Model.education_Prescription model = bll.GetModel(PrescriptionID); this.lblPrescriptionID.Text = model.PrescriptionID.ToString(); this.txtP_Object.Text = model.P_Object.ToString(); this.txtP_Name.Text = model.P_Name; this.txtP_Content.Text = model.P_Content; this.txtP_Doctor.Text = model.P_Doctor.ToString(); this.txtP_Date.Text = model.P_Date.ToString(); }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsDecimal(txtP_Object.Text)) { strErr += "健康处方对象格式错误!\\n"; } if (this.txtP_Name.Text.Trim().Length == 0) { strErr += "处方名称不能为空!\\n"; } if (this.txtP_Content.Text.Trim().Length == 0) { strErr += "处方内容不能为空!\\n"; } if (!PageValidate.IsNumber(txtP_Doctor.Text)) { strErr += "处方医生格式错误!\\n"; } if (!PageValidate.IsDateTime(txtP_Date.Text)) { strErr += "处方日期格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int PrescriptionID = int.Parse(this.lblPrescriptionID.Text); decimal P_Object = decimal.Parse(this.txtP_Object.Text); string P_Name = this.txtP_Name.Text; string P_Content = this.txtP_Content.Text; int P_Doctor = int.Parse(this.txtP_Doctor.Text); DateTime P_Date = DateTime.Parse(this.txtP_Date.Text); Maticsoft.Model.education_Prescription model = new Maticsoft.Model.education_Prescription(); model.PrescriptionID = PrescriptionID; model.P_Object = P_Object; model.P_Name = P_Name; model.P_Content = P_Content; model.P_Doctor = P_Doctor; model.P_Date = P_Date; Maticsoft.BLL.education_Prescription bll = new Maticsoft.BLL.education_Prescription(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsDecimal(txtP_Object.Text)) { strErr+="健康处方对象格式错误!\\n"; } if(this.txtP_Name.Text.Trim().Length==0) { strErr+="处方名称不能为空!\\n"; } if(this.txtP_Content.Text.Trim().Length==0) { strErr+="处方内容不能为空!\\n"; } if(!PageValidate.IsNumber(txtP_Doctor.Text)) { strErr+="处方医生格式错误!\\n"; } if(!PageValidate.IsDateTime(txtP_Date.Text)) { strErr+="处方日期格式错误!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int PrescriptionID=int.Parse(this.lblPrescriptionID.Text); decimal P_Object=decimal.Parse(this.txtP_Object.Text); string P_Name=this.txtP_Name.Text; string P_Content=this.txtP_Content.Text; int P_Doctor=int.Parse(this.txtP_Doctor.Text); DateTime P_Date=DateTime.Parse(this.txtP_Date.Text); Maticsoft.Model.education_Prescription model=new Maticsoft.Model.education_Prescription(); model.PrescriptionID=PrescriptionID; model.P_Object=P_Object; model.P_Name=P_Name; model.P_Content=P_Content; model.P_Doctor=P_Doctor; model.P_Date=P_Date; Maticsoft.BLL.education_Prescription bll=new Maticsoft.BLL.education_Prescription(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.education_Prescription model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update education_Prescription set "); strSql.Append("P_Object=@P_Object,"); strSql.Append("P_Name=@P_Name,"); strSql.Append("P_Content=@P_Content,"); strSql.Append("P_Doctor=@P_Doctor,"); strSql.Append("P_Date=@P_Date"); strSql.Append(" where PrescriptionID=@PrescriptionID"); SqlParameter[] parameters = { new SqlParameter("@P_Object", SqlDbType.Money, 8), new SqlParameter("@P_Name", SqlDbType.NVarChar, 100), new SqlParameter("@P_Content", SqlDbType.Text), new SqlParameter("@P_Doctor", SqlDbType.Int, 4), new SqlParameter("@P_Date", SqlDbType.DateTime), new SqlParameter("@PrescriptionID", SqlDbType.Int, 4) }; parameters[0].Value = model.P_Object; parameters[1].Value = model.P_Name; parameters[2].Value = model.P_Content; parameters[3].Value = model.P_Doctor; parameters[4].Value = model.P_Date; parameters[5].Value = model.PrescriptionID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.education_Prescription GetModel(int PrescriptionID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PrescriptionID,P_Object,P_Name,P_Content,P_Doctor,P_Date from education_Prescription "); strSql.Append(" where PrescriptionID=@PrescriptionID"); SqlParameter[] parameters = { new SqlParameter("@PrescriptionID", SqlDbType.Int, 4) }; parameters[0].Value = PrescriptionID; Maticsoft.Model.education_Prescription model = new Maticsoft.Model.education_Prescription(); 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.education_Prescription GetModel(int PrescriptionID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 PrescriptionID,P_Object,P_Name,P_Content,P_Doctor,P_Date from education_Prescription "); strSql.Append(" where PrescriptionID=@PrescriptionID"); SqlParameter[] parameters = { new SqlParameter("@PrescriptionID", SqlDbType.Int,4) }; parameters[0].Value = PrescriptionID; Maticsoft.Model.education_Prescription model=new Maticsoft.Model.education_Prescription(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }