Beispiel #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var sv = new Journey1SoapClient();

            if (btnAdd.Text == "Add")
            {
                btnUpdate.Enabled = false;
                btnAdd.Text       = "Save";
                btnExit.Text      = "Cancel";

                ClearControl();
                UnlockControl();

                return;
            }

            if (btnAdd.Text == "Save")
            {
                if (txtTimeProvide.Text == "")
                {
                    MessageBox.Show("You must enter all fields", "notification");
                    return;
                }
                else
                {
                    btnAdd.Text  = "Add";
                    btnExit.Text = "Exit";
                    LockControl();
                    bool  status    = false;
                    int   idbeginPo = (int)cbxBeginpo.EditValue;
                    int   idendPo   = (int)cbxEndPo.EditValue;
                    float timepro   = float.Parse(txtTimeProvide.Text);
                    //   bool status = false;

                    sv.inserttrip(IDboat, idbeginPo, idendPo, timepro, dateTimeBegin.Value, dateTimeEnd.Value, status);
                    if (status == false)
                    {
                        var sv1        = new Position1SoapClient();
                        var sv2        = new Journey1SoapClient();
                        var sv3        = new ServicePortNationalSoapClient();
                        var journeyNew = sv2.GetTrip(IDboat).OrderByDescending(p => p.ID).FirstOrDefault();
                        var port       = sv3.GetPortByID((int)journeyNew.BeginPosition);
                        sv1.UpdatePosition(journeyNew.ID, (float)(port.Longitude), (float)(port.Latitude), DateTime.Now, port.Ocean);
                    }

                    MessageBox.Show("Add successfully!");

                    LoaDgvTrip(IDboat);
                }
            }
        }
Beispiel #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var sv     = new Journey1SoapClient();
            int idtrip = (int)gridTrip.GetFocusedRowCellValue("ID");
            var trip   = sv.GetTripId(idtrip);

            if (btnUpdate.Text == "Update")
            {
                btnUpdate.Text = "Save";
                btnExit.Text   = "Cancel";


                UnlockControl();

                return;
            }

            if (btnUpdate.Text == "Save")
            {
                btnUpdate.Text = "Update";
                btnExit.Text   = "Exit";
                LockControl();
                bool  status    = false;
                int   idbeginPo = (int)cbxBeginpo.EditValue;
                int   idendPo   = (int)cbxEndPo.EditValue;
                float timepro   = float.Parse(txtTimeProvide.Text);
                if (cbxSatus.Text == "Complete")
                {
                    status = true;
                    var sv1 = new Position1SoapClient();

                    var sv3 = new ServicePortNationalSoapClient();

                    var port = sv3.GetPortByID((int)trip.EndPosition);
                    sv1.UpdatePosition((int)trip.ID, (float)(port.Longitude), (float)(port.Latitude), DateTime.Now, port.Ocean);
                }
                else
                {
                    status = false;
                }

                sv.UpdateTrip(idtrip, IDboat, idbeginPo, idendPo, timepro, dateTimeBegin.Value, dateTimeEnd.Value, status);
                MessageBox.Show("Update successfully!");

                FrmJourney_Load(sender, e);
            }
        }
        private void LoadDgv()
        {
            int i = 1, j = 1;
            var sv_boat     = new ServiceBoatSoapClient();
            var sv_position = new Position1SoapClient();
            var sv_journey  = new Journey1SoapClient();
            var boat        = sv_boat.GetAllBoat().ToList();

            //  var position = new Position1SoapClient();

            var position   = sv_position.GetPosition().ToList();
            var journey    = sv_journey.LoadJourneyActive().ToList();
            var BoatActive = (from a in journey
                              join b in boat
                              on a.IDBoat equals b.ID
                              select new
            {
                ID = b.ID,
                Name = b.Name,
                IMO = b.IMO,
                ID_Journey = a.ID
            }).ToList();
            var InforBoatActive = (from p in BoatActive
                                   select new
            {
                STT = i++,
                ID = p.ID,
                Name = p.Name,
                IMO = p.IMO,
                Lat = sv_position.ListPosition(p.ID_Journey).Latitude,
                Long = sv_position.ListPosition(p.ID_Journey).Longitude,
                Oceans = sv_position.ListPosition(p.ID_Journey).Oceans
            }).ToList();

            var list = InforBoatActive.GroupBy(p => p.Oceans).Select(p => new { STT = j++, Name = p.Key, count = p.Count() });

            int tong = InforBoatActive.Count();

            dgvOcean.DataSource                  = list;
            chartThongKe.DataSource              = list;
            chartThongKe.Series[0].XValueMember  = "Name";
            chartThongKe.Series[0].XValueType    = ChartValueType.String;
            chartThongKe.Series[0].YValueMembers = "count";
            chartThongKe.Series[0].YValueType    = ChartValueType.Int32;
            label_Tong.Text = tong.ToString();
        }
Beispiel #4
0
        private void LoadMap(int IDTrip)
        {
            var         image        = new Bitmap(imageFilePath);
            var         sv           = new Position1SoapClient();
            var         listPosition = sv.GetAllPo(IDTrip).ToList();
            MapPolyline mp           = new MapPolyline();

            mp.Fill = Color.White;
            listPosition.OrderBy(p => p.Time).ToList();
            foreach (var p in listPosition)
            {
                mp.Points.Add(new GeoPoint(Convert.ToDouble(p.Latitude), Convert.ToDouble(p.Longitude)));
                var customElement = new MapCustomElement()
                {
                    Location = new GeoPoint(Convert.ToDouble(p.Latitude), Convert.ToDouble(p.Longitude)), Text = ""
                };
                customElement.Image = new Bitmap(image, new Size(40, 40));
                mapItemStorage1.Items.Add(customElement);
            }
            ((MapItemStorage)VectorLayer.Data).Items.Add(mp);
        }
Beispiel #5
0
        private void btnUpdate_Click_1(object sender, EventArgs e)
        {
            var sv = new Position1SoapClient();

            var sv1 = new ServiceParameterSoapClient();

            btnUpdate.Text = "Add";
            //  check();
            if (txtLongitude.Text == "" || txLatitude.Text == "" || txtspeed.Text == "" || txtWeather.Text == "" || txtWater.Value.ToString() == null || txtWind.Value.ToString() == "" || comboBoxOcean.Text == "")
            {
                MessageBox.Show("Not enough information");
            }
            else
            {
                sv.UpdatePosition(IDtrip, float.Parse(txtLongitude.Text), float.Parse(txLatitude.Text), dateTimePo.Value, comboBoxOcean.Text);

                var newPosition = sv.GetPosition().OrderByDescending(p => p.ID).FirstOrDefault();
                sv1.InsertParameter(newPosition.ID, Convert.ToInt32(txtspeed.Text), (int)txtWater.Value, (int)txtWind.Value, txtWeather.Text);

                MessageBox.Show("Add suceed!");
            }
        }
Beispiel #6
0
        void LoadDgv()
        {
            int i           = 1;
            var sv_boat     = new ServiceBoatSoapClient();
            var sv_position = new Position1SoapClient();
            var sv_journey  = new Journey1SoapClient();
            var boat        = sv_boat.GetAllBoat().ToList();
            var position    = sv_position.GetPosition().ToList();
            var journey     = sv_journey.LoadJourneyActive().ToList();
            var BoatActive  = (from a in journey
                               join b in boat
                               on a.IDBoat equals b.ID
                               select new
            {
                ID = b.ID,
                Name = b.Name,
                IMO = b.IMO,
                ID_Journey = a.ID
            }).ToList();
            var PositionOfBoatActive = (from p in BoatActive
                                        select new
            {
                STT = i++,
                Name = p.Name,
                IMO = p.IMO,
                Latitude = sv_position.ListPosition(p.ID_Journey).Latitude,
                Longitude = sv_position.ListPosition(p.ID_Journey).Longitude,
                Ocean = sv_position.ListPosition(p.ID_Journey).Oceans,
                IDPosition = sv_position.ListPosition(p.ID_Journey).ID
            }).ToList();

            dgvBoat.DataSource = PositionOfBoatActive;

            foreach (var p in PositionOfBoatActive)
            {
                var para      = new ServiceParameterSoapClient();
                var parameter = para.parameter(p.IDPosition);
                if (parameter == null)
                {
                    ItemStorage.Items.Add(new MapPushpin()
                    {
                        Location = new GeoPoint((float)p.Latitude, (float)p.Longitude), Text = p.STT.ToString()
                    });
                }

                else
                {
                    string PositionPara = "Parameter\nSpeed : " + parameter.Speed.ToString() + "   ( km/h)" + "\n Wind: " + parameter.Wind.ToString() + "  ( mph ) " + "\nWater Level: " + parameter.Waterlevel.ToString() + "  ( m )\nWeather: " + parameter.Weather.ToString();

                    ItemStorage.Items.Add(new MapCallout()
                    {
                        Location = new GeoPoint((float)p.Latitude, (float)p.Longitude), Text = PositionPara
                    });


                    ItemStorage.Items.Add(new MapPushpin()
                    {
                        Location = new GeoPoint((float)p.Latitude, (float)p.Longitude), Text = p.STT.ToString(), TextColor = Color.Red
                    });
                }
            }
        }