Exemplo n.º 1
0
        private int WriteFactory(Worksheet pSheet, CFactory pFactory, int row, int column)
        {
            List <ProductTag> input = pFactory.GetInputArray();
            int    realCount        = 0;
            string factoryName      = pFactory.GetFactName();

            pSheet.Cells[row, column] = factoryName;
            Range pTitleRange = Utils.GetRange(pSheet, row, column, row, column + 4);

            pTitleRange.Merge();
            pTitleRange.Interior.Color = Color.Bisque;
            realCount++;
            for (int i = 0; i < input.Count; i++)
            {
                ProductTag tag     = input[i];
                int        value   = pFactory.GetTagCount(tag);
                int        currRow = row + realCount;
                string     tagName = m_spisok.GetName(tag);

                if (value > 0)
                {
                    realCount++;
                    pSheet.Cells[currRow, column].ColumnWidth = 20;
                    Utils.WriteTagString(pSheet, currRow, column, tagName, value);
                }
            }

            return(realCount);
        }
Exemplo n.º 2
0
        public void ExportForExcel(Worksheet pSheet)
        {
            int factByLine = 4;
            int currRow    = 2;
            int currColumn = 2;
            int maxColumn  = 0;

            for (int i = 0; i < m_pFactoryList.Count; i++)
            {
                CFactory pFact = m_pFactoryList[i];
                CExportFactoryResultHelper helper = new CExportFactoryResultHelper(pSheet, pFact, currRow, currColumn);
                currColumn += (helper.GetWidht() + 0);
                maxColumn   = Math.Max(maxColumn, currColumn);
                if ((i + 1) % factByLine == 0)
                {
                    currRow   += (helper.GetHeight() + 1);
                    currColumn = 2;
                }
            }

            Dictionary <ProductTag, int> .KeyCollection.Enumerator e = m_array.m_TagMap.Keys.GetEnumerator();
            int startRow = 3;

            //maxColumn += 3;
            pSheet.Cells[startRow, maxColumn]                 = "название";
            pSheet.Cells[startRow, maxColumn].ColumnWidth     = 20;
            pSheet.Cells[startRow, maxColumn + 1]             = "надо";
            pSheet.Cells[startRow, maxColumn + 1].ColumnWidth = 5;
            pSheet.Cells[startRow, maxColumn + 2]             = "в процессе";
            pSheet.Cells[startRow, maxColumn + 2].ColumnWidth = 5;
            pSheet.Cells[startRow, maxColumn + 3]             = "готово";
            pSheet.Cells[startRow, maxColumn + 3].ColumnWidth = 5;
            startRow++;
            int count = m_array.m_TagMap.Keys.Count;

            for (int i = 0; i < count; i++)
            {
                e.MoveNext();
                ProductTag tag   = e.Current;
                string     name  = m_spisok.GetName(tag);
                int        value = m_array.m_TagMap[tag];
                pSheet.Cells[startRow + i + 1, maxColumn]     = name;
                pSheet.Cells[startRow + i + 1, maxColumn + 1] = value;
            }

            Range pRange = pSheet.Range[pSheet.Cells[startRow, maxColumn], pSheet.Cells[startRow + count, maxColumn + 3]];

            for (int i = (int)XlBordersIndex.xlEdgeLeft; i <= (int)XlBordersIndex.xlInsideHorizontal; i++)
            {
                pRange.Borders[(XlBordersIndex)i].LineStyle = XlLineStyle.xlContinuous;
            }
        }
Exemplo n.º 3
0
        public void Calc()
        {
            int count = m_factArray.Count;

            m_array.ExcludeWhatHave(m_alreadyHave);
            for (int i = 0; i < count; i++)
            {
                CFactory pFact = m_factArray[i];
                pFact.SetInput(m_array);
                pFact.Calc();
                pFact.UpdateResult(m_array);
                m_array.ExcludeWhatHave(m_alreadyHave);
            }
        }
Exemplo n.º 4
0
        private void ExportFactory(Worksheet pSheet, CFactory pFactory, ref int row)
        {
            List <ProductTag> input = pFactory.GetInputArray();

            for (int i = 0; i < input.Count; i++)
            {
                ProductTag tag   = input[i];
                int        value = pFactory.GetTagCount(tag);
                if (value > 0)
                {
                    pSheet.Cells[row, 1] = m_spisok.GetName(tag);
                    pSheet.Cells[row, 2] = value.ToString();
                    row++;
                }
            }
        }
Exemplo n.º 5
0
        public CSimpleFactoryExport(Worksheet pSheet, List <CFactory> pList, CSmartArray array)
        {
            int row = 1;

            for (int i = 0; i < pList.Count; i++)
            {
                CFactory pFactory = pList[i];
                if (!pFactory.IsEmpty())
                {
                    Range pRange = pSheet.Range[pSheet.Cells[row, 1], pSheet.Cells[row, 2]];
                    pRange.Merge();
                    pRange.Value = pList[i].GetFactName();
                    row++;
                }
                ExportFactory(pSheet, pFactory, ref row);
            }

            Dictionary <ProductTag, int> map = array.GetMap();

            Dictionary <ProductTag, int> .KeyCollection.Enumerator e = map.Keys.GetEnumerator();
            int count = map.Keys.Count;

            pSheet.Range[pSheet.Cells[row, 1], pSheet.Cells[row, 2]].Merge();
            pSheet.Range[pSheet.Cells[row, 1], pSheet.Cells[row, 2]] = "Вырастить на поле";
            row++;
            for (int i = 0; i < count; i++)
            {
                e.MoveNext();
                ProductTag tag   = e.Current;
                string     name  = m_spisok.GetName(tag);
                int        value = map[tag];
                pSheet.Cells[row, 1] = name;
                pSheet.Cells[row, 2] = value;
                row++;
            }

            Range FullRange = pSheet.Range[pSheet.Cells[1, 1], pSheet.Cells[row - 1, 2]];

            for (int i = (int)XlBordersIndex.xlEdgeLeft; i <= (int)XlBordersIndex.xlInsideHorizontal; i++)
            {
                FullRange.Borders[(XlBordersIndex)i].LineStyle = XlLineStyle.xlContinuous;
            }
            pSheet.Columns[1].AutoFit();
        }
Exemplo n.º 6
0
        public CExportFactoryResultHelper(Worksheet pSheet, CFactory pFact, int Row, int Column)
        {
            m_pFactory    = pFact;
            m_pSheet      = pSheet;
            m_startRow    = Row;
            m_startColumn = Column;
            UploadFactory();
            DefaultStyle();
            int delta = 1;

            Utils.DrawConditions(Utils.GetRange(pSheet, m_startRow + 1, m_startColumn + delta, m_startRow + 7, m_startColumn + delta), Color.CornflowerBlue);
            delta++;
            Utils.DrawConditions(Utils.GetRange(pSheet, m_startRow + 1, m_startColumn + delta, m_startRow + 7, m_startColumn + delta), Color.Khaki);
            delta++;
            //DrawConditions(GetRange(m_startRow + 1, m_startColumn + delta, m_startRow + 5, m_startColumn + delta), Color.DarkSeaGreen);
            delta++;
            Utils.DrawConditions(Utils.GetRange(pSheet, m_startRow + 1, m_startColumn + delta, m_startRow + 7, m_startColumn + delta), Color.DarkSeaGreen);
            WriteFormula();
        }
Exemplo n.º 7
0
        public void WriteInfoAboutFactroryToExcel()
        {
            List <ProductSourceInfo> PSInfo      = new List <ProductSourceInfo>();
            CProductCalc             productCalc = new CProductCalc();
            List <CFactory>          factList    = productCalc.GetFactoryList();

            //Worksheet pSourceSheet = m_pBook.Worksheets.Add();
            //pSourceSheet.Name = GetUniqueSheetName("FullSource");
            for (int factNo = 0; factNo < factList.Count; factNo++)
            {
                Kernal.CFactory          factory  = factList[factNo];
                List <Kernal.ProductTag> tagInput = factory.GetInputArray();
                for (int i = 0; i < tagInput.Count; i++)
                {
                    Kernal.CSmartArray array = new Kernal.CSmartArray();
                    array.Add(tagInput[i], 1);
                    factory.SetInput(array);
                    factory.Calc();
                    Kernal.CSmartArray result = new Kernal.CSmartArray();
                    factory.UpdateResult(result);
                    Dictionary <ProductTag, int> map = result.GetMap();
                    int count = map.Count;
                    var en    = map.Keys.GetEnumerator();
                    en.MoveNext();
                    for (int j = 0; j < count; j++)
                    {
                        ProductTag pTag = en.Current;
                        en.MoveNext();
                        int TagCount = result.GetTagCount(pTag);
                        PSInfo.Add(new ProductSourceInfo(tagInput[i], pTag, TagCount));
                    }
                }
            }

            Dictionary <ProductTag, List <ProductInfo> > InfoArray = new Dictionary <ProductTag, List <ProductInfo> >();

            for (int i = 0; i < PSInfo.Count; i++)
            {
                ProductSourceInfo info = PSInfo[i];
                if (!InfoArray.ContainsKey(info.m_SourceTag))
                {
                    InfoArray[info.m_SourceTag] = new List <ProductInfo>();
                }
                InfoArray[info.m_SourceTag].Add(new ProductInfo(info.m_ProductTag, info.m_Value));
            }

            int FactCount = Enum.GetNames(typeof(FactoryType)).Length;

            for (int FactNo = 0; FactNo < FactCount; FactNo++)
            {
                CFactory pFact = CreateFactory((FactoryType)FactNo);
                string   FactName;
                if (pFact == null)
                {
                    if ((FactoryType)FactNo == FactoryType.ftField)
                    {
                        FactName = "поля";
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    FactName = pFact.GetFactName();
                }

                Worksheet pSourceSheet = m_pBook.Worksheets.Add();
                pSourceSheet.Name = GetUniqueSheetName(FactName);
                int CurrentColumn = 1;
                var e             = InfoArray.Keys.GetEnumerator();
                for (int i = 0; i < InfoArray.Count; i++)
                {
                    e.MoveNext();
                    ProductTag tag = e.Current;

                    if (m_Spisok.GetFactoryType(tag) == (FactoryType)FactNo)
                    {
                        List <ProductInfo> list = InfoArray[tag];
                        Kernal.Utils.UpdateCell(pSourceSheet, 1, CurrentColumn, m_Spisok.GetName(tag), 20);
                        Range pTitleRange = Utils.GetRange(pSourceSheet, 1, CurrentColumn, 1, CurrentColumn + 1);
                        pTitleRange.Merge();
                        for (int ProductNo = 0; ProductNo < list.Count; ProductNo++)
                        {
                            ProductInfo info = list[ProductNo];
                            Kernal.Utils.UpdateCell(pSourceSheet, ProductNo + 2, CurrentColumn, m_Spisok.GetName(info.m_SourceTag), 20);
                            Kernal.Utils.UpdateCell(pSourceSheet, ProductNo + 2, CurrentColumn + 1, info.m_Value.ToString(), 4);
                        }
                        Range pRange = Utils.GetRange(pSourceSheet, 1, CurrentColumn, list.Count + 1, CurrentColumn + 1);
                        for (int borderNo = (int)XlBordersIndex.xlEdgeLeft; borderNo <= (int)XlBordersIndex.xlInsideHorizontal; borderNo++)
                        {
                            pRange.Borders[(XlBordersIndex)borderNo].LineStyle = XlLineStyle.xlContinuous;
                        }
                        CurrentColumn += 2;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private CFactory CreateFactory(Kernal.FactoryType type)
        {
            CFactory pFact = null;

            switch (type)
            {
            case FactoryType.ftAnimal:
                pFact = new CAnimalFactory();
                break;

            case FactoryType.ftBakery:
                pFact = new CBakery();
                break;

            case FactoryType.ftConfectionery:
                pFact = new CСonfectioneryFactory();
                break;

            case FactoryType.ftFastFood:
                pFact = new CFastFoodFactory();
                break;

            case FactoryType.ftIceCream:
                pFact = new CIceCreamFactory();
                break;

            case FactoryType.ftJam:
                pFact = new CJamFactory();
                break;

            case FactoryType.ftKorm:
                pFact = new CKormFactory();
                break;

            case FactoryType.ftMilk:
                pFact = new CMilkFactory();
                break;

            case FactoryType.ftPaper:
                pFact = new CPaperFactory();
                break;

            case FactoryType.ftPlastic:
                pFact = new CPlasticFactory();
                break;

            case FactoryType.ftSewing:
                pFact = new CSewingFactory();
                break;

            case FactoryType.ftSnack:
                pFact = new CSnackFactory();
                break;

            case FactoryType.ftSugar:
                pFact = new CSugarFactory();
                break;

            case FactoryType.ftWeaving:
                pFact = new CWeavingFactory();
                break;

            case FactoryType.ftRubber:
                pFact = new CRubberFactory();
                break;

            case FactoryType.ftCandy:
                pFact = new CCandyFactory();
                break;

            case FactoryType.ftMexican:
                pFact = new CMexicanRestaurant();
                break;
            }
            return(pFact);
        }