public DataTable search(lkkSearchData data) { DataTable searchResult = new DataTable(); SQLiteCommand selectData = new SQLiteCommand(); SQLiteDataAdapter adapter = new SQLiteDataAdapter(); adapter.SelectCommand = selectData; selectData.Connection = connection; selectData.CommandText = "SELECT * FROM infedenceView WHERE deleted='0' AND status='0'"; selectData.Parameters.Add(":status", DbType.Int32); selectData.Parameters[":status"].Value = Program.status; if (data.dateBegin != Convert.ToDateTime("01.01.1900") && data.dateEnd != Convert.ToDateTime("01.01.1900")) { selectData.CommandText += " AND data BETWEEN :dataStart AND :dataEnd "; selectData.Parameters.Add(":dataStart", DbType.Date); selectData.Parameters.Add(":dataEnd", DbType.Date); selectData.Parameters[":dataStart"].Value = data.dateBegin; selectData.Parameters[":dataEnd"].Value = data.dateEnd; } if (data.fio.Trim() !="") { selectData.CommandText += " AND fio=:fio "; selectData.Parameters.Add(":fio", DbType.String); selectData.Parameters[":fio"].Value = data.fio; } if (data.ageStart != null) { selectData.CommandText += " AND age>=:startAge AND age <=:endAge "; selectData.Parameters.Add(":startAge", DbType.String); selectData.Parameters.Add(":endAge", DbType.String); selectData.Parameters[":startAge"].Value = data.ageStart; selectData.Parameters[":endAge"].Value = data.ageEnd; } if (data.region != null) { selectData.CommandText += " AND region=:region "; selectData.Parameters.Add(":region", DbType.String); selectData.Parameters[":region"].Value = data.region; } if (data.diagnose != null) { selectData.CommandText += " AND mkbCode=:mkbCode "; selectData.Parameters.Add(":mkbCode", DbType.String); selectData.Parameters[":mkbCode"].Value = getID(data.diagnose, typesData.mkbcode); } if (data.lpz != null) { selectData.CommandText += " AND LPZ=:lpz "; selectData.Parameters.Add(":lpz", DbType.String); selectData.Parameters[":lpz"].Value = data.lpz; } if (data.excludeTill18) { selectData.CommandText += " AND birth >" + (DateTime.Now.Year - 18).ToString(); } if (data.orphanDiseases) { selectData.CommandText += " AND mkbCode IN (SELECT diagnosis.codeMKB FROM diagnosis WHERE diagnosis.isOrphan = 1) "; } connect(); adapter.Fill(searchResult); disconnect(); return searchResult; }
public void start(lkkSearchData dataToSearch) { searchData = dataToSearch; }