/// <summary> /// hàm xử lý địa chỉ chạy ngầm để cải thiện tốc độ load form. /// -Trong khi đó có 1 cờ bật lên.không cho phép lưu hoặc tắt form trong khi đang xử lý. /// </summary> private void ProcessAutoDiaChi() { G_TongTien = 0; AppendTextBox(txtKmDuKien, string.Empty); AppendTextBox(deTGDuKienDen, string.Empty); AppendTextBox(txtTienDuKien, string.Empty); AppendTextBox(txtLoTrinh, string.Empty); IsProcess = true; PointLatLng start = auDiaChiDon.TempLat > 0 ? new PointLatLng(auDiaChiDon.TempLat, auDiaChiDon.TempLng) : new PointLatLng(auDiaChiDon.Lat, auDiaChiDon.Lng); PointLatLng end = new PointLatLng(auDiaChiTra.Lat, auDiaChiTra.Lng); var loTrinh = TaxiReturn_Process.LayLoTrinh(start, end); if (!string.IsNullOrEmpty(loTrinh.LoTrinh_DiaChi)) { try { this.LoTrinh = loTrinh; string address = loTrinh.LoTrinh_DiaChi; Distance = (double)loTrinh.Distance; TinhTienTheoKm objTinhTien = new TinhTienTheoKm(this.loaiXe, Distance.To <int>()); G_TongTien = objTinhTien.TongTien1Chieu; AppendTextBox(txtKmDuKien, Distance.To <int>()); AppendTextBox(deTGDuKienDen, deGioDon.DateTime.AddHours(Distance / 40)); AppendTextBox(txtTienDuKien, G_TongTien); AppendTextBox(txtLoTrinh, address.RemoveRoutePr()); } catch (Exception) { AppendTextBox(txtLoTrinh, "Không có lộ trình"); } } IsProcess = false; }
private void GridDaDonDuocKhach() { if (ThongTinDangNhap.HasPermission(StaxiPermission.GhepXeChieuVe)) { if (gridView_Bookings.GetFocusedRow() != null) { var m = gridView_Bookings.GetFocusedRow().As <Booking>(); if (string.IsNullOrEmpty(m.OpVehicle) || m.FK_TaxiReturn == 0)// { new MessageBox.MessageBoxBA().Show("Cuốc đón khách phải là cuốc đã được gán xe"); return; } //m.OpAcceptedUser = ThongTinDangNhap.USER_ID; m.OpStatus = (int)Enum_Bookings_OpStatus.DaDonKhach; m.DaDonDuocKhach(); TaxiReturn_Process.TripUpdateStatus(m.FK_TaxiReturn, ThongTinCauHinh.CompanyID, Trip.Status.KhachDaLenXe); if (!IsDieuXe) { btnSearch.PerformClick(); } else { _iSearch = 0; } } } }
private void gridView1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyData == Keys.Enter) { if (!ThongTinDangNhap.HasPermission(StaxiPermission.BaoXeDiDuongDai)) { new MessageBox.MessageBoxBA().Show("Bạn không có quyền thao tác tác vụ này."); return; } var m = gridView1.GetFocusedRow <XeDiDuongDai>(); if (m != null) { var frm = new frmUpdateTrip(m); frm.ShowDialog(); } } else if (e.KeyData == Keys.H) { if (!ThongTinDangNhap.HasPermission(StaxiPermission.BaoXeDiDuongDai)) { new MessageBox.MessageBoxBA().Show("Bạn không có quyền thao tác tác vụ này."); return; } var m = gridView1.GetFocusedRow <XeDiDuongDai>(); if (m != null && new MessageBox.MessageBoxBA().Show("Bạn có muốn hủy cuốc này không?", "Thông báo", MessageBox.MessageBoxButtonsBA.YesNo) == "Yes") { _dulieu.Remove(m); shGridControl1.RefreshDataSource(); m.UpdateStatus(m.ID, Enum_XeBaoDiDuongDai_TrangThai.HuyDieu, ThongTinDangNhap.USER_ID, true); TaxiReturn_Process.TripUpdateStatus(m.ID, ThongTinCauHinh.CompanyID, Services.FastTaxi_OperationService.Trip.Status.HuyDieu); } } }
public void ShowCtrlH() { this.Hide(); timer1.Enabled = false; this.Close(); Model.OpReceivedTime = TaxiReturn_Process.timerServer; //Model.OpAcceptedTime = Model.OpReceivedTime; Model.OpReceivedUser = ThongTinDangNhap.USER_ID; //Model.OpAcceptedUser = ThongTinDangNhap.USER_ID; Model.OpReceived(Model.PK_BooID, Model.OpReceivedUser); TaxiReturn_Process.OperationHasReceive(Model.PK_BooID, ThongTinCauHinh.GPS_MaCungXN.To <int>()); new frmKhachCanXe(true, Model).ShowDialog(); }
private void ctrlDanhSachXeChieuVe_Load(object sender, EventArgs e) { if (this.DesignMode) { return; } if (ThongTinCauHinh.CacLineCuaTaxiOperation == "") { ThongTinCauHinh.LayThongTinCauHinh(); } if (!ThongTinCauHinh.FT_ChieuVe_Active) { this.Visible = false; return; } TaxiReturn_Process.StartTimeServer(); _dulieu = new List <XeDiDuongDai>(); gridView1.Add <RepositoryItemEnum_TrangThaiXeBaoDiDuongDai>("TrangThai"); gridView1.Add <RepositoryItemEnum_TrangThaiDuyetXeBaoDiDuongDai>("TrangThaiDuyet"); try { panel1.BindShControl(); } catch (Exception ex) { new MessageBox.MessageBoxBA().Show(ex.Message); } if (IsDieuXe) { lblDenNgay.Visible = false; lblTuNgay.Visible = false; deDenNgay.Visible = false; deTuNgay.Visible = false; //btnSearch.Visible = true; btnSearch.Visible = false; //panel1.Visible = false; Start(); } else { btnSearch.Visible = true; } _first = false; LoadFull(); ReSearch(); }
public void EnterBooking() { Book = gridView_Bookings.GetFocusedRow().As <Services.FastTaxi_OperationService.Booking>(); Taxi.Services.FastTaxi_OperationService.TimerSendTripTimerSendTripAnswer item = new Services.FastTaxi_OperationService.TimerSendTripTimerSendTripAnswer() { BookID = Book.PK_BooID, Trip = rs.TripID, XNCode = rs.XNCode, Money = G_TongTien }; if (!TaxiReturn_Process.OperationAnswer2(item)) { new MessageBox.MessageBoxBA().Show("Cuốc này khách hàng đã hủy."); return; } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
private void ctrlDieuXe_Load(object sender, EventArgs e) { if (DesignMode) { return; } if (ThongTinCauHinh.CacLineCuaTaxiOperation == "") { ThongTinCauHinh.LayThongTinCauHinh(); } if (!ThongTinCauHinh.FT_ChieuVe_Active) { this.Visible = false; return; } TaxiReturn_Process.StartTimeServer(); try { MenuItem_ChuyenSangChuaGiaiQuyet.Visible = !IsDieuXe; menuKetThuc.Visible = IsDieuXe; gridView_Bookings.Add <RepositoryItemEnum_TrangThaiDieuXe>("OpStatus"); panel2.BindShControl(); if (IsDieuXe) { // panel2.Visible = true; DieuXe(); lblNgayDon.Visible = false; lblNgayDen.Visible = false; deDenNgay.Visible = false; deTuNgay.Visible = false; btnSearch.Visible = false; } else { deDenNgay.Bind(); deTuNgay.Bind(); } } catch (Exception ex) { new MessageBox.MessageBoxBA().Show(ex.Message); } }
private void btnHuy_Click(object sender, EventArgs e) { try { if (this.Confirm("Bạn có muốn hủy không?")) { if (_model != null && _model.ID > 0) { _model.UpdateStatus(_model.ID, Enum_XeBaoDiDuongDai_TrangThai.HuyDieu, ThongTinDangNhap.USER_ID, true); TaxiReturn_Process.TripUpdateStatus(_model.ID, ThongTinCauHinh.CompanyID, Services.FastTaxi_OperationService.Trip.Status.HuyDieu); } DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { LogError.WriteLogError("btnHuy_Click: ", ex); } }
private void GridDelete() { if (ThongTinDangNhap.HasPermission(StaxiPermission.GhepXeChieuVe)) { if (gridView_Bookings.GetFocusedRow() != null) { var m = gridView_Bookings.GetFocusedRow().As <Booking>(); if (m.OpStatus == (int)Enum_Bookings_OpStatus.DaDonKhach) { new MessageBox.MessageBoxBA().Show("[Không xóa được] - Cuốc khách này đã đón được khách.", "Thông báo"); return; } else if (m.OpStatus == (int)Enum_Bookings_OpStatus.ChapNhan) { new MessageBox.MessageBoxBA().Show("[Không xóa được] - Cuốc khách này đã ghép xe.", "Thông báo"); return; } var rs = new MessageBox.MessageBoxBA().Show("Bạn có muốn xóa cuốc này không?", "Thông báo", MessageBoxButtons.YesNo); if (rs.ToLower() == ("YES").ToLower()) { //m.OpAcceptedUser = ThongTinDangNhap.USER_ID; m.DoDelete(); if (m.FK_TaxiReturn > 0) { TaxiReturn_Process.TripUpdateStatus(m.FK_TaxiReturn, ThongTinCauHinh.CompanyID, Trip.Status.KetThuc); } if (!IsDieuXe) { btnSearch.PerformClick(); } } } else { // new MessageBox.MessageBox().Show("Chưa chọn cuốc khách"); } } }
private void btnHienThi_Click(object sender, System.EventArgs e) { try { if (Model == null) { Close(); return; } if (frmKhachCanXe.IsOpenStatic) { Model.OpReceived(Model.PK_BooID, ThongTinDangNhap.USER_ID); TaxiReturn_Process.OperationHasReceive(Model.PK_BooID, ThongTinCauHinh.GPS_MaCungXN.To <int>()); } else { ShowCtrlH(); } } catch (System.Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "btnHienThi_Click", DateTime.Now, ex.Message); } }
private void txtSearch_Properties_ButtonClick(object sender, ButtonPressedEventArgs e) { if (!string.IsNullOrEmpty(txtSearch.Text)) { var txt = TaxiReturn_Process.Search(txtSearch.Text); if (txt != null) { MainMap.Position = new PointLatLng(txt.Value.Key, txt.Value.Value); if (AddMarkerRed == null) { AddMarkerRed = MainMap.AddMarkerRed(MainMap.Position); } else { AddMarkerRed.Position = MainMap.Position; } MainMap.Zoom = 16; } else { new MessageBox.MessageBoxBA().Show("Không tìm thấy địa chỉ"); } } }
private void txtSearch_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { var txt = TaxiReturn_Process.Search(txtSearch.Text); if (txt != null) { MainMap.Position = new PointLatLng(txt.Value.Key, txt.Value.Value); if (AddMarkerRed == null) { AddMarkerRed = MainMap.AddMarkerRed(MainMap.Position); } else { AddMarkerRed.Position = MainMap.Position; } MainMap.Zoom = 16; } else { new MessageBox.MessageBoxBA().Show("Không tìm thấy địa chỉ"); } } }
public static float TinhQuangDuong(float start_lat, float start_lng, float end_lat, float end_lng) { return(TaxiReturn_Process.LayLoTrinh(start_lat, start_lng, end_lat, end_lng).Distance); }
private void kếtThúcToolStripMenuItem_Click(object sender, EventArgs e) { var _model = gridView_Bookings.GetFocusedRow <Booking>(); if (_model == null) { return; } int G_XNCode = ThongTinCauHinh.CompanyID; #region Trường hợp 1:Khách hàng hủy if (_model.OpCommand == m_HuyDieu) { //Bạn có muốn xóa cuốc khách chiều về này không ? // if (new MessageBox.MessageBox().Show("Khách hàng hủy cuốc chiều về ?", "Thông báo", MessageBoxButtons.YesNo).ToLower() == "yes".ToLower()) { try { //cập nhật trạng thái của xe đường dài. var xddd = new XeDiDuongDai(); xddd.UpdateStatus(_model.FK_TaxiReturn, Enum_XeBaoDiDuongDai_TrangThai.ChoGhepKhach, ThongTinDangNhap.USER_ID); _model.UpdateStatus(_model.PK_BooID, Enum_Bookings_OpStatus.KhachHangHuy, m_HuyDieu, ThongTinDangNhap.USER_ID); if (_model.FK_TaxiReturn > 0) { TaxiReturn_Process.TripUpdateStatus(_model.FK_TaxiReturn, G_XNCode, Services.FastTaxi_OperationService.Trip.Status.DangDi); } // this.Close(); } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "ctrlListBook\\kếtThúcToolStripMenuItem_Click", DateTime.Now, ex.Message); // ShowMessageFail("[KH hủy] Quá trình lưu xảy ra bị lỗi"); } } return; } #endregion #region Từ chối if (_model.FK_TaxiReturn == 0) { new MessageBox.MessageBoxBA().Show("Cuốc khách chưa gián xe.\nvui lòng chọn trạng thái từ chối"); return; } #endregion #region Trường hợp 2:Đã ghép. else { #region Mobile đã gặp xe if (_model.OpCommand == m_DaGapXe) { try { string rs = string.Empty; var themTrip = new XeDiDuongDai(); var address = new AutoCompleteAddress(); address.Bind(); #region Khởi tạo trip mới và chưa lưu themTrip.ID = _model.FK_TaxiReturn; try { //Thiếu : Thêm ID cha vào để quan hệ if (themTrip.GetByKey()) { themTrip.ParentID = _model.FK_TaxiReturn; themTrip.ID = 0; themTrip.LoTrinh = string.Empty; themTrip.LoTrinh_Diem = string.Empty; themTrip.KmDuKien = 0; themTrip.TrangThai = (int)Enum_XeBaoDiDuongDai_TrangThai.ChoGhepKhach; themTrip.CreatedDate = TaxiReturn_Process.timerServer; themTrip.CreatedByUser = ThongTinDangNhap.USER_ID; themTrip.UpdatedDate = null; themTrip.UpdatedByUser = string.Empty; // thời điểm bắt đầu của lái xe. themTrip.ThoiDiemDi = themTrip.TGDuKien; //_modelDetail.B themTrip.DiaDiemDen = _model.ToAdress; //address.Text = themTrip.DiaDiemDen; //address.ReSearch(); themTrip.FK_QuanHuyenDenID = address.HuyenId; themTrip.FK_TinhThanhDenID = address.TinhId; themTrip.Den_ViDo = _model.ToLat; themTrip.Den_KinhDo = _model.ToLng; //lấy tọa độ của xe. var _xeOnline = WCFService_Common.GetXeOnlineBySHX(themTrip.FK_SoHieuXe); themTrip.Xe_KinhDo = _xeOnline.KinhDo; themTrip.Xe_ViDo = _xeOnline.ViDo; // Lộ trình này là lộ trình của điểm DC var lotrinh = TaxiReturn_Process.LayLoTrinh(themTrip.Di_ViDo, themTrip.Di_KinhDo, themTrip.Den_ViDo, themTrip.Den_KinhDo); themTrip.LoTrinh = lotrinh.LoTrinh_DiaChi; themTrip.LoTrinh_Diem = lotrinh.LoTrinh_ToaDo; themTrip.KmDuKien = (int)lotrinh.Distance; //Tính thời gian đi của book. int SoPhutDiQuangDuongBC = TaxiReturn_Process.TinhThoiGianDiHetQuangDuong(_model.BC_Route_Distance); themTrip.TGDuKien = themTrip.TGDuKien.AddMinutes(SoPhutDiQuangDuongBC); // là thời điểm đến điểm C. themTrip.ThoiDiemVe = themTrip.TGDuKien; Xe objXe1 = new Xe().GetChiTietXe(themTrip.FK_SoHieuXe); if (objXe1 != null) { themTrip.BienSoXe = objXe1.BienKiemSoat; TinhTienTheoKm objTinhTien = new TinhTienTheoKm(objXe1.LoaiXeID, themTrip.KmDuKien); themTrip.TienDuKien = objTinhTien.TongTien1Chieu; } } } catch (Exception) { } #endregion if (themTrip.KmDuKien >= g_KmDuKien) { rs = new MessageBox.MessageBoxBA().Show("Xe này có muốn đón cuốc chiều về khác không ?", "Thông báo", MessageBoxButtons.YesNo); } if (rs == "Yes") { themTrip.Insert(); } themTrip.UpdateStatusV2(_model.FK_TaxiReturn, Enum_XeBaoDiDuongDai_TrangThai.None, ThongTinDangNhap.USER_ID, true, Enum_Bookings_OpStatus.MobileKetThuc, _model.PK_BooID); #region Send server try { TaxiReturn_Process.TripUpdateStatus(_model.FK_TaxiReturn, G_XNCode, Services.FastTaxi_OperationService.Trip.Status.KetThuc); if (rs == "Yes" && themTrip.ID > 0) { var rsBoot = TaxiReturn_Process.ReplaceTrip(themTrip.ParentID, themTrip); themTrip.UpdateIsAddedStaxi(themTrip.ID, ThongTinDangNhap.USER_ID, rsBoot); } } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message); } //chỉ cần Kết thúc cái Book chưa có hàm gửi lên server try { // if (!G_DoNotSendToServer) TaxiReturn_Process.FinishVehicleReturn(_model.ClientKey); } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message); } #endregion } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Cập nhật dữ liệu lỗi:" + ex.Message); } } #endregion #region Mobile chưa gặp xe else { try { #region Điều hành kết thúc string rs = string.Empty; var themTrip = new XeDiDuongDai(); var address = new AutoCompleteAddress(); address.Bind(); #region Khởi tạo trip mới và chưa lưu themTrip.ID = _model.FK_TaxiReturn; try { //Thiếu : Thêm ID cha vào để quan hệ if (themTrip.GetByKey()) { themTrip.ParentID = _model.FK_TaxiReturn; themTrip.ID = 0; themTrip.LoTrinh = string.Empty; themTrip.LoTrinh_Diem = string.Empty; themTrip.KmDuKien = 0; themTrip.TrangThai = (int)Enum_XeBaoDiDuongDai_TrangThai.ChoGhepKhach; themTrip.CreatedDate = TaxiReturn_Process.timerServer; themTrip.CreatedByUser = ThongTinDangNhap.USER_ID; themTrip.UpdatedDate = null; themTrip.UpdatedByUser = string.Empty; // thời điểm bắt đầu của lái xe. themTrip.ThoiDiemDi = themTrip.TGDuKien; //_modelDetail.B themTrip.DiaDiemDen = _model.ToAdress; //address.Text = themTrip.DiaDiemDen; //address.ReSearch(); themTrip.FK_QuanHuyenDenID = address.HuyenId; themTrip.FK_TinhThanhDenID = address.TinhId; themTrip.Den_ViDo = _model.ToLat; themTrip.Den_KinhDo = _model.ToLng; //lấy tọa độ của xe. var _xeOnline = WCFService_Common.GetXeOnlineBySHX(themTrip.FK_SoHieuXe); themTrip.Xe_KinhDo = _xeOnline.KinhDo; themTrip.Xe_ViDo = _xeOnline.ViDo; // Lộ trình này là lộ trình của điểm DC var lotrinh = TaxiReturn_Process.LayLoTrinh(themTrip.Di_ViDo, themTrip.Di_KinhDo, themTrip.Den_ViDo, themTrip.Den_KinhDo); themTrip.LoTrinh = lotrinh.LoTrinh_DiaChi; themTrip.LoTrinh_Diem = lotrinh.LoTrinh_ToaDo; themTrip.KmDuKien = (int)lotrinh.Distance; //Tính thời gian đi của book. int SoPhutDiQuangDuongBC = TaxiReturn_Process.TinhThoiGianDiHetQuangDuong(_model.BC_Route_Distance); themTrip.TGDuKien = themTrip.TGDuKien.AddMinutes(SoPhutDiQuangDuongBC); // là thời điểm đến điểm C. themTrip.ThoiDiemVe = themTrip.TGDuKien; Xe objXe1 = new Xe().GetChiTietXe(themTrip.FK_SoHieuXe); if (objXe1 != null) { themTrip.BienSoXe = objXe1.BienKiemSoat; TinhTienTheoKm objTinhTien = new TinhTienTheoKm(objXe1.LoaiXeID, themTrip.KmDuKien); themTrip.TienDuKien = objTinhTien.TongTien1Chieu; } } } catch (Exception) { } #endregion if (themTrip.KmDuKien >= g_KmDuKien) { rs = new MessageBox.MessageBoxBA().Show("Xe này có muốn đón cuốc chiều về khác không ?", "Thông báo", MessageBoxButtons.YesNo); } #region nếu chọn đón cuốc chiều về khác thì Thêm mới Trip if (rs == "Yes") { themTrip.Insert(); } themTrip.UpdateStatusV2(_model.FK_TaxiReturn, Enum_XeBaoDiDuongDai_TrangThai.None, ThongTinDangNhap.USER_ID, true, Enum_Bookings_OpStatus.KetThuc, _model.PK_BooID); #endregion #region Send server try { TaxiReturn_Process.TripUpdateStatus(_model.FK_TaxiReturn, G_XNCode, Services.FastTaxi_OperationService.Trip.Status.KetThuc); if (rs == "Yes" && themTrip.ID > 0) { var rsBoot = TaxiReturn_Process.ReplaceTrip(themTrip.ParentID, themTrip); themTrip.UpdateIsAddedStaxi(themTrip.ID, ThongTinDangNhap.USER_ID, rsBoot); } } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message); } //chỉ cần Kết thúc cái Book chưa có hàm gửi lên server try { //if (!G_DoNotSendToServer) TaxiReturn_Process.FinishVehicleReturn(_model.ClientKey); } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "Lưu trên form khách cần xe", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message); } #endregion #endregion } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "Kết thúc trên lưới Book", DateTime.Now, "Gửi lên server sảy ra lỗi:" + ex.Message); new MessageBox.MessageBoxBA().Show("Quá trình xử lý sảy ra lỗi vui lòng liên hệ với quản trị"); } } #endregion } #endregion }
/// <summary> /// Thực hiện thao tác lưu trữ dữ liệu. /// </summary> public void DoSave() { var fw = new ProgressBar(); try { if (Model.ID <= 0) { Model.CreatedByUser = ThongTinDangNhap.USER_ID; Model.CreatedDate = TaxiReturn_Process.timerServer; Model.Insert(); #region Xử lý thông tin gửi lên server if (ckb1Chieu.Checked && ckbFastTaxi.Visible && ckbFastTaxi.Checked && lue_TrangThaiDuyet.EditValue.To <int>() == (int)Enum_XeBaoDiDuongDai_TrangThaiDuyet.DaDuyet) { if (Distance >= 500) { ShowError("Hệ thống Staxi không hỗ trợ cuốc đi đường dài lớn hơn 500 km"); } else { fw.Show(); var rs = TaxiReturn_Process.AddTrip(Model); fw.Close(); if (rs != null && rs.AddTripSuccess) { //Add Trip lên server Thành Công Model.IsAddedStaxi = true; } else { //Add Trip lên server thất bại Model.IsAddedStaxi = false; } // cập nhật trạng thái Model.UpdateIsAddedStaxi(Model.ID, ThongTinDangNhap.USER_ID, Model.IsAddedStaxi); #region Quét xem có booking đề cử cho cuốc chiều về này hay ko //kiểm tra Có danh sách các book đề cử cho xe này. if (rs != null && rs.TripBookingsSend != null && rs.TripBookingsSend.Bookings.Length > 0) { frmListBooking frm = new frmListBooking() { rs = rs.TripBookingsSend, Books = rs.TripBookingsSend.Bookings, G_TongTien = G_TongTien }; if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (frm.Book != null) //chấp nhận { var book = new Booking(); book.PK_BooID = frm.Book.PK_BooID; if (!book.GetByKey()) //trường hợp server chưa đẩy về thì sẽ tự động thêm book đã đc chấp nhận. { //Tạo book mới trên hệ thống. // dán lại xe nào được chấp nhận. book = ParseBooking(frm.Book); book.FK_TaxiReturn = rs.TripBookingsSend.TripID; book.OpVehicle = Model.FK_SoHieuXe; book.OpStatus = (int)Enum_Bookings_OpStatus.ChapNhan; book.OpAcceptedUser = ThongTinDangNhap.USER_ID; book.OpAcceptedTime = book.GetTimeServer(); book.CreatedDate = book.OpAcceptedTime; book.Insert(); //Tạo book deltail trên hệ thống. BookingsDetail detail = new BookingsDetail(); detail.TripID = Model.ID; detail.FK_BookID = book.PK_BooID; // detail.CalF var AB = TaxiReturn_Process.LayLoTrinh(Model.Den_ViDo, Model.Den_KinhDo, book.FromLat, book.FromLng); detail.ABRoute = AB.LoTrinh_ToaDo; var CD = TaxiReturn_Process.LayLoTrinh(book.ToLat, book.ToLng, Model.Di_ViDo, Model.Di_KinhDo); detail.CDRoute = CD.LoTrinh_ToaDo; detail.Status = (int)Enum_BookingsDetail_Status.DuocChapNhan; detail.DateUpdated = TaxiReturn_Process.timerServer; detail.Insert(); } else { // dán lại xe nào được chấp nhận. book.FK_TaxiReturn = rs.TripBookingsSend.TripID; book.OpVehicle = Model.FK_SoHieuXe; book.OpStatus = (int)Enum_Bookings_OpStatus.ChapNhan; book.OpAcceptedUser = ThongTinDangNhap.USER_ID; book.OpAcceptedTime = book.GetTimeServer(); book.Update(); } book.DaDieuDuocXe(frm.Book.PK_BooID, rs.TripBookingsSend.TripID, ThongTinDangNhap.USER_ID, ThongTinCauHinh.CompanyID); } else // Hủy điều { //Xác nhận hủy điều. if (new MessageBox.MessageBoxBA().Show("Bạn có muốn hủy cuốc này không", "Thông báo", MessageBox.MessageBoxButtonsBA.YesNo) == "Yes") { if (_model != null && _model.ID > 0) { _model.UpdatedByUser = ThongTinDangNhap.USER_ID; _model.HuyDieu(); TaxiReturn_Process.TripUpdateStatus(_model.ID, ThongTinCauHinh.CompanyID, Services.FastTaxi_OperationService.Trip.Status.HuyDieu); } } } } } #endregion } } #endregion DialogResult = DialogResult.OK; this.BeginInvoke((Action)(() => this.Close())); } else { Model.UpdatedByUser = ThongTinDangNhap.USER_ID; Model.UpdatedDate = TaxiReturn_Process.timerServer; Model.Update(); #region Gửi lên server if (ckb1Chieu.Checked && ckbFastTaxi.Visible && ckbFastTaxi.Checked && lue_TrangThaiDuyet.EditValue.To <int>() == (int)Enum_XeBaoDiDuongDai_TrangThaiDuyet.DaDuyet) { if (Distance >= 500) { ShowError("Hệ thống Staxi không hỗ trợ cuốc đi đường dài lớn hơn 500 km"); } else { //nếu gửi rồi thì sẽ EditTrip if (Model.IsAddedStaxi) { TaxiReturn_Process.EditTrip(Model); } else // Chưa gửi lên thì sẽ AddTrip { var rs = TaxiReturn_Process.AddTrip(Model); if (rs != null) { // cập nhật trạng thái Model.UpdateIsAddedStaxi(Model.ID, ThongTinDangNhap.USER_ID, rs.AddTripSuccess); } } } } #endregion DialogResult = DialogResult.OK; try { this.BeginInvoke((Action)(() => this.Close())); } catch (Exception ex) { } } if (Model.IsKetThuc) { Model.UpdateStatus(Model.ID, Enum_XeBaoDiDuongDai_TrangThai.None, ThongTinDangNhap.USER_ID, true); TaxiReturn_Process.TripUpdateStatus(Model.ID, ThongTinCauHinh.CompanyID, Services.FastTaxi_OperationService.Trip.Status.KetThuc); } } catch (Exception ex) { try { fw.Invoke((MethodInvoker)fw.Close); } catch (Exception ex2) { new MessageBox.MessageBoxBA().Show("fw:" + ex2.Message); } new MessageBox.MessageBoxBA().Show("Lỗi ngoại lệ xảy ra:" + ex.Message); } }
private void layDuLieuThayDoi_Tick(object sender, EventArgs e) { _timeXoaDuLieu++; try { if (DuLieu == null) { DuLieu = new List <Booking>(); } if (_iSearch > 0) { // _iSearch--; } else if (_iSearch == 0) { shGridControl_Bookings.DataSource = DuLieu; shGridControl_Bookings.RefreshDataSource(); _iSearch = -1; } var data = Booking.Inst.GetByDateTime(ThongTinCauHinh.CacLineCuaTaxiOperation, _thoiDiemTruocLayDuLieu); if (data != null && data.Count > 0) { TaxiReturn_Process.timerServer = DieuHanhTaxi.GetTimeServer(); _thoiDiemTruocLayDuLieu = TaxiReturn_Process.timerServer; //Kiểm tra là trạng thái chấp nhận,đã đón khách,chờ xử lý thì thêm và cập nhận lại. data.Where(p => !DieuKienXoa(p)).ToList().ForEach(p => { var dl = DuLieu.FirstOrDefault(pi => pi.PK_BooID == p.PK_BooID); if (dl != null) { dl.CopyPropertyValue(p, p.GetPropertiesName()); } else { if (p.FK_TaxiReturn == 0 && p.OpStatus == (int)Enum_Bookings_OpStatus.ChoXuLy) { var control = this.ActiveControl; if (this.ParentForm != null) { control = this.ParentForm.ActiveControl; } if (!string.IsNullOrEmpty(ThongTinDangNhap.USER_ID) && ThongTinDangNhap.HasPermission(StaxiPermission.GhepXeChieuVe)) { FrmThongTin = new frmInfo(); FrmThongTin.SetModel(p); FrmThongTin.Show(); } bool check = false; foreach (Form item in Application.OpenForms) { if (item.Visible && item is frmKhachCanXe) { item.Focus(); item.Activate(); check = true; } } if (!check && control != null) { control.Focus(); } } else { if (p.OpReceivedTime == null) { p.OpReceived(p.PK_BooID, ThongTinDangNhap.USER_ID); TaxiReturn_Process.OperationHasReceive(p.PK_BooID, ThongTinCauHinh.GPS_MaCungXN.To <int>()); } } DuLieu.Insert(0, p); } }); //kiểm tra xem đã kết thúc và xóa khỏi lưới. data.Where(DieuKienXoa).ToList().ForEach(p => { var dl = DuLieu.FirstOrDefault(pi => pi.PK_BooID == p.PK_BooID); if (dl != null) { DuLieu.Remove(dl); } }); if (_iSearch == -1) { shGridControl_Bookings.DataSource = DuLieu; shGridControl_Bookings.RefreshDataSource(); } // DuLieu = DuLieu.OrderBy(p => p.CreatedDate).ToList(); } //Duyệt các cuốc xe thời gian đã hết chưa và thực hiện dấu số điện thoại. DuLieu.ForEach(p => { if (p.OpStatus == (int)Enum_Bookings_OpStatus.ChapNhan || p.OpStatus == (int)Enum_Bookings_OpStatus.DaDonKhach) { p.Mobile_ThoiGian = p.Mobile; } else if (p.OpStatus == (int)Enum_Bookings_OpStatus.ChoXuLy) { if (IsDieuXe) { if (string.IsNullOrEmpty(p.OpCommand)) { var dt = p.OpReceivedTime ?? p.CreatedDate; //Trạng thái số phút còn lại thực hiện int val = ((p.OpReceivedTime == null ? 1 : 5) * 60) - (int)(TaxiReturn_Process.timerServer - dt.Value).TotalSeconds; // nếu hết thời gian sẽ cập nhật là không xử lý. if (val <= 0) { //p.OpStatus = (int)Enum_Bookings_OpStatus.KhongXuLy; //p.OpAcceptedUser = ThongTinDangNhap.USER_ID; //p.OpAcceptedTime = TaxiReturn_Process.timerServer; p.UpdateStatus(p.PK_BooID, Enum_Bookings_OpStatus.KhongXuLy, ThongTinDangNhap.USER_ID); DuLieu.Remove(p); } else { int sophut = (val / 60); int soGiay = val - sophut * 60; p.Mobile_ThoiGian = string.Format("Còn lại {0}:{1}", sophut, soGiay); } } else { p.Mobile_ThoiGian = string.Empty; } } else { p.Mobile_ThoiGian = string.Empty; } } else { p.Mobile_ThoiGian = string.Empty; } }); if (_timeXoaDuLieu >= 3) { _timeXoaDuLieu = 0; if (DuLieu.Count > 0) { string lsId = string.Empty; DuLieu.ForEach(p => lsId += string.Format("{0},", p.PK_BooID)); var lsDelete = Booking.Inst.GetDataDelete(lsId); DuLieu.Where(p => lsDelete.Any(pi => pi == p.PK_BooID)).ToList().ForEach(p => { p.OpReceivedTime = DateTime.Now; DuLieu.Remove(p); }); } //DuLieu = DuLieu.OrderBy(p => p.CreatedDate).ToList(); } shGridControl_Bookings.RefreshDataSource(); //int index = gridView_Bookings.FocusedRowHandle; //shGridControl_Bookings.DataSource = DuLieu.Where(DieuKienTimKiem).ToList(); //if (index < gridView_Bookings.RowCount) gridView_Bookings.FocusedRowHandle = index; } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "ctrlListBook\\layDuLieuThayDoi_Tick", DateTime.Now, ex.Message); } }
private void ShowBanDo() { try { _bando = new frmUpdateTrip_Map(); PointLatLng?start = null; PointLatLng?end = null; lblMsg.Text = ""; { if (auDiaChiDon.TempLat > 0 && auDiaChiDon.TempLng > 0) { start = new PointLatLng(auDiaChiDon.TempLat, auDiaChiDon.TempLng); } else if (auDiaChiDon.TinhId > 0) { start = new PointLatLng(auDiaChiDon.Lat, auDiaChiDon.Lng); } } { if (auDiaChiTra.TempLat > 0 && auDiaChiTra.TempLng > 0) { end = new PointLatLng(auDiaChiTra.TempLat, auDiaChiTra.TempLng); } else if (auDiaChiTra.TinhId > 0) { end = new PointLatLng(auDiaChiTra.Lat, auDiaChiTra.Lng); } } _bando.ShowBanDo(start, end, auDiaChiDon.Text, auDiaChiTra.Text); _bando.pic = pic1; _bando.SoXe = txtXe.Text.Trim(); _bando.LoaiXeId = this.loaiXe; if (_model != null) { var _LoTrinh = new LoTrinh(); _LoTrinh.Distance = _model.KmDuKien; _LoTrinh.LoTrinh_DiaChi = _model.LoTrinh; _LoTrinh.LoTrinh_ToaDo = _model.LoTrinh_Diem; _LoTrinh.ListPoint = TaxiReturn_Process.ConvertToPointLatLng(_LoTrinh.LoTrinh_ToaDo); _bando.LoTrinh = _LoTrinh; } _bando.ShowDialog(); pic1 = 0; if (_bando.IsOk) { if (auDiaChiDon.Text != _bando.AddressA) { auDiaChiDon.Text = _bando.AddressA; auDiaChiDon.ReSearch(); auDiaChiDon.TempLat = (float)_bando._gMapMarkerA.Position.Lat; auDiaChiDon.TempLng = (float)_bando._gMapMarkerA.Position.Lng; auDiaChiDon.IsChangeText = true; } if (auDiaChiTra.Text != _bando.AddressB) { auDiaChiTra.Text = _bando.AddressB; auDiaChiTra.ReSearch(); auDiaChiTra.TempLat = (float)_bando._gMapMarkerB.Position.Lat; auDiaChiTra.TempLng = (float)_bando._gMapMarkerB.Position.Lng; auDiaChiTra.IsChangeText = true; } if (auDiaChiDon.TinhId > 0 && auDiaChiTra.TinhId > 0) { // new Thread(new ThreadStart(ProcessAutoDiaChi)).Start(); } txtKmDuKien.EditValue = _bando.Distance; txtKmDuKien.IsChangeText = true; deTGDuKienDen.EditValue = deGioDon.DateTime.AddHours(_bando.time); deTGDuKienDen.IsChangeText = true; this.LoTrinh = _bando.LoTrinh; txtLoTrinh.Text = LoTrinh.LoTrinh_DiaChi; txtLoTrinh.IsChangeText = true; G_TongTien = _bando.TienDuKien; txtTienDuKien.EditValue = G_TongTien; txtTienDuKien.IsChangeText = true; } } catch (Exception ex) { LogError.WriteLogError("ShowBanDo: ", ex); } }