Example #1
0
        private static string GetFactoryName(int tripId)
        {
            string         sFactoryName = "";
            PlannerDataSet ds           = new PlannerDataSet();

            PlannerDataSetTableAdapters.FactoriesTableAdapter adapt = new PlannerDataSetTableAdapters.FactoriesTableAdapter();
            adapt.FillByTrip(ds.Factories, tripId);

            if (ds.Factories.Count > 0)
            {
                sFactoryName = ds.Factories[0].Name;
            }

            return(sFactoryName);
        }
Example #2
0
        private static Order ConvertToOrderFromPlanner(DataRow row, PlannerDataSet.PlannerAssignmentsDataTable table)
        {
            Order          order   = new Order();
            PlannerDataSet dataset = new PlannerDataSet();

            order.Id = Convert.ToInt64(row[table.OrderIdColumn.ColumnName]);

            order.Reference = row[table.ReferenceColumn.ColumnName].ToString();

            order.StartDate    = (DateTime)row[table.StartDateColumn.ColumnName];
            order.FinalDate    = (DateTime)row[table.FinalDateColumn.ColumnName];
            order.CreatedDate  = (DateTime)row[table.CreatedDateColumn.ColumnName];
            order.ModifiedDate = (DateTime)row[table.ModifiedDateColumn.ColumnName];

            if (string.IsNullOrEmpty(row[table.TripIdColumn.ColumnName].ToString()))
            {
                order.TripId = 0;
            }
            else
            {
                order.TripId = Convert.ToInt32(row[table.TripIdColumn.ColumnName].ToString());
            }


            order.HexColor = GetColorLoaded(Convert.ToInt32(order.TripId.ToString()));


            LocationData location = new LocationData();

            location.Address  = row[table.AddressColumn.ColumnName].ToString();
            location.City     = row[table.CityColumn.ColumnName].ToString();
            location.PostCode = row[table.PostCodeColumn.ColumnName].ToString();
            location.Province = row[table.ProvinceColumn.ColumnName].ToString();
            location.Country  = row[table.CountryColumn.ColumnName].ToString();


            float.TryParse(row[table.LatitudeColumn.ColumnName].ToString(), out float loc);
            location.Latitude = loc;

            float.TryParse(row[table.LongitudeColumn.ColumnName].ToString(), out loc);
            location.Longitude = loc;

            order.Location = location;

            Int32.TryParse(row[table.VehicleSizeColumn.ColumnName].ToString(), out int num);
            order.VehicleType = num;

            Int32.TryParse(row[table.RequestedAmountColumn.ColumnName].ToString(), out num);
            order.RequestedAmount = num;

            Int32.TryParse(row[table.ReceivedAmountColumn.ColumnName].ToString(), out num);
            order.ReceivedAmount = num;

            //si la cantidad recivida no tiene valor se coje la que se espera requestedAmount
            if (order.ReceivedAmount == 0)
            {
                Int32.TryParse(row[table.RequestedAmountColumn.ColumnName].ToString(), out num);
                order.ReceivedAmount = num;
            }

            //aqui
            order.TankNum    = row[table.TankNumColumn.ColumnName].ToString();
            order.TankVolume = row[table.TankVolumeColumn.ColumnName].ToString();
            order.TankLevel  = row[table.TankLevelColumn.ColumnName].ToString();
            order.Status     = row[table.StatusColumn.ColumnName] as int? ?? 0;
            //order.Description = row[table.DescriptionColumn.ColumnName].ToString();
            //order.Observations = row[table.ObservationsColumn.ColumnName].ToString();


            //operadores


            PlannerDataSetTableAdapters.OperatorsTableAdapter operatoradapter = new PlannerDataSetTableAdapters.OperatorsTableAdapter();
            PlannerDataSet.OperatorsDataTable dataTableOperators = operatoradapter.GetDataByOperatorId(Convert.ToInt32(row[table.OperatorIdColumn.ColumnName]));



            order.Operator = new Operator()
            {
                Id   = Convert.ToInt32(row[table.OperatorIdColumn.ColumnName]),
                Code = dataTableOperators.Rows[0]["Code"].ToString(),
                Name = dataTableOperators.Rows[0]["Name"].ToString(),
                Cif  = dataTableOperators.Rows[0]["Cif"].ToString(),

                Location = new LocationData()
                {
                    Address  = dataTableOperators.Rows[0]["Address"].ToString(),
                    City     = dataTableOperators.Rows[0]["City"].ToString(),
                    PostCode = dataTableOperators.Rows[0]["PostCode"].ToString(),
                    Province = dataTableOperators.Rows[0]["Province"].ToString(),
                    Country  = dataTableOperators.Rows[0]["Country"].ToString(),
                },

                Contact = new ContactData()
                {
                    Name        = dataTableOperators.Rows[0]["Name"].ToString(),
                    Phone       = dataTableOperators.Rows[0]["Phone"].ToString(),
                    Phone2      = dataTableOperators.Rows[0]["Phone2"].ToString(),
                    PhoneMobile = dataTableOperators.Rows[0]["PhoneMobile"].ToString(),
                    Fax         = dataTableOperators.Rows[0]["Fax"].ToString(),
                    Email       = dataTableOperators.Rows[0]["Email"].ToString()
                },


                Enabled = (bool)dataTableOperators.Rows[0]["Enabled"],
                //Observations = row[table.ClientObservationsColumn.ColumnName].ToString(),
            };


            //clientes

            PlannerDataSetTableAdapters.ClientsTableAdapter adapter = new PlannerDataSetTableAdapters.ClientsTableAdapter();
            PlannerDataSet.ClientsDataTable dataTableClients        = adapter.GetDataByIdClient(Convert.ToInt32(row[table.ClientIdColumn.ColumnName]));

            order.Client = new Client()
            {
                Id   = Convert.ToInt32(dataTableClients.Rows[0]["Id"].ToString()),
                Code = dataTableClients.Rows[0]["Code"].ToString(),
                Name = dataTableClients.Rows[0]["Name"].ToString(),
                Cif  = dataTableClients.Rows[0]["Cif"].ToString(),

                Location = new LocationData()
                {
                    Address  = dataTableClients.Rows[0]["Address"].ToString(),
                    City     = dataTableClients.Rows[0]["City"].ToString(),
                    PostCode = dataTableClients.Rows[0]["PostCode"].ToString(),
                    Province = dataTableClients.Rows[0]["Province"].ToString(),
                    Country  = dataTableClients.Rows[0]["Country"].ToString(),

                    Latitude  = (float)dataTableClients.Rows[0]["Latitude"],
                    Longitude = (float)dataTableClients.Rows[0]["Longitude"],
                },

                Contact = new ContactData()
                {
                    Name        = dataTableClients.Rows[0]["Name"].ToString(),
                    Phone       = dataTableClients.Rows[0]["Phone"].ToString(),
                    Phone2      = dataTableClients.Rows[0]["Phone2"].ToString(),
                    PhoneMobile = dataTableClients.Rows[0]["PhoneMobile"].ToString(),
                    Fax         = dataTableClients.Rows[0]["Fax"].ToString(),
                    Email       = dataTableClients.Rows[0]["Email"].ToString()
                },


                Enabled = (bool)dataTableClients.Rows[0]["Enabled"],
                //Observations = row[table.ClientObservationsColumn.ColumnName].ToString(),
            };


            //factorias

            PlannerDataSetTableAdapters.FactoriesTableAdapter factoryadapter = new PlannerDataSetTableAdapters.FactoriesTableAdapter();
            PlannerDataSet.FactoriesDataTable factory = factoryadapter.GetDataByIdFactory(Convert.ToInt32(row[table.FactoryIdColumn.ColumnName]));


            order.Factory = new Factory()
            {
                Id   = Convert.ToInt32(factory.Rows[0]["Id"].ToString()),
                Code = factory.Rows[0]["Code"].ToString(),
                Name = factory.Rows[0]["Name"].ToString(),

                HexColor = GetColorFactory(Convert.ToInt32(row[table.FactoryIdColumn.ColumnName].ToString())),

                Location = new LocationData()
                {
                    Address  = factory.Rows[0]["Address"].ToString(),
                    City     = factory.Rows[0]["City"].ToString(),
                    PostCode = factory.Rows[0]["PostCode"].ToString(),
                    Province = factory.Rows[0]["Province"].ToString(),
                    Country  = factory.Rows[0]["Country"].ToString(),

                    Latitude  = (float)factory.Rows[0]["Latitude"],
                    Longitude = (float)factory.Rows[0]["Longitude"],
                },


                Enabled = (bool)factory.Rows[0]["Enabled"],
                //Observations = row[table.FactoryObservationsColumn.ColumnName].ToString(),
            };

            //producto
            PlannerDataSetTableAdapters.ProductsTableAdapter productsadapter = new PlannerDataSetTableAdapters.ProductsTableAdapter();
            PlannerDataSet.ProductsDataTable product = productsadapter.GetDataProductId(Convert.ToInt32(row[table.ProductIdColumn.ColumnName]));

            order.Product = new Product()
            {
                Id   = Convert.ToInt32(product.Rows[0]["Id"].ToString()),
                Code = product.Rows[0]["Code"].ToString(),
                Name = product.Rows[0]["Name"].ToString(),

                Density     = 4,
                MeasureUnit = 4,
            };


            order.SizeName = VehicleType.GetVehicleSizeName((int)order.VehicleType);

            //actualizamos el estado del pedido a planificado
            //UpdateStatusOrders(order.Id);


            return(order);
        }