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 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 }