Beispiel #1
0
 public void ExcludeWhatHave(CProductCalc pCalc)
 {
     for (int i = 0; i < m_factArray.Count; i++)
     {
         List <CFactory> pList = pCalc.GetFactoryList();
         m_factArray[i].ExcludeWhatHave(pList[i]);
     }
     m_array.ExcludeWhatHave(pCalc.m_array);
 }
Beispiel #2
0
 private void button2_Click_1(object sender, EventArgs e)
 {
     Kernal.CProductCalc ar    = new Kernal.CProductCalc();
     Kernal.CSmartArray  array = GetAllZakazArray();
     array.ExcludeWhatHave(m_AlreadyHave.Copy());
     ar.SetArray(array);
     ar.SetAlreadyHave(m_AlreadyHave.Copy());
     for (int i = 0; i < CalcCount; i++)
     {
         ar.Calc();
     }
     ShowResultForm(ar.Print());
 }
Beispiel #3
0
        private CProductCalc GetProductCalcSimpleAndSecond(List <CZakaz> simpleZakazes, List <CZakaz> newZakazes)
        {
            CSmartArray calcArray2 = new CSmartArray();

            LoadZakazListToSmartArray(calcArray2, simpleZakazes);
            LoadZakazListToSmartArray(calcArray2, newZakazes);

            CProductCalc productCalc2 = new CProductCalc();

            productCalc2.SetArray(calcArray2);
            productCalc2.SetAlreadyHave(m_alreadyHave.Copy());
            productCalc2.Calc(5);
            return(productCalc2);
        }
Beispiel #4
0
        public void Calc()
        {
            List <CZakaz> simpleZakazes  = new List <CZakaz>();
            List <CZakaz> newZakazes     = new List <CZakaz>();
            List <CZakaz> resolveZakazes = new List <CZakaz>();

            UpdateZakazsList(resolveZakazes, newZakazes, simpleZakazes);

            CSmartArray calcArray = new CSmartArray();

            LoadZakazListToSmartArray(calcArray, simpleZakazes);

            CProductCalc productCalc = new CProductCalc();

            productCalc.SetArray(calcArray);
            productCalc.SetAlreadyHave(m_alreadyHave.Copy());
            productCalc.Calc(5);

            Worksheet pTotalSheet = m_pBook.Worksheets.Add();

            pTotalSheet.Name = GetUniqueSheetName("MainTotal");
            ExportToExcel(pTotalSheet, productCalc.GetFactoryList(), productCalc.GetArray());
            {
                Worksheet pOneTableSheet = m_pBook.Worksheets.Add();
                pOneTableSheet.Name = GetUniqueSheetName("OneTableTotal");
                Kernal.CAllFactoryOneTable allFactoryOneTable = new Kernal.CAllFactoryOneTable(productCalc.GetFactoryList(), pOneTableSheet);
                Kernal.CAllSourceWrite     AllSourceWrite     = new Kernal.CAllSourceWrite(pOneTableSheet, productCalc.GetArray());
            }

            if (newZakazes.Count > 0)
            {
                CProductCalc productCalc2 = GetProductCalcSimpleAndSecond(simpleZakazes, newZakazes);
                {
                    Worksheet pTotalSheet2 = m_pBook.Worksheets.Add();
                    pTotalSheet2.Name = GetUniqueSheetName("OtherTotal");
                    ExportToExcel(pTotalSheet2, productCalc2.GetFactoryList(), productCalc2.GetArray());
                }
                productCalc2.ExcludeWhatHave(productCalc);
                Worksheet pSimpleSheet = m_pBook.Worksheets.Add();
                pSimpleSheet.Name = GetUniqueSheetName("SimpleTotal");
                new CSimpleFactoryExport(pSimpleSheet, productCalc2.GetFactoryList(), productCalc2.GetArray());
            }
            if (resolveZakazes.Count > 0)
            {
                CProductCalc productCalc2   = GetProductCalcSimpleAndSecond(simpleZakazes, resolveZakazes);
                CSmartArray  newAlreadyHave = productCalc.GetAlreadyHave();

                //вывести на другой лист значение newAlreadyHave
            }
        }
Beispiel #5
0
        private void planeCalc_Click(object sender, EventArgs e)
        {
            Kernal.CProductCalc calc  = new Kernal.CProductCalc();
            Kernal.CSmartArray  array = GetAllPlaneArray();
            array.ExcludeWhatHave(m_AlreadyHave.Copy());
            calc.SetArray(array);
            calc.SetAlreadyHave(m_AlreadyHave.Copy());
            for (int i = 0; i < CalcCount; i++)
            {
                calc.Calc();
            }

            ShowResultForm(calc.Print());
        }
Beispiel #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     Kernal.CSmartArray array = GetAllZakazArray();
     array.Merge(GetAllTrainArray());
     array.Merge(GetAllPlaneArray());
     array.ExcludeWhatHave(m_AlreadyHave.Copy());
     Kernal.CProductCalc calc = new Kernal.CProductCalc();
     calc.SetArray(array);
     calc.SetAlreadyHave(m_AlreadyHave.Copy());
     for (int i = 0; i < CalcCount; i++)
     {
         calc.Calc();
     }
     ShowResultForm(calc.Print());
     Kernal.CExportAllFactoryHelper helper = new Kernal.CExportAllFactoryHelper(calc.GetFactoryList());
 }
Beispiel #7
0
        public void WriteInfoAboutSourceToExcel()
        {
            CProductCalc    productCalc  = new CProductCalc();
            List <CFactory> factList     = productCalc.GetFactoryList();
            Worksheet       pSourceSheet = m_pBook.Worksheets.Add();

            pSourceSheet.Name = GetUniqueSheetName("FullSource");
            int currentRow = 1 + 1;

            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);
                        Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 1, m_Spisok.GetName(tagInput[i]), 20);
                        Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 2, m_Spisok.GetName(pTag), 10);
                        Kernal.Utils.UpdateCell(pSourceSheet, currentRow, 3, TagCount.ToString());
                        currentRow++;
                    }
                }
            }
        }
Beispiel #8
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;
                    }
                }
            }
        }
Beispiel #9
0
        public static CProductCalc Create()
        {
            CProductCalc cProductCalc = new CProductCalc();

            return(cProductCalc);
        }