예제 #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
        //protected override SqlParameter GetFromParameter(FabLotPlanFilter filter)
        //{
        //    return new SqlParameter("FromDate", filter.Date.StartOfWeekUS());

        //}

        protected override SqlParameter GetToParameter(FabLotPlanFilter filter)
        {
            DateTime date = filter.Date.StartOfWeekUS();

            date = date.AddDays(DateHelper.DaysInWeek * numberOfWeeks);
            return(new SqlParameter("ToDate", date));
        }
예제 #3
0
        protected virtual void LoadTable(DataTable table, View view, string guid)
        {
            if (filter == null)
            {
                filter = GetFilter(view, guid);
            }

            SortedDictionary <DateTime, double> lots = GetLots(view, filter);

            int index = 0;

            foreach (DateTime date in lots.Keys)
            {
                index++;
                double lot = lots[date];

                DataRow prevRow = null;
                foreach (DataRow row in table.Rows)
                {
                    if (!row.IsNull("ProductionOut"))
                    {
                        DateTime ProductionOut      = (DateTime)row["ProductionOut"];
                        DateTime ProductionOutMonth = new DateTime(ProductionOut.Year, ProductionOut.Month, 1);

                        if (date >= ProductionOutMonth)
                        {
                            prevRow = row;
                        }
                        else
                        {
                            if (prevRow != null)
                            {
                                SetLot(index, table, prevRow, lot);
                            }
                        }
                    }
                }
                if (prevRow != null)
                {
                    SetLot(index, table, prevRow, lot);
                }
            }
        }
예제 #4
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);
        }
예제 #5
0
        protected virtual void LoadTable(DataTable table, View view, string guid, FabLotPlanFilter filter, int id)
        {
            DateTime?firstPlanningMonth = GetFirstPlanningMonth();

            if (!firstPlanningMonth.HasValue)
            {
                return;
            }

            FabLotPlanLoader fabLotPlanLoader = GetNewFabLotPlanLoader();

            SortedDictionary <DateTime, double> lots = fabLotPlanLoader.GetLots(view, filter);

            DataRow newRow = table.NewRow();

            string periodPrefix = GetPeriodPrefix();

            foreach (DateTime date in lots.Keys)
            {
                double lot = lots[date];


                int index = GetIndex(date, firstPlanningMonth);

                if (table.Columns.Contains(periodPrefix + index))
                {
                    newRow[periodPrefix + index] = lot;
                }
            }
            newRow["Id"]           = id;
            newRow["TechnologyId"] = filter.Technology;
            newRow["FabId"]        = filter.Fab;
            newRow["MemoryId"]     = filter.Memory;
            newRow["ECCTypeId"]    = filter.Ecc;

            table.Rows.Add(newRow);
        }
예제 #6
0
        protected virtual FabLotPlanFilter GetFilter(View view, string guid)
        {
            FabLotPlanFilter filter = new FabLotPlanFilter(view, guid);

            return(filter);
        }
예제 #7
0
 protected virtual SqlParameter GetToParameter(FabLotPlanFilter filter)
 {
     return(new SqlParameter("ToDate", new DateTime(filter.Date.Year + 1, filter.Date.Month, 1)));
 }