예제 #1
0
        void LoadPortOfNational(int ID_National)
        {
            int i        = 1;
            var sv       = new ServicePortNationalSoapClient();
            var ListPort = sv.ListPortOfNational(ID_National).ToList();
            var List     = (from p in ListPort
                            select new
            {
                STT = i++,
                Name = p.Name,
                Latitude = p.Latitude,
                Longitude = p.Longitude
            }).ToList();

            gridPort.DataSource = List;
            foreach (var p in List)
            {
                ItemStorage.Items.Add(new MapCallout()
                {
                    Location = new GeoPoint((float)p.Latitude, (float)p.Longitude), Text = p.Name.ToString()
                });
                ItemStorage.Items.Add(new MapPushpin()
                {
                    Location = new GeoPoint((float)p.Latitude, (float)p.Longitude), Text = p.STT.ToString()
                });
            }
        }
        private void gridPort_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            var sv   = new ServicePortNationalSoapClient();
            int id   = (int)gridPort.GetFocusedRowCellValue("ID");
            var port = sv.GetPortByID(id);

            ((MapItemStorage)vectorItemsLayer1.Data).Items.Clear();
            try
            {
                txtName.Text     = port.Name;
                txtLat.Text      = port.Latitude.ToString();
                txtLongiude.Text = port.Longitude.ToString();

                cbbOceanOfPort.Text = port.Ocean;

                cbbNational.SelectedValue = port.ID_Nation;

                ItemStorage.Items.Add(new MapCallout()
                {
                    Location = new GeoPoint((float)port.Latitude, (float)port.Longitude), Text = port.Name.ToString()
                });
                ItemStorage.Items.Add(new MapPushpin()
                {
                    Location = new GeoPoint((float)port.Latitude, (float)port.Longitude), Text = ""
                });
                map.CenterPoint = new GeoPoint((float)port.Latitude, (float)port.Longitude);
            }
            catch
            {
            }
        }
예제 #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (btnUpdate.Text == "Update")
            {
                btnUpdate.Text = "Save";
                btnCancel.Text = "Cancel";
                btnAdd.Enabled = false;

                UnlockControl();

                return;
            }

            if (btnUpdate.Text == "Save")
            {
                btnUpdate.Text = "Update";
                btnCancel.Text = "Delete";

                LockControl();

                var    sv   = new ServicePortNationalSoapClient();
                var    name = txtNameOfNational.Text;
                int    id   = (int)gridListNational.GetFocusedRowCellValue("ID");
                byte[] avt  = ConvertImageToBinary(imgAnh.Image);
                sv.UpdateNational(id, name, avt);
                MessageBox.Show("Update succeed!");
                LoadNational();
            }
        }
예제 #4
0
        private void UpdateDetail()
        {
            try
            {
                var sv  = new Journey1SoapClient();
                var sv1 = new ServicePortNationalSoapClient();

                int id   = (int)gridTrip.GetFocusedRowCellValue("ID");
                var trip = sv.GetTripId(id);
                #region Detail


                cbxBeginpo.EditValue = trip.BeginPosition;
                cbxEndPo.EditValue   = trip.EndPosition;
                dateTimeBegin.Value  = trip.TimeBegin.Value;
                dateTimeEnd.Value    = trip.TimeEnd.Value;

                txtTimeProvide.Text = trip.TimeProvide.ToString();


                bool status = (bool)trip.Status;

                if (status == true)
                {
                    cbxSatus.Text             = "Complete";
                    btnUpdatePosition.Enabled = false;
                }
                else
                {
                    cbxSatus.Text             = "Not Complete";
                    btnUpdatePosition.Enabled = true;
                }


                #endregion

                #region Load Map
                ((MapItemStorage)vectorItemsLayer1.Data).Items.Clear();
                var portBegin = sv1.GetPortByID((int)trip.BeginPosition);
                var portEnd   = sv1.GetPortByID((int)trip.EndPosition);

                ItemStorage.Items.Add(new MapPushpin()
                {
                    Location = new GeoPoint((float)portBegin.Latitude, (float)portBegin.Longitude), Text = "Begin"
                });

                ItemStorage.Items.Add(new MapPushpin()
                {
                    Location = new GeoPoint((float)portEnd.Latitude, (float)portEnd.Longitude), Text = "End"
                });
                map.CenterPoint = new GeoPoint((float)portBegin.Latitude, (float)portBegin.Longitude);
                map.Zoom(7);
                LoadMap(id);
                #endregion
            }
            catch
            {
            }
        }
예제 #5
0
        private void gridListNational_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            var sv = new ServicePortNationalSoapClient();

            ((MapItemStorage)vectorItemsLayer1.Data).Items.Clear();
            int id       = (int)gridListNational.GetFocusedRowCellValue("ID");
            var national = sv.GetNational(id);

            txtNameOfNational.Text = gridListNational.GetFocusedRowCellValue("Name").ToString();
            imgAnh.Image           = ConvertBinaryToImage(national.Image);
            LoadPortOfNational((int)gridListNational.GetFocusedRowCellValue("ID"));
        }
예제 #6
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);
                }
            }
        }
예제 #7
0
        void LoadNational()
        {
            int i            = 1;
            var sv           = new ServicePortNationalSoapClient();
            var listNational = sv.ListNational().ToList();

            gridNational.DataSource = (from p in listNational
                                       select new
            {
                STT = i++,
                ID = p.ID,
                Name = p.Name,
            }).ToList();
        }
        private void LoaddgvPort()
        {
            var sv       = new ServicePortNationalSoapClient();
            var listPort = (from p in sv.ListPort()
                            select new
            {
                ID = p.ID,
                Name = p.Name,
                Nationnal = sv.GetNational((int)p.ID_Nation).Name,
                Latitude = p.Latitude,
                Longitude = p.Longitude
            }).ToList();

            dgvPortList.DataSource = listPort;
        }
예제 #9
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);
            }
        }
예제 #10
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var sv = new ServicePortNationalSoapClient();

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

                txtNameOfNational.Text = "";
                imgAnh.Image           = null;
                UnlockControl();

                return;
            }

            if (btnAdd.Text == "Save")
            {
                if (txtNameOfNational.Text == null || imgAnh.Image == null)
                {
                    MessageBox.Show("You must enter all fields", "notification");
                    return;
                }
                else
                {
                    btnAdd.Text    = "Add";
                    btnCancel.Text = "Delete";
                    LockControl();
                    string name = txtNameOfNational.Text;
                    byte[] avt  = ConvertImageToBinary(imgAnh.Image);
                    sv.InsertNational(name, avt);

                    MessageBox.Show("Add suceed!");

                    LoadNational();
                }

                // return;
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var sv = new ServicePortNationalSoapClient();

            if (btnAdd.Text == "Add")
            {
                btnUpdate.Enabled = false;
                btnAdd.Text       = "Save";
                // btnCancel.Text = "Delete";
                UnLockControl();
                txtLat.Text      = "";
                txtLongiude.Text = "";
                txtName.Text     = "";

                //   panel1.Enabled = true;
                return;
            }

            if (btnAdd.Text == "Save")
            {
                if (check() == true)
                {
                    // panel1.Enabled = false;
                    btnAdd.Text       = "Add";
                    btnUpdate.Enabled = true;
                    LockControl();
                    //  Port port = new Port();
                    double Latitude  = Convert.ToDouble(txtLat.Text);
                    double Longitude = Convert.ToDouble(txtLongiude.Text);
                    int    ID_Nation = Convert.ToInt32(cbbNational.SelectedValue);
                    string Ocean     = cbbOceanOfPort.Text;
                    string Name      = txtName.Text;
                    sv.InsertPort(Name, (float)Latitude, (float)Longitude, ID_Nation, Ocean);
                    MessageBox.Show("Add suceed!");
                    FrmPortManagement_Load(sender, e);
                }
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var sv = new ServicePortNationalSoapClient();

            if (btnUpdate.Text == "Update")
            {
                btnUpdate.Text = "Save";
                //      btnCancel.Text = "Cancel";
                btnAdd.Enabled = false;

                UnLockControl();

                return;
            }

            if (btnUpdate.Text == "Save")
            {
                if (check() == true)
                {
                    btnUpdate.Text = "Update";

                    btnAdd.Enabled = true;
                    LockControl();

                    int id = (int)gridPort.GetFocusedRowCellValue("ID");

                    double Latitude  = Convert.ToDouble(txtLat.Text);
                    double Longitude = Convert.ToDouble(txtLongiude.Text);
                    int    ID_Nation = Convert.ToInt32(cbbNational.SelectedValue);
                    string Ocean     = cbbOceanOfPort.Text;
                    string Name      = txtName.Text;
                    sv.UpdatePort(id, Name, (float)Latitude, (float)Longitude, ID_Nation, Ocean);
                    MessageBox.Show("Update succeed!");
                    FrmPortManagement_Load(sender, e);
                }
            }
        }