Exemplo n.º 1
0
 /// <summary>
 /// 根据条件进行模糊搜索
 /// </summary>
 /// <param name="searchCond">搜索条件</param>
 /// <returns></returns>
 public List <Drugs> SearchDrugs(string searchCond)
 {
     using (IDbConnection conn = DAOFactory.Instance.OpenConnection())
     {
         IDrugsDAO           dao      = DAOFactory.Instance.CreateDrugsDAO();
         SearchDrugsTemplate template = new SearchDrugsTemplate();
         template.Code     = searchCond;
         template.Name     = searchCond;
         template.From     = searchCond;
         template.Category = searchCond;
         return(dao.SearchDrugs(template, conn));
     }
 }
Exemplo n.º 2
0
        public List <Drugs> SearchDrugs(SearchDrugsTemplate drug, IDbConnection conn)
        {
            string sql = @"
            Select 
               Md.ID,Md.DrugCode,Md.DrugName,Md.UnitPrice,Md.Standard,Md.Unit,Md.Actived,Md.Remark,
               Mdf.ID,Mdf.DrugFromCode,Mdf.DrugFromName,Mdf.Actived,Mdf.Remark,
               Mdc.ID,Mdc.DrugCategoryCode,Mdc.DrugCategoryName,Mdc.Actived,Mdc.Remark
            from MD_Drugs as Md 
            inner join  MD_DrugFrom as Mdf on Md.DrugFrom_ID=Mdf.ID
            inner join MD_DrugCategory as Mdc on Md.DrugCategory_ID=Mdc.ID 
            where Md.DrugCode like @DrugCode
            or Md.DrugName like @DrugName
            or Md.DrugFromName like @DrugFromName
            or Md.DrugCategory like @DrugCategory";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@DrugCode", string.Format("%{0}%", drug.Code)));
            paramList.Add(new SqlParameter("@DrugName", string.Format("%{0}%", drug.Name)));
            paramList.Add(new SqlParameter("@DrugFromName", string.Format("%{0}%", drug.From)));
            paramList.Add(new SqlParameter("@DrugCategory", string.Format("%{0}%", drug.Category)));
            return(SelectDrugs(sql, paramList, (SqlConnection)conn));
        }