using System; using System.Data; using System.Data.SqlClient; using System.Collections; using System.Collections.Generic; using AIMSModel; using AIMSObjectQuery; using System.Text; namespace AIMSDAL { internal partial class DMedicamentPrice { public static bool Exists(int Id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select count(1) from MedicamentPrice where Id="+Id+"" ); return HelperDB.DbHelperSQL.Exists(strSql.ToString()); } public static void Add(MedicamentPrice MedicamentPriceObj) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into [MedicamentPrice]("); strSql.Append("DrugManufacturerId,MedicalItemId,PurchasePrice,TradePrice,RetailPrice,IsValid,OperatorNo,OperatorName,OperateDate"); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(""+MedicamentPriceObj.DrugManufacturerId+","); strSql.Append(""+MedicamentPriceObj.MedicalItemId+","); strSql.Append(""+MedicamentPriceObj.PurchasePrice+","); strSql.Append(""+MedicamentPriceObj.TradePrice+","); strSql.Append(""+MedicamentPriceObj.RetailPrice+","); strSql.Append(""+MedicamentPriceObj.IsValid+","); strSql.Append("'"+MedicamentPriceObj.OperatorNo+"',"); strSql.Append("'"+MedicamentPriceObj.OperatorName+"',"); strSql.Append("'"+MedicamentPriceObj.OperateDate+"'"); strSql.Append(")"); HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString()); } public static MedicamentPrice GetModel(int Id) { MedicamentPrice MedicamentPriceObj = new MedicamentPrice(); StringBuilder strSql=new StringBuilder(); strSql.Append("select "); strSql.Append("Id,DrugManufacturerId,MedicalItemId,PurchasePrice,TradePrice,RetailPrice,IsValid,OperatorNo,OperatorName,OperateDate "); strSql.Append(" from MedicamentPrice "); strSql.Append(" where Id="+Id+"" ); DataSet ds = HelperDB.DbHelperSQL.GetDataSet(strSql.ToString()); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["Id"].ToString()!="") { MedicamentPriceObj.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if(ds.Tables[0].Rows[0]["DrugManufacturerId"].ToString()!="") { MedicamentPriceObj.DrugManufacturerId = int.Parse(ds.Tables[0].Rows[0]["DrugManufacturerId"].ToString()); } if(ds.Tables[0].Rows[0]["MedicalItemId"].ToString()!="") { MedicamentPriceObj.MedicalItemId = int.Parse(ds.Tables[0].Rows[0]["MedicalItemId"].ToString()); } if(ds.Tables[0].Rows[0]["PurchasePrice"].ToString()!="") { MedicamentPriceObj.PurchasePrice = decimal.Parse(ds.Tables[0].Rows[0]["PurchasePrice"].ToString()); } if(ds.Tables[0].Rows[0]["TradePrice"].ToString()!="") { MedicamentPriceObj.TradePrice = decimal.Parse(ds.Tables[0].Rows[0]["TradePrice"].ToString()); } if(ds.Tables[0].Rows[0]["RetailPrice"].ToString()!="") { MedicamentPriceObj.RetailPrice = decimal.Parse(ds.Tables[0].Rows[0]["RetailPrice"].ToString()); } if(ds.Tables[0].Rows[0]["IsValid"].ToString()!="") { MedicamentPriceObj.IsValid = int.Parse(ds.Tables[0].Rows[0]["IsValid"].ToString()); } MedicamentPriceObj.OperatorNo = ds.Tables[0].Rows[0]["OperatorNo"].ToString(); MedicamentPriceObj.OperatorName = ds.Tables[0].Rows[0]["OperatorName"].ToString(); if(ds.Tables[0].Rows[0]["OperateDate"].ToString()!="") { MedicamentPriceObj.OperateDate = DateTime.Parse(ds.Tables[0].Rows[0]["OperateDate"].ToString()); } } return MedicamentPriceObj; } public static DataTable GetDataTable(int MedicalItemId) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT mp.Id, mi.No,mi.Name,dm.Name AS DrugManufacturerName,mp.PurchasePrice, mp.TradePrice, mp.RetailPrice, CASE mp.IsValid WHEN 1 THEN '有效' WHEN 0 THEN '无效' END AS IsValid "); strSql.Append("FROM MedicamentPrice mp "); strSql.Append("LEFT JOIN DrugManufacturer dm ON dm.Id =mp.DrugManufacturerId "); strSql.Append("LEFT JOIN MedicalItem mi ON mi.Id = mp.MedicalItemId WHERE MedicalItemId =" + MedicalItemId + " "); return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString()); } } }