예제 #1
1
        public DataSet FilterData(ArsonFilterModel filterData)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["UCR_DataEntities"];
            DataSet dsResult = new DataSet();
            using (SqlConnection conn = new SqlConnection(connectionString.ConnectionString))
            {
                try
                {
                    SqlCommand command = new SqlCommand();
                    command.Connection = conn;
                    command.CommandText = GenerateArsonORQuery(filterData);
                    command.CommandType = System.Data.CommandType.Text;
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    adapter.SelectCommand = command;

                    conn.Open();
                    adapter.Fill(dsResult);
                    conn.Close();
                    adapter.Dispose();
                    command.Dispose();
                }
                catch (Exception ex)
                {
                    StorageClient.LogError(ex);
                }
            }
            return dsResult;
        }
예제 #2
0
        private string GenerateArsonORQuery(ArsonFilterModel filterData)
        {
            bool useAnd = false;
            StringBuilder sbQuery = new StringBuilder("select * from ARSON_View");
            sbQuery.Append(GetNumValOR(filterData.Year, ref useAnd, "Year"));
            sbQuery.Append(GetBetValOR(filterData.MonthFrom, filterData.MonthTo, ref useAnd, "Month"));
            sbQuery.Append(GetListValOR(filterData.OffenseName, ref useAnd, "Offense"));

            return sbQuery.ToString();
        }