Ejemplo n.º 1
0
 public void EditDocumentInAnotherWindow(Standart doc)
 {
     var docController = _factory.GetDocumentController<Standart>();
     docController.Document = doc;
     if (docController.ShowViewDialog())
     {
         Save(docController.Document);
         DataRefreshed?.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 2
0
        private void wizardControl1_SelectedPageChanging(object sender, WizardPageChangingEventArgs e)
        {
            if (e.Page == wpUngrouppedPositions)
            {
                var log = new Logger();
                _standart = _controller.CreateStandartByDrawing(log);
                gcUngPositions.DataSource = _standart.Positions;
                lbMessages.DataSource =
                    log.Messages.Select(mess => new MessageListBox() {Tag = mess.Tag, Message = mess.Message}).ToList();
            }

            if (e.Page == wpGrouppedPositions)
            {
                _standart = _controller.GroupPositionsStandart(_standart);
                gcGrpPositions.DataSource = _standart.Positions;
            }
        }
Ejemplo n.º 3
0
        public void CreateReportClearWeights(Standart standart, string fileName)
        {
            var pck = new ExcelPackage();
            var workSheet = pck.Workbook.Worksheets.Add("Чистые веса");
            CreateHeaderBigNorms(workSheet);
            int i = 4;

            workSheet.Cells["A2:J2"].Value = standart.Name;

            foreach (PositionStandart positionStandart in standart.Positions)
            {
                workSheet.Cells["A" + i].Value = i - 3;
                SetStyleToAllLinesSquare(workSheet.Cells["A" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["B" + i].Value = positionStandart.Profile;
                SetStyleToAllLinesSquare(workSheet.Cells["B" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["C" + i].Value = positionStandart.StandartSize;
                SetStyleToAllLinesSquare(workSheet.Cells["C" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["D" + i].Value = string.Empty;
                SetStyleToAllLinesSquare(workSheet.Cells["D" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["E" + i].Value = positionStandart.GostOnSort;
                SetStyleToAllLinesSquare(workSheet.Cells["E" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["F" + i].Value = positionStandart.MarkSteal;
                SetStyleToAllLinesSquare(workSheet.Cells["F" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["G" + i].Value = string.Empty;
                SetStyleToAllLinesSquare(workSheet.Cells["G" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["H" + i].Value = positionStandart.Weight;
                SetStyleToAllLinesSquare(workSheet.Cells["H" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["I" + i].Value = positionStandart.UtilizationRatio;
                SetStyleToAllLinesSquare(workSheet.Cells["I" + i], ExcelBorderStyle.Thin);
                workSheet.Cells["J" + i].Formula = string.Format("=H{0}*I{0}", i);
                SetStyleToAllLinesSquare(workSheet.Cells["J" + i], ExcelBorderStyle.Thin);
                i++;
            }

            workSheet.Cells["G" + i].Value = "Итого: ";
            SetStyleToAllLinesSquare(workSheet.Cells["G" + i], ExcelBorderStyle.Thin);
            workSheet.Cells["H" + i].Formula = $"=SUM(H4:H{i - 1})";
            SetStyleToAllLinesSquare(workSheet.Cells["H" + i], ExcelBorderStyle.Thin);
            workSheet.Cells["J" + i].Formula = $"=SUM(J4:J{i - 1})";
            SetStyleToAllLinesSquare(workSheet.Cells["J" + i], ExcelBorderStyle.Thin);

            pck.SaveAs(new FileInfo(fileName));
        }
Ejemplo n.º 4
0
        public void CreateReportClearWeightsTest()
        {
            var pathFileSave = Path.Combine(Path.GetTempPath(), "UPPY" + Environment.TickCount + ".tmp");
            ExportExcelFile excelFile = new ExportExcelFile();

            Debug.WriteLine(pathFileSave);

            var st = new Standart();
            st.Positions.Add(new PositionStandart() {});
            st.Positions.Add(new PositionStandart() {});
            st.Positions.Add(new PositionStandart() {});
            st.Positions.Add(new PositionStandart() {});

            Assert.DoesNotThrow(() =>
            {
                excelFile.CreateReportClearWeights(st, pathFileSave);
            });
        }
Ejemplo n.º 5
0
 public void Save(Standart document)
 {
     _standartDataManager.InsertOrUpdate(document);
 }
Ejemplo n.º 6
0
 public void Delete(Standart doc)
 {
     _standartDataManager.Delete(doc);
     DataRefreshed?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 7
0
        /// <summary>
        ///     Создать нормы на деталь
        /// </summary>
        /// <param name="headDrawing">Деталь</param>
        /// <param name="dataManager">Дата манагер</param>
        /// <param name="gosts">Список ГОСТов</param>
        /// <returns></returns>
        public Standart CreateStandartByDrawing(Drawing headDrawing, IHierClassDataManager<Drawing> dataManager,
            List<Gost> gosts)
        {
            var allChildrens = dataManager.GetListAllChildrens(headDrawing.Id);
            var allParentId = allChildrens.Select(x => x.ParentId).Distinct();
            var allDetails = allChildrens.AsParallel().Where(x => allParentId.FirstOrDefault(y => y != null && y.Value == x.Id) == null);

            var standart = new Standart();

            foreach (var detail in allDetails)
            {
                var position = new PositionStandart
                {
                    Profile = detail.Profile,
                    StandartSize = detail.StandartSize,
                    GostOnSort = detail.GostOnSort,
                    MarkSteal = detail.MarkSteal,
                    UtilizationRatio = DefaultUtilizationRatio,
                    Weight = 0
                };

                if (string.IsNullOrWhiteSpace(position.Profile))
                    position.Profile = detail.Name;

                var gost =
                    gosts.FirstOrDefault(
                        x =>
                            string.Equals(x.Name.Replace(" ", ""), position.GostOnSort.Replace(" ", ""),
                                StringComparison.CurrentCultureIgnoreCase));

                if (string.IsNullOrWhiteSpace(position.GostOnSort))
                {
                    Log?.AppendMessage("Поле ГОСТ на сортамент не заполнено." + position.GostOnSort, position, TypeMessage.Error);
                    standart.Positions.Add(position);
                    continue;
                }

                if (gost == null)
                {
                    if (ThrowExceptions)
                    {
                        var argEx = new ArgumentException($"Справочник гостов не полный. Отсутствует ГОСТ {position.GostOnSort}.");
                        argEx.Data.Add("detail", detail);
                        throw argEx;
                    }
                    else
                    {
                        position.Note = "Не найден ГОСТ в справочнике, позиция без обработки!";
                        Log?.AppendMessage("Не найден ГОСТ " + position.GostOnSort, position, TypeMessage.Error);
                        standart.Positions.Add(position);
                        continue;
                    }
                }

                switch (gost.TypeExtraDimension)
                {
                        case ExtraDimensions.Meters:
                        case ExtraDimensions.SquareMeter:

                        switch (gost.WeightMethodCalculate)
                        {
                            case WeightMethodCalculate.LengthAndWidth:

                                if (detail.Length.HasValue && detail.Width.HasValue && !string.IsNullOrEmpty(position.StandartSize))
                                {
                                    position.AdditionalMeasurement = (double)(((double)detail.Length * detail.Width) / 1000 / 1000 *
                                                                               detail.CountAll);
                                    position.Weight = position.AdditionalMeasurement * ConvertStandartSize(position.StandartSize) *
                                                      Density;
                                    position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                    position.Note = $"{(double)detail.Length} x {(double)detail.Width} x {detail.CountAll}";
                                }
                                else
                                {
                                    Log?.AppendMessage("Поля Длина и/или Ширина и/или Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                }
                                break;
                            case WeightMethodCalculate.Length:
                                if (detail.Length.HasValue && !string.IsNullOrEmpty(position.StandartSize))
                                {
                                    var dimensions = position.StandartSize.ToUpper().Split(SplittersStandartSize.ToArray());
                                    position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                    position.AdditionalMeasurement = ((double)detail.Length) / 1000 * detail.CountAll;
                                    position.Weight = Math.PI * Math.Pow(ConvertStandartSizeByDelim(dimensions[0]), 2) / 4000 *
                                                      position.AdditionalMeasurement * Density;
                                }
                                else
                                {
                                    Log?.AppendMessage("Поля не Длина и/или Ширина и/или Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                }
                                break;
                            case WeightMethodCalculate.ByTable:
                                if (detail.Length.HasValue && !string.IsNullOrEmpty(position.StandartSize))
                                {
                                    position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                    position.AdditionalMeasurement = ((double)detail.Length.Value) / 1000 * detail.CountAll;
                                    var weigthByTable = gost.GetStandartWeight(position.StandartSize);
                                    if (weigthByTable != null)
                                        position.Weight = weigthByTable.Weight * position.AdditionalMeasurement;
                                    else
                                    {
                                        Log?.AppendMessage(
                                            $"Не заполнен табличный типоразмер для ГОСТа {gost.Name} и типоразмера {position.StandartSize}");
                                    }
                                }
                                else
                                {
                                    Log?.AppendMessage("Поле Длина и/или Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                }
                                break;
                            case WeightMethodCalculate.LengthAndThikness:


                                if (!string.IsNullOrEmpty(position.StandartSize))
                                {
                                    var splStSize = position.StandartSize.ToUpper().Split(SplittersStandartSize.ToArray());
                                    var outerSize = splStSize[0];
                                    var widthWall = splStSize[1];

                                    if (detail.Length.HasValue)
                                    {
                                        if (!string.IsNullOrEmpty(outerSize) && !string.IsNullOrEmpty(widthWall))
                                        {
                                            position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                            position.AdditionalMeasurement = ((double)detail.Length) / 1000 * detail.CountAll;
                                            position.Weight = (Convert.ToDouble(outerSize) - Convert.ToDouble(widthWall)) *
                                                              Convert.ToDouble(widthWall) / 40.55 *
                                                              position.AdditionalMeasurement;
                                        }
                                        else
                                        {
                                            Log?.AppendMessage("Поле Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                        }
                                    }
                                    else
                                    {
                                        Log?.AppendMessage("Поле Длина не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                    }
                                }
                                else
                                {
                                    Log?.AppendMessage("Поле Типоразмер не заполнено");
                                }


                                break;
                            case WeightMethodCalculate.LengthAndDoubleThikness:

                                if (detail.Length.HasValue && !string.IsNullOrEmpty(position.StandartSize))
                                {
                                    position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                                    position.AdditionalMeasurement = ((double)detail.Length) / 1000 * detail.CountAll;
                                    position.Weight = position.AdditionalMeasurement * ConvertStandartSize(position.StandartSize) *
                                                      ConvertStandartSize(position.StandartSize) * Density / 1000;
                                }
                                else
                                {
                                    Log?.AppendMessage("Поле Длина и/или Типоразмер не заполнено в соответствии выбранному методу вычисления по типу ГОСТа " + gost.Name);
                                }
                                break;
                        }

                        position.WeightWithWaste = position.Weight / position.UtilizationRatio;
                        position.AdditionalMeasurementWithWaste = position.AdditionalMeasurement /
                                                                  position.UtilizationRatio;

                        break;

                        case ExtraDimensions.Piece:
                        position.Weight = 0;
                        position.WeightWithWaste = 0;
                        position.UtilizationRatio = 1;

                        position.TypeAdditionalMeasurement = gost.TypeExtraDimension;
                        position.AdditionalMeasurement = detail.CountAll;
                        position.AdditionalMeasurementWithWaste = detail.CountAll;
                        break;
                }

                standart.Positions.Add(position);
            }

            return standart;
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Сгруппировать позиции нормы на сборку
        /// </summary>
        /// <param name="standart"></param>
        /// <returns></returns>
        public Standart GroupAndSumPositionsStandart(Standart standart)
        {
            var grouppedPositionStandart = new Standart();
            grouppedPositionStandart.Id = standart.Id;
            grouppedPositionStandart.Name = standart.Name;
            grouppedPositionStandart.Drawing = standart.Drawing;
            grouppedPositionStandart.UtilizationRatio = standart.UtilizationRatio;

            grouppedPositionStandart.Positions = (from tempPosition in standart.Positions
                                                  orderby tempPosition.Profile, tempPosition.StandartSize, tempPosition.GostOnSort, tempPosition.MarkSteal
                                                  group tempPosition by
                                                      new
                                                      {
                                                          tempPosition.Profile,
                                                          tempPosition.StandartSize,
                                                          tempPosition.GostOnSort,
                                                          tempPosition.MarkSteal,
                                                          tempPosition.TypeAdditionalMeasurement
                                                      }
                into grPosition
                                                  select new PositionStandart
                                                  {
                                                      Profile = grPosition.Key.Profile,
                                                      StandartSize = grPosition.Key.StandartSize,
                                                      GostOnSort = grPosition.Key.GostOnSort,
                                                      MarkSteal = grPosition.Key.MarkSteal,
                                                      TypeAdditionalMeasurement = grPosition.Key.TypeAdditionalMeasurement,
                                                      AdditionalMeasurement = grPosition.Sum(x => x.AdditionalMeasurement),
                                                      AdditionalMeasurementWithWaste = grPosition.Sum(x => x.AdditionalMeasurementWithWaste) ,
                                                      Weight = grPosition.Sum(x => x.Weight),
                                                      WeightWithWaste = grPosition.Sum(x => x.WeightWithWaste),
                                                      UtilizationRatio = DefaultUtilizationRatio,
                                                      Note = string.Empty
                                                  }).ToList();

            return grouppedPositionStandart;
        }
Ejemplo n.º 9
0
        public void CreateReportLZK(Standart standart)
        {
            var pck = new ExcelPackage();
            var workSheet = pck.Workbook.Worksheets.Add("Чистые веса");
            CreateHeaderBigNorms(workSheet);
            int i = 4;

            workSheet.Cells["A2:J2"].Value = standart.Name;

            foreach (var positionStandart in standart.Positions)
            {

            }
        }
Ejemplo n.º 10
0
 public void Save(Standart standart)
 {
     _dataManagersFactory.GetDataManager<Standart>().InsertOrUpdate(standart);
 }
Ejemplo n.º 11
0
 public Standart GroupPositionsStandart(Standart standart)
 {
     var helper = new DrawingsToStandartHelper();
     standart = helper.GroupAndSumPositionsStandart(standart);
     return standart;
 }