/// <summary> /// 添加门诊或购药记录 /// </summary> /// <param name="purDrug">救助对象门诊或购药 model</param> /// <returns> /// 成功返回刚刚插入数据库的救助对象门诊或购药记录编号 /// 失败 返回0 /// </returns> public static int AddPurDrug(PurDrug purDrug) { return DalPurDrug.AddPurDrug(purDrug); }
/// <summary> /// 添加门诊或购药记录 /// </summary> /// <param name="purDrug">救助对象门诊或购药 model</param> /// <returns> /// 成功返回刚刚插入数据库的救助对象门诊或购药记录编号 /// 失败 返回0 /// </returns> public int AddPurDrug(PurDrug purDrug) { int result = 0; try { StringBuilder strSql = new StringBuilder(); strSql.Append(" insert into T_Med_PurDrug ("); strSql.Append(" TypeId,PatientId,DeptId,ExpenseName,ExpenseNums,ExpensTotalFee,AddTime,State,Operator)"); strSql.Append(" values("); strSql.Append(" @TypeId,@PatientId,@DeptId,@ExpenseName,@ExpenseNums,@ExpensTotalFee,@AddTime,@State,@Operator ) "); strSql.Append(" ;select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@TypeId", SqlDbType.Int), new SqlParameter("@PatientId", SqlDbType.Int), new SqlParameter("@DeptId", SqlDbType.Int), new SqlParameter("@ExpenseName", SqlDbType.NVarChar,100), new SqlParameter("@ExpenseNums", SqlDbType.Int), new SqlParameter("@ExpensTotalFee", SqlDbType.Decimal), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@State", SqlDbType.Int), new SqlParameter("@Operator", SqlDbType.NVarChar,100) }; parameters[0].Value = purDrug.TypeId; parameters[1].Value = purDrug.PatientId; parameters[2].Value = purDrug.DeptId; parameters[3].Value = purDrug.ExpenseName; parameters[4].Value = purDrug.ExpenseNums; parameters[5].Value = purDrug.ExpensTotalFee; parameters[6].Value = purDrug.AddTime; parameters[7].Value = purDrug.State; parameters[8].Value = purDrug.Operator; 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_PurDrug//AddPurDrug" + e.Message); //发生异常,记录 } return result; }