コード例 #1
0
        private void btGenerarReporte_Click(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show(DateTime.Now.ToString("yyyy-dd-MM"));

            if (LocaleDatePickerDe.Text != "" && LocaleDatePickerHasta.Text != "")
            {
                DateTime dt_1 = Convert.ToDateTime(LocaleDatePickerDe.Text);
                DateTime dt_2 = Convert.ToDateTime(LocaleDatePickerHasta.Text);

                if (dt_1 > dt_2)
                {
                    MessageBox.Show("La primera fecha tiene que ser menor a la segunda");
                }
                else
                {
                    DateTime fecha_1 = new DateTime(dt_1.Year, dt_1.Month, dt_1.Day, 0, 0, 0);
                    DateTime fecha_2 = new DateTime(dt_2.Year, dt_2.Month, dt_2.Day, 0, 0, 0);
                    MyDataGridReportProduc.ItemsSource = ReportsList.rangoFechasProducto(fecha_1, fecha_2);
                }
            }
            else
            {
                MessageBox.Show("Para realizar un reporte las fechas debe tener datos.");
            }
        }
コード例 #2
0
        private List <GeoCoordinate> RecenterClusters(List <GeoCoordinate> clustersIdList)
        {
            //Recenter the clusters
            ReportsList = ReportsList.OrderBy(c => c.ClusterId).ToList();
            int    id = 0;
            double clustersLongitudeSum = 0;
            double clustersLatitudeSum  = 0;
            int    counter = 0;

            for (int i = 0; i < ReportsList.Count; i++)
            {
                if (ReportsList[i].ClusterId == id)
                {
                    clustersLatitudeSum  += ReportsList[i].GetCoordinate().Latitude;
                    clustersLongitudeSum += ReportsList[i].GetCoordinate().Longitude;
                    counter++;
                }
                else if (ReportsList[i].ClusterId != id)
                {
                    clustersIdList[id].Latitude  = clustersLatitudeSum / counter;
                    clustersIdList[id].Longitude = clustersLongitudeSum / counter;
                    counter = 0;
                    clustersLongitudeSum = 0;
                    clustersLatitudeSum  = 0;
                    i--;
                    id++;
                }
            }
            clustersIdList[id].Latitude  = clustersLatitudeSum / counter;
            clustersIdList[id].Longitude = clustersLongitudeSum / counter;
            return(clustersIdList);
        }
コード例 #3
0
 public FileStreamResult OnPostExportReport()
 {
     if (ModelState.IsValid)
     {
         var reportName   = ReportsList.FirstOrDefault(x => x.Value == SelectedReport)?.Text;
         var memoryStream = _reportingService.ExportReport(SelectedReport, reportName);
         return(GetFileStream(memoryStream, $"{SelectedReport}_{DateTime.UtcNow.ToFileTimeUtc()}.xlsx"));
     }
     return(null);
 }
コード例 #4
0
 private void btCrearReporteSemana_Click(object sender, RoutedEventArgs e)
 {
     //Semana
     if (LocaleDatePickerSemana.Text != "")
     {
         MyDataGridVentas.ItemsSource = ReportsList.rangoFechasVentasSemana(ReportsList.AltFecha(LocaleDatePickerSemana.Text));
     }
     else
     {
         MessageBox.Show("La fecha del Semana no puede estar vacia");
     }
 }
コード例 #5
0
        public ReportsList GetAllReports()
        {
            var table       = GetData("SELECT * FROM Reports");
            var reportsList = new ReportsList();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                Report report = new Report(table.Rows[i]);
                reportsList.reports.Add(report);
            }

            return(reportsList);
        }
コード例 #6
0
        private List <GeoCoordinate> ClustersGenerator()
        {
            List <GeoCoordinate> clustersIdList = new List <GeoCoordinate>();

            double minLatitude  = ReportsList.Min(r => r.GetCoordinate().Latitude);
            double maxLatitude  = ReportsList.Max(r => r.GetCoordinate().Latitude);
            double minLongitude = ReportsList.Min(r => r.GetCoordinate().Longitude);
            double maxLongitude = ReportsList.Max(r => r.GetCoordinate().Longitude);

            for (int i = 0; i < K; i++)
            {
                double        latitude   = minLatitude + rand.NextDouble() * (maxLatitude - minLatitude);
                double        longitude  = minLongitude + rand.NextDouble() * (maxLongitude - minLongitude);
                GeoCoordinate coordinate = new GeoCoordinate(latitude, longitude);
                clustersIdList.Add(coordinate);
            }

            return(clustersIdList);
        }
コード例 #7
0
        private void FillTable()
        {
            organisations = Program.dataManager.GetFilteredOrganisations
                                ("SELECT * FROM Organisations WHERE law = 2 AND contractType = 1");
            reportsList = Program.dataManager.GetReportsList();

            foreach (var org in organisations)
            {
                if (org != null)
                {
                    int rowIndex = dataGridView1.Rows.Add();
                    var newRow   = dataGridView1.Rows[rowIndex];

                    var report = reports.SingleOrDefault(rep => rep.organisationID == org.id);

                    newRow.Cells["organisationID"].Value = org.id;
                    newRow.Cells["inn"].Value            = org.inn;
                    newRow.Cells["name"].Value           = org.name;
                }
            }

            // RecolorTable();
            RecheckTable();
        }
コード例 #8
0
        public List <GeoCoordinate> K_Means()
        {
            if (ReportsList.Count == 0)
            {
                return(null);
            }

            List <GeoCoordinate> clustersIdList = ClustersGenerator();

            bool isChanged;

            do
            {
                isChanged = false;

                //for each report looking for the closest cluster
                for (int i = 0; i < ReportsList.Count; i++)
                {
                    double min = Double.MaxValue;

                    for (int j = 0; j < clustersIdList.Count; j++)
                    {
                        double temp = ReportsList[i].GetCoordinate().GetDistanceTo(clustersIdList[j]);
                        if (temp < min)
                        {
                            min = temp;
                            ReportsList[i].ClusterIdNumber = j;
                        }
                    }
                }

                //Recenter the clusters
                ReportsList.OrderBy(c => c.ClusterIdNumber);
                double clustersLongitudeSum = 0;
                double clustersLatitudeSum = 0;
                double oldLat = 0, oldLong = 0;
                int    counter = 0;
                for (int id = 0; id < clustersIdList.Count; id++)
                {
                    for (int i = 0; i < ReportsList.Count; i++)
                    {
                        if (ReportsList[i].ClusterIdNumber == id)
                        {
                            clustersLatitudeSum  += ReportsList[i].GetCoordinate().Latitude;
                            clustersLongitudeSum += ReportsList[i].GetCoordinate().Longitude;
                            counter++;
                        }
                    }
                    oldLat  = clustersIdList[id].Latitude;
                    oldLong = clustersIdList[id].Longitude;
                    clustersIdList[id].Latitude  = counter == 0 ? 0 : clustersLatitudeSum / counter;
                    clustersIdList[id].Longitude = counter == 0 ? 0 : clustersLongitudeSum / counter;
                    if (clustersIdList[id].Longitude != oldLong || clustersIdList[id].Latitude != oldLat)
                    {
                        isChanged = true;
                    }
                    clustersLongitudeSum = 0;
                    clustersLatitudeSum  = 0;
                    counter = 0;
                }
            } while (isChanged);

            return(clustersIdList);
        }
コード例 #9
0
 public void refreshReportes()
 {
     MyDataGridReportProduc.ItemsSource = ReportsList.listarProductos();
     MyDataGridVentas.ItemsSource       = ReportsList.listarVentas();
 }
コード例 #10
0
 private void btRestaurarVentas_Click(object sender, RoutedEventArgs e)
 {
     MyDataGridVentas.ItemsSource = ReportsList.listarVentas();
 }
コード例 #11
0
 private void btRestaurarProductos_Click(object sender, RoutedEventArgs e)
 {
     MyDataGridReportProduc.ItemsSource = ReportsList.listarProductos();
 }
コード例 #12
0
        public void Add <T>(T model)
        {
            var theType = model.GetType().Name;

            switch (theType)
            {
            case "User": UsersList.Add(model as User); return;

            case "News": NewsesList.Add(model as Dal.Models.News); return;

            case "Category": CategoriesList.Add(model as Category); return;

            case "Magazine": MagazinesList.Add(model as Magazine); return;

            case "SmartLink": SmartLinksList.Add(model as SmartLink); return;

            case "Comment": CommentsList.Add(model as Comment); return;

            case "Visit": VisitsList.Add(model as Visit); return;

            case "NewsLetter": NewsLettersList.Add(model as NewsLetter); return;

            case "Slider": SlidersList.Add(model as Slider); return;

            case "Slide": SlidesList.Add(model as Slide); return;

            case "UserMagazine": UserMagazinesList.Add(model as UserMagazine); return;

            case "State": StatesList.Add(model as State); return;

            case "City": CitiesList.Add(model as City); return;

            case "Media": MediasList.Add(model as Media); return;

            case "Report": ReportsList.Add(model as Report); return;

            case "Vote": VotesList.Add(model as Vote); return;

            case "Advertise": AdvertisesList.Add(model as Advertise); return;

            case "AdCategory": AdCategoriesList.Add(model as AdCategory); return;

            case "Galery": GaleriesList.Add(model as Galery); return;

            case "GaleryImage": GaleryImagesList.Add(model as GaleryImage); return;

            case "Image": ImagesList.Add(model as Image); return;

            case "KeyPoint": KeyPointsList.Add(model as KeyPoint); return;

            case "KeyPointsContainer": KeyPointsContainersList.Add(model as KeyPointsContainer); return;

            case "Quiz": QuizesList.Add(model as Quiz); return;

            case "Question": QuestionsList.Add(model as Question); return;

            case "Answer": AnswersList.Add(model as Answer); return;

            case "Option": OptionList.Add(model as Option); return;

            case "ItemList": ItemsListList.Add(model as ItemList); return;

            default: throw new Exception("The type " + theType + " is not supported.");
            }
        }