114 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using AIMSDAL;
 | |
| using AIMSModel;
 | |
| using DrawGraph;
 | |
| using HelperDB;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Data;
 | |
| using System.Data.SqlClient;
 | |
| 
 | |
| namespace AIMSBLL
 | |
| {
 | |
|     public partial class BCharges
 | |
|     { 
 | |
|         public static DataTable GetDrugsByIds(string ids)
 | |
|         {
 | |
|             if (ids != null && ids.Length > 0)
 | |
|             {
 | |
|                 string sql = string.Format("select *, Bill Stand from  Charges 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 *, Bill Stand from  Charges where 1<>1 ");
 | |
|                 return DBHelper.GetDataTable(sql);
 | |
|             }
 | |
|         }
 | |
|         public static DataTable GetAllChargesByCondition(string Condition)
 | |
|         {
 | |
|             string strSql = "SELECT top 20 d.*, Bill Stand,unit DosageUnit,Form Factory,d.Class as TypeName FROM Charges d where d.IsValid=1 and (d.HelpCode like'%" + Condition.ToUpper() + "%' or d.Name like'%" + Condition + "%')  ";
 | |
|             return DBHelper.GetDataTable(strSql);
 | |
|         }
 | |
| 
 | |
|         public static DataTable SelectIdName(string str)
 | |
|         {
 | |
|             string sql = string.Empty;
 | |
|             if (str == "")
 | |
|             {
 | |
|                 sql = string.Format("select Id,Name,code,price,Bill from Charges  where IsValid = 1");
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 sql = string.Format("SELECT Top 26 e.Id,e.Name,code,price,Bill FROM  Charges e WHERE (Lower(Name) like '%{0}%' OR  Lower(HelpCode) like '%{0}%') and IsValid = 1", str);
 | |
|             }
 | |
|             return DBHelper.GetDataTable(sql);
 | |
|         }
 | |
| 
 | |
|         public static DataTable GetChargsByCodes(string ids, string numbers)
 | |
|         {
 | |
|             DataTable dt = BCharges.GetChargsByCodes(ids);
 | |
|             dt.Columns.Add(new DataColumn("Number", typeof(string)));
 | |
|             string[] numbes = new string[0];
 | |
|             if (numbers != null && numbers != "") numbes = numbers.Split(',');
 | |
|             for (int i = 0; i < dt.Rows.Count; i++)
 | |
|             {
 | |
|                 if (numbes.Length != 0 && numbes.Length <= dt.Rows.Count) dt.Rows[i]["Number"] = numbes[i].ToString();
 | |
|                 else dt.Rows[i]["Number"] = "0";
 | |
|             }
 | |
|             return dt;
 | |
|         }
 | |
|         public static DataTable GetChargsByCodes(string ChargCodes)
 | |
|         {
 | |
|             if (ChargCodes != null && ChargCodes.Length > 0)
 | |
|             {
 | |
|                 string sql = string.Format("select * from Charges where Id in({0})  order by charindex(','+rtrim(Id)+',',',{1},') ", ChargCodes, ChargCodes.Replace("'", "")); 
 | |
|                 return DBHelper.GetDataTable(sql);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 string sql = string.Format("select * from Charges  where 1<>1 ");
 | |
|                 return DBHelper.GetDataTable(sql);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 模糊查询事件
 | |
|         /// </summary>
 | |
|         /// <returns></returns>
 | |
|         public static DataTable SelectByIdName(string str, string deptid)
 | |
|         {
 | |
|             string sql = string.Empty;
 | |
|             if (str == "")
 | |
|             {
 | |
|                 sql = string.Format("select Top 40 Id ID,name+' '+ISNULL(Bill,'') Name, Code,code xmbm,Form,Price,Bill from Charges where Class <>  '药品'");
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 sql = string.Format("select Top 40 Id ID,name+' '+ISNULL(Bill,'') Name, Code,code xmbm,Form,Price,Bill from Charges where Class <>  '药品' and ( Code like '%{0}%' OR name like '%{0}%'   ) ", str); 
 | |
|             }
 | |
|             try
 | |
|             {
 | |
|                 return DBHelper.GetDataTable(sql);
 | |
|             }
 | |
|             catch (SqlException ex)
 | |
|             {
 | |
|                 throw new Exception(ex.Message);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         public static List<Charges> GetChargsListByCodes(string ids, string numbers)
 | |
|         { 
 | |
|             List<Charges> dt = DCharges.GetChargsListByCodes(ids);
 | |
|             string[] numbes = new string[0];
 | |
|             if (numbers != null && numbers != "") numbes = numbers.Split(',');
 | |
|             for (int i = 0; i < dt.Count; i++)
 | |
|             {
 | |
|                 if (numbes.Length != 0 && numbes.Length <= dt.Count) dt[i].Number = numbes[i].ToString();
 | |
|                 else dt[i].Number = "1";
 | |
|             }
 | |
|             return dt;
 | |
|         }
 | |
| 
 | |
|     }
 | |
| } 
 |