示例#1
0
        protected virtual SortedDictionary <DateTime, double> GetLots(View view, FabLotPlanFilter filter)
        {
            string sql = "select * from FabLotPlan " + filter.GetWhereStatement();

            SortedDictionary <DateTime, double> lots = new SortedDictionary <DateTime, double>();

            using (SqlConnection connection = new SqlConnection(view.Database.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    SqlParameter fromParameter = new SqlParameter("FromDate", new DateTime(filter.Date.Year, filter.Date.Month, 1));
                    command.Parameters.Add(fromParameter);
                    SqlParameter toParameter = new SqlParameter("ToDate", new DateTime(filter.Date.Year + 1, filter.Date.Month, 1));
                    command.Parameters.Add(toParameter);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DateTime date = reader.GetDateTime(reader.GetOrdinal("Date"));
                            double   lot  = reader.GetDouble(reader.GetOrdinal("Lot"));
                            lots.Add(date, lot);
                        }
                        reader.Close();
                    }
                }
                connection.Close();
            }

            return(lots);
        }
示例#2
0
        public virtual SortedDictionary <DateTime, double> GetLots(View view, FabLotPlanFilter filter)
        {
            string sql = "select * from FabLotPlan " + filter.GetWhereStatement();

            SortedDictionary <DateTime, double> lots = new SortedDictionary <DateTime, double>();

            using (SqlConnection connection = new SqlConnection(view.Database.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    SqlParameter fromParameter = GetFromParameter(filter);
                    command.Parameters.Add(fromParameter);
                    SqlParameter toParameter = GetToParameter(filter);
                    command.Parameters.Add(toParameter);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DateTime date = reader.GetDateTime(reader.GetOrdinal("Date"));
                            double   lot  = reader.GetDouble(reader.GetOrdinal("Lot"));

                            date = GetFirstPeriodDate(date);
                            if (lots.ContainsKey(date))
                            {
                                lots[date] += lot;
                            }
                            else
                            {
                                lots.Add(date, lot);
                            }
                        }
                        reader.Close();
                    }
                }
                connection.Close();
            }

            return(lots);
        }