private void LoadDgv() { int i = 1; var sv = new ServiceBoatSoapClient(); var listBoat = sv.GetAllBoat(); var listType = sv.GetAllType(); var listBoatAndNameType = (from a in listBoat select new { ID = a.ID, Name = a.Name, NameYpeBoat = sv.GetTypeBoat((int)a.IDTypeBoat).Name }).ToList(); var list = listBoatAndNameType.GroupBy(p => p.NameYpeBoat).Select(p => new { STT = i++, Name = p.Key, Quantity = p.Count() }); dgvTypeBoat.DataSource = list; chartThongKe.DataSource = list; chartThongKe.Series[0].XValueMember = "Name"; chartThongKe.Series[0].XValueType = ChartValueType.String; chartThongKe.Series[0].YValueMembers = "Quantity"; chartThongKe.Series[0].YValueType = ChartValueType.Int32; }
private void UpdateDetail() { try { var sv = new ServiceBoatSoapClient(); int id = (int)gridBoat.GetFocusedRowCellValue("ID"); // int id= (int)dgvBoatList.get var boat = sv.GetBoat(id); cbxNational.EditValue = boat.IDNational; cbxTypeBoat.EditValue = boat.IDTypeBoat; txtName.Text = boat.Name; txtIMO.Text = boat.IMO; txtLength.Text = boat.Length.ToString(); txtMMSI.Text = boat.MMSI; txtTonnage.Text = boat.Tonnage.ToString(); txthigh.Text = boat.High.ToString(); // txtStatus.Text = boat.Status.ToString(); if (boat.Status == true) { cbxstatus.Text = "Work"; } else { cbxstatus.Text = "Work Off"; } txtVolume.Text = boat.Volume.ToString(); imgAnh.Image = ConvertBinaryToImage(boat.Image); } catch { } }
private void btnTrip_Click(object sender, EventArgs e) { var sv = new ServiceBoatSoapClient(); int id = (int)gridBoat.GetFocusedRowCellValue("ID"); FrmJourney form = new FrmJourney(id); form.ShowDialog(); }
private void LoadUnitControl() { var sv = new ServiceBoatSoapClient(); cbbNational.DataSource = sv.GetAllNational().ToList(); cbbNational.DisplayMember = "Name"; cbbNational.ValueMember = "ID"; }
private void btnAdd_Click(object sender, EventArgs e) { var sv = new ServiceBoatSoapClient(); var boat = sv.GetAllBoat().ToList(); if (btnAdd.Text == "Add") { btnUpdate.Enabled = false; btnAdd.Text = "Save"; btnDelete.Text = "Cancel"; ClearControl(); UnlockControl(); return; } if (btnAdd.Text == "Save") { if (txtMMSI.Text == "" || txtName.Text == "" || txtIMO.Text == "" || txthigh.Text == "" || txtTonnage.Text == "" || txtVolume.Text == "" || imgAnh.Image == null) { MessageBox.Show("You must enter all fields", "notification"); return; } else { if (CheckAll() == true) { btnAdd.Text = "Add"; btnDelete.Text = "Delete"; LockControl(); int idnational = (int)cbxNational.EditValue; int idtypeboat = (int)cbxTypeBoat.EditValue; float volume = float.Parse(txtVolume.Text); float tonnage = float.Parse(txtTonnage.Text); float length = float.Parse(txtLength.Text); float high = float.Parse(txthigh.Text); bool status = true; if (cbxstatus.Text == "Work") { status = true; } else { status = false; } byte[] avt = ConvertImageToBinary(imgAnh.Image); sv.insertboat(txtName.Text, txtIMO.Text, txtMMSI.Text, idnational, idtypeboat, volume, tonnage, high, length, status, avt); MessageBox.Show("Add successfully!"); LoagDgvBoat(); } } } }
private void LoadInitControl() { var sv = new ServiceBoatSoapClient(); var list = sv.BoatAreActive(); cbbBoat.Properties.DataSource = sv.BoatAreActive().Select(p => new { p.ID, p.Name }).ToList(); cbbBoat.Properties.ValueMember = "ID"; cbbBoat.Properties.DisplayMember = "Name"; }
private void LoadInitControl() { var sv = new ServiceBoatSoapClient(); cbxNational.Properties.DataSource = sv.GetAllNational().Select(p => new { p.ID, p.Name }).ToList(); cbxNational.Properties.DisplayMember = "Name"; cbxNational.Properties.ValueMember = "ID"; cbxTypeBoat.Properties.DataSource = sv.GetAllType().ToList(); cbxTypeBoat.Properties.DisplayMember = "Name"; cbxTypeBoat.Properties.ValueMember = "ID"; ClearControl(); }
private void cbbBoat_EditValueChanged(object sender, EventArgs e) { var sv = new ServiceBoatSoapClient(); var list = sv.BoatAreActive(); var Bien = list.Where(p => p.ID == (int)cbbBoat.EditValue).FirstOrDefault(); txtjourney.Text = Bien.ID_Journey.ToString(); txtLat.Text = Bien.Latiude.ToString(); txtLong.Text = Bien.Longiude.ToString(); cbbOcean.Text = Bien.Ocean; dateTimeLost.Value = Bien.Time; CbbStatus.Text = "Lost Infor"; }
private void btnUpdate_Click(object sender, EventArgs e) { if (btnUpdate.Text == "Update") { btnUpdate.Text = "Save"; btnDelete.Text = "Cancel"; btnAdd.Enabled = false; UnlockControl(); return; } if (btnUpdate.Text == "Save") { if (CheckAll() == true) { btnUpdate.Text = "Update"; btnDelete.Text = "Delete"; LockControl(); var sv = new ServiceBoatSoapClient(); int id = (int)gridBoat.GetFocusedRowCellValue("ID"); int idnational = (int)cbxNational.EditValue; int idtypeboat = (int)cbxTypeBoat.EditValue; float volume = float.Parse(txtVolume.Text); float tonnage = float.Parse(txtTonnage.Text); float length = float.Parse(txtLength.Text); float high = float.Parse(txthigh.Text); bool status = true; if (cbxstatus.Text == "Work") { status = true; } else { status = false; } byte[] avt = ConvertImageToBinary(imgAnh.Image); sv.UpdateBoat(id, txtName.Text, txtIMO.Text, txtMMSI.Text, idnational, idtypeboat, volume, tonnage, high, length, status, avt); MessageBox.Show("Update successfully!"); LoagDgvBoat(); } } }
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(); }
public bool checkDefMMIS(int id, string str) { var sv = new ServiceBoatSoapClient(); foreach (var b in sv.GetAllBoat().ToList()) { if (string.Compare(str, b.MMSI, true) == 0 && id == b.ID) { return(false); } else { return(true); } } return(false); }
public void LoagDgvBoat() { int i = 0; var sv = new ServiceBoatSoapClient(); var boat = sv.GetAllBoat().ToList(); // var po = sv.GetAllPosition().ToList(); var national = sv.GetAllNational().ToList(); var type = sv.GetAllType().ToList(); var ShowBoat = (from b in boat select new { STT = ++i, ID = b.ID, Name = b.Name, IMO = b.IMO, }).ToList(); dgvBoatList.DataSource = ShowBoat; }
private void BoatLostInfor_Load(object sender, EventArgs e) { var sv = new ServiceBoatSoapClient(); LoadInitControl(); dgvBoatLost.DataSource = (from p in sv.AllBoatLostInfor() from q in sv.GetAllBoat() where p.IDBoat == q.ID select new { ID = p.ID, IDBoat = q.ID, NameOfBoat = q.Name, LastConnect = p.LastConnect, Latitude = p.Latitude, Longitude = p.Longitude, IDJourney = p.IDJourney, Ocean = p.Ocean }).ToList(); }
private void btnDelete_Click(object sender, EventArgs e) { if (btnDelete.Text == "Cancel") { LoagDgvBoat(); btnDelete.Text = "Delete"; btnAdd.Text = "Add"; btnUpdate.Text = "Update"; LockControl(); } else { var sv = new ServiceBoatSoapClient(); int id = (int)gridBoat.GetFocusedRowCellValue("ID"); DialogResult rs = MessageBox.Show("Do you want to delete this boat?", "Notification", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (rs == DialogResult.Cancel) { return; } sv.DeleteBoat(id); MessageBox.Show("Delete successfully!"); LoagDgvBoat(); } }
/* * private void Loaddgv() * { * int i = 1; * var sv = new ServiceBoatSoapClient(); * var listBoat = sv.GetAllBoat(); * var National = sv.GetAllNational(); * * var listBoatAndNameType = (from a in listBoat * * select new * { * ID = a.ID, * Name = a.Name, * NameNational = sv.GetNational((int)a.IDNational).Name * * }).ToList(); * var list = listBoatAndNameType.GroupBy(p => p.NameNational).Select(p => new { STT = i++, Name = p.Key, Quantity = p.Count() }); * * dgvBoatByNational.DataSource = list; * } */ private void StatisticsByNational_Load(object sender, EventArgs e) { var a = new ServiceBoatSoapClient(); dgvBoatByNational.DataSource = a.CountBoat(); }
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 }); } } }