Пример #1
0
        static void StatisticCoefficientK1K2()
        {
            C_Flats_PIK1_AreasTableAdapter pikFlats = new C_Flats_PIK1_AreasTableAdapter();
            var flatsAreas = new PIK1.C_Flats_PIK1_AreasDataTable();

            flatsAreas = pikFlats.GetData();

            DBService dbServ = new DBService(null);

            dbServ.LoadDbFlatsFromFile();
            //var sections = DBService.dictDbFlats.Values.SelectMany(s => s).ToList();

            // Шагов, этажность , секция, кол квартир, К1, К2
            var sectCoeffsK1K2 = new List <Tuple <SelectSectionParam, string, int, double, double, string> >();

            foreach (var item in DBService.dictDbFlats)
            {
                var    sectBySize      = item.Value;
                double levelArea       = 0;
                double levelAreaOffLLU = 0;
                double levelAreaOnLLU  = 0;

                foreach (var sect in sectBySize)
                {
                    string          sectString = string.Empty;
                    List <RoomInfo> rooms      = new List <RoomInfo>();
                    foreach (var flat in sect)
                    {
                        var ri = flat.GetRoomInfo();
                        ri.CodeReqIndex = GetRoomCode(ri);
                        rooms.Add(ri);
                        var currentFlatAreas = flatsAreas.First(x => x.Short_Type.Equals(flat.ShortType));
                        var areas            = Calculate.GetAreaFlat(15, ri, currentFlatAreas);
                        levelArea       += areas[2];
                        levelAreaOffLLU += areas[3];
                        levelAreaOnLLU  += areas[4];
                        sectString      += flat.ShortType + "_";
                    }
                    var k1 = levelAreaOffLLU / levelArea;
                    var k2 = levelAreaOffLLU / levelAreaOnLLU;

                    string code = GetCodeSection(rooms);

                    sectCoeffsK1K2.Add(new Tuple <SelectSectionParam, string, int, double, double, string>(
                                           item.Key, sectString, sect.Count - 1, k1, k2, code));
                }
            }

            using (var xlPackage = new ExcelPackage())
            {
                DoubleEqualityComparer doubleComparer = new DoubleEqualityComparer(0.01);
                var wsK1 = xlPackage.Workbook.Worksheets.Add("К1");
                FillCoefK(sectCoeffsK1K2, wsK1, "К1", (k) => k.GroupBy(g => g.Item4, doubleComparer));
                var wsK2 = xlPackage.Workbook.Worksheets.Add("К2");
                FillCoefK(sectCoeffsK1K2, wsK2, "К2", (k) => k.GroupBy(g => g.Item5, doubleComparer));
                xlPackage.SaveAs(new FileInfo("BankSectionsCoeficientK1K2.xlsx"));
            }
        }
Пример #2
0
        public MainForm()
        {
            InitializeComponent();
            btnMenuGroup1.Image = Properties.Resources.up;
            btnMenuGroup2.Image = Properties.Resources.up;
            btnMenuGroup3.Image = Properties.Resources.up;

            var pikFlats = new C_Flats_PIK1_AreasTableAdapter();

            flatsAreas     = pikFlats.GetData();
            dictFlatsAreas = flatsAreas.ToDictionary(k => k.Short_Type, v => v);
            var flatsTableAdapter = new C_Flats_PIK1TableAdapter();

            dbFlats = flatsTableAdapter.GetData();
        }
Пример #3
0
        static void ExportFlatsAreas(string excelPath)
        {
            FrameWork fw = new FrameWork();
            C_Flats_PIK1_AreasTableAdapter flatsPik1Areas = new C_Flats_PIK1_AreasTableAdapter();
            var flatsAreas = flatsPik1Areas.GetData();

            using (var xlPackage = new ExcelPackage(new FileInfo(excelPath)))
            {
                int counter   = 2;
                var worksheet = xlPackage.Workbook.Worksheets[2];
                while (worksheet.Cells[counter, 1].Value != null)
                {
                    string shortType                       = Convert.ToString(worksheet.Cells[counter, 2].Value);
                    double area_Total_Low18                = fw.DoubleConvert(worksheet.Cells[counter, 4].Value);
                    double area_Total_Standart_More18      = fw.DoubleConvert(worksheet.Cells[counter, 5].Value);
                    double area_Total_Strong_More18        = fw.DoubleConvert(worksheet.Cells[counter, 6].Value);
                    double area_Total_End_Low18            = fw.DoubleConvert(worksheet.Cells[counter, 7].Value);
                    double area_Total_Standart_End_More18  = fw.DoubleConvert(worksheet.Cells[counter, 8].Value);
                    double area_Total_Strong_End_More18    = fw.DoubleConvert(worksheet.Cells[counter, 9].Value);
                    double area_Total_Standart_Seam_Low18  = fw.DoubleConvert(worksheet.Cells[counter, 10].Value);
                    double area_Total_Standart_Seam_More18 = fw.DoubleConvert(worksheet.Cells[counter, 11].Value);
                    double area_Total_Strong_Seam_More18   = fw.DoubleConvert(worksheet.Cells[counter, 12].Value);
                    string correction_Low18                = Convert.ToString(worksheet.Cells[counter, 13].Value);
                    string correction_More18               = Convert.ToString(worksheet.Cells[counter, 14].Value);
                    double area_Live_Low18                 = fw.DoubleConvert(worksheet.Cells[counter, 15].Value);
                    double area_Live_Standart_More18       = fw.DoubleConvert(worksheet.Cells[counter, 16].Value);
                    double area_Live_Strong_More18         = fw.DoubleConvert(worksheet.Cells[counter, 17].Value);
                    double area_Live_End_Low18             = fw.DoubleConvert(worksheet.Cells[counter, 18].Value);
                    double area_Live_Standart_End_More18   = fw.DoubleConvert(worksheet.Cells[counter, 19].Value);
                    double area_Live_Strong_End_More18     = fw.DoubleConvert(worksheet.Cells[counter, 20].Value);
                    double area_Live_Seam_Low18            = fw.DoubleConvert(worksheet.Cells[counter, 21].Value);
                    double area_Live_Standart_Seam_More18  = fw.DoubleConvert(worksheet.Cells[counter, 22].Value);
                    double area_Live_Strong_Seam_More18    = fw.DoubleConvert(worksheet.Cells[counter, 23].Value);
                    double area_Level_Combo                = fw.DoubleConvert(worksheet.Cells[counter, 24].Value);
                    double area_Level_End                  = fw.DoubleConvert(worksheet.Cells[counter, 25].Value);
                    double area_Level_Seam                 = fw.DoubleConvert(worksheet.Cells[counter, 26].Value);
                    double area_OutFlat_Combo              = fw.DoubleConvert(worksheet.Cells[counter, 27].Value);
                    double area_OutFlat_Strong             = fw.DoubleConvert(worksheet.Cells[counter, 28].Value);
                    if (flatsAreas.Any(x => x.Short_Type.Equals(shortType)))
                    {
                        flatsPik1Areas.UpdateAreaFlat(area_Total_Low18, area_Total_Standart_More18,
                                                      area_Total_Strong_More18, area_Total_End_Low18, area_Total_Standart_End_More18,
                                                      area_Total_Strong_End_More18, area_Total_Standart_Seam_Low18, area_Total_Standart_Seam_More18,
                                                      area_Total_Strong_Seam_More18,
                                                      correction_Low18, correction_More18, area_Live_Low18, area_Live_Standart_More18,
                                                      area_Live_Strong_More18,
                                                      area_Live_End_Low18, area_Live_Standart_End_More18, area_Live_Strong_End_More18,
                                                      area_Live_Seam_Low18, area_Live_Standart_Seam_More18,
                                                      area_Live_Strong_Seam_More18, area_Level_Combo, area_Level_End, area_Level_Seam, area_OutFlat_Combo, area_OutFlat_Strong, shortType);
                    }
                    else
                    {
                        flatsPik1Areas.Insert(shortType, area_Total_Low18, area_Total_Standart_More18,
                                              area_Total_Strong_More18, area_Total_End_Low18, area_Total_Standart_End_More18,
                                              area_Total_Strong_End_More18, area_Total_Standart_Seam_Low18, area_Total_Standart_Seam_More18,
                                              area_Total_Strong_Seam_More18,
                                              correction_Low18, correction_More18, area_Live_Low18, area_Live_Standart_More18,
                                              area_Live_Strong_More18,
                                              area_Live_End_Low18, area_Live_Standart_End_More18, area_Live_Strong_End_More18,
                                              area_Live_Seam_Low18, area_Live_Standart_Seam_More18,
                                              area_Live_Strong_Seam_More18, area_Level_Combo, area_Level_End, area_Level_Seam, area_OutFlat_Combo, area_OutFlat_Strong, 0);
                    }

                    counter++;
                }
            }
        }