2023-03-14 19:05:29 +08:00

77 lines
2.5 KiB
C#

using System;
using AIMSDAL;
using AIMSModel;
using AIMSObjectQuery;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using HelperDB;
using System.Windows.Forms;
namespace AIMSBLL
{
public partial class BDrugs
{
public static DataTable GetAllDrugsByCondition(string Condition)
{
string strSql = "SELECT top 20 d.*, d.DrugKind as TypeName FROM Drugs d where d.IsValid=1 and (d.HelpCode like'%" + Condition.ToUpper() + "%' or d.Name like'%" + Condition + "%') Order By UseRate desc";
return DBHelper.GetDataTable(strSql);
}
public static DataTable SelectIdName(string str)
{
string sql = string.Empty;
if (str == "")
{
sql = string.Format("select Id,HelpCode,Name,Id code,Stand,UseDose1,UseDose2,UseDose3,Comment,ZFBL from Drugs where IsValid = 1");
}
else
{
sql = string.Format("SELECT Top 26 e.Id,e.Name,Id code, Stand,UseDose1,UseDose2,UseDose3,Comment,ZFBL FROM Drugs e WHERE (Lower(Name) like '%{0}%' OR Lower(HelpCode) like '%{0}%') and IsValid = 1", str);
}
return DBHelper.GetDataTable(sql);
}
public static DataTable GetDrugsByIds(string ids)
{
if (ids != null && ids.Length > 0)
{
string sql = string.Format("select * from Drugs where IsValid=1 and Id in({0}) order by charindex(','+rtrim(cast(id as varchar(10)))+',',',{0},')", ids);//IsValid=1 and
return DBHelper.GetDataTable(sql);
}
else
{
string sql = string.Format("select * from Drugs where 1<>1 ");
return DBHelper.GetDataTable(sql);
}
}
public static void Add(Drugs DrugsObj)
{
try
{
DDrugs.Add(DrugsObj);
MessageBox.Show("药品增加成功!");
}
catch
{
MessageBox.Show("药品增加失败!");
}
}
public static Drugs GetModel(int Id)
{
return DDrugs.GetModel(Id);
}
public static DataTable GetDataTable(string DrugKind,string Name)
{
return DDrugs.GetDataTable(DrugKind,Name);
}
public static DataTable GetDrugsDataTable()
{
return DDrugs.GetDrugsDataTable();
}
}
}