/// <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 btnTinhTien_Click(object sender, EventArgs e) { TinhTienTheoKm objTinhTien = new TinhTienTheoKm( (float)numKmMoCua4.Value , (float)numGiaMoCua.Value , (float)numKmNguong1.Value , (float)numGiaNguong1.Value , (float)numGiaNguong2.Value , (float)numKmNguong2Chieu.Value , (float)numTiLeGiamGia2Chieu.Value , 4 , txtThongTinThueBao.Text , G_LoaiCuoc); if (!objTinhTien.Update()) { new MessageBox.MessageBoxBA().Show("Lỗi cập nhật thông tin giá cước mới cho loại xe 4 chỗ."); return; } objTinhTien = null; TinhTienTheoKm objTinhTien7 = new TinhTienTheoKm((float)numKmMoCua7.Value, (float)numGiaMoCua7.Value, (float)numKmNguong17.Value, (float)numGiaNguong17.Value, (float)numGiaNguong27.Value, (float)numKmNguong2Chieu7.Value, (float)numTiLeGiamGia2Chieu7.Value, 7, txtThongTinThueBao.Text, G_LoaiCuoc); if (!objTinhTien7.Update()) { new MessageBox.MessageBoxBA().Show("Lỗi cập nhật thông tin giá cước mới cho loại xe 7 chỗ."); return; } new MessageBox.MessageBoxBA().Show("Cập nhật thông tin giá cước mới thành công."); this.Close(); }
protected override object GetData() { var data = (base.GetData() as List <Booking>); if (data != null) { // data = data.OrderByDescending(pi => pi.FromTime).OrderBy(p=>p.SoHieuXe.To<int>()).ToList(); data.ForEach(pi => { if (pi.KmCoKhach <= 0) { pi.TongTien = 0; } TinhTienTheoKm item = new TinhTienTheoKm(pi.LoaiXeID, pi.BC_Route_Distance); if (item != null) { pi.TongTien = (decimal)item.TongTien1Chieu; } else { pi.TongTien = (decimal)0; } }); } return(data.ToList()); }
private void Calculator() { if (editKm.Text.Length <= 0) { return; } float SoKm = float.Parse(editKm.Text); int LoaiXe = 4; if (rad4Cho.Checked) { LoaiXe = 4; } if (radioButton2.Checked) { LoaiXe = 7; } TinhTienTheoKm objTinhTien = new TinhTienTheoKm(); if (chkTaxiCP.Checked) { objTinhTien = new TinhTienTheoKm(LoaiXe, SoKm); } // else objTinhTien = new TinhTienTheoKm(LoaiXe, SoKm, chkTaxiCP.Checked); editTienChieuDi.Text = string.Format("{0:0,0}", objTinhTien.TongTien1Chieu); editTienChieuVe.Text = string.Format("{0:0,0}", objTinhTien.TongTien2Chieu); editTongTien.Text = string.Format("{0:0,0}", objTinhTien.TongTien1Chieu + objTinhTien.TongTien2Chieu); }
private void Calculator() { if (editKm.Text.Length <= 0) { return; } float SoKm = float.Parse(editKm.Text); float SoKm2Chieu = SoKm * 2; int LoaiXe = 4; if (rad4Cho.Checked) { LoaiXe = 4; } if (radioButton2.Checked) { LoaiXe = 7; } TinhTienTheoKm objTinhTien; objTinhTien = new TinhTienTheoKm(LoaiXe, SoKm); editTienChieuDi.Text = string.Format("{0:0,0}", objTinhTien.TinhTien1Chieu_CP(SoKm)); editTienChieuVe.Text = string.Format("{0:0,0}", objTinhTien.TinhTien2Chieu_CP(SoKm2Chieu)); lblKm2Chieu.Text = "(" + SoKm2Chieu.ToString() + " Km)"; }
private void lnkXoa_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { gridDiaDanhKm.SelectionMode = Janus.Windows.GridEX.SelectionMode.SingleSelection; if (gridDiaDanhKm.SelectedItems.Count > 0) { GridEXRow row = gridDiaDanhKm.SelectedItems[0].GetRow(); int ID = int.Parse(row.Cells["ID"].Value.ToString()); if (new MessageBox.MessageBoxBA().Show(this, "Bạn có đồng ý xóa địa danh.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.YesNoCancel, Taxi.MessageBox.MessageBoxIconBA.Question).ToString() == DialogResult.Yes.ToString()) { if (TinhTienTheoKm.DeleteDiaDanhKm(ID)) { new MessageBox.MessageBoxBA().Show(this, "Xóa địa danh thành công.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information); this.LoadDiaDanh(); return; } else { new MessageBox.MessageBoxBA().Show(this, "Lỗi xóa địa danh.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information); return; } } } }
/// <summary> /// Yêu cầu riêng của Sao Hà Nội! /// </summary> private void TinhTienTheoSaoHaNoi() { try { if (editKm.Text.Length <= 0) { return; } float SoKm = float.Parse(editKm.Text); float SoKm2Chieu = SoKm * 2; int LoaiXe = 0; string strLoaiXe = ctrl_LoaiXe_Combobox.LoaiXeID.ToString(); if (!string.IsNullOrEmpty(strLoaiXe)) { LoaiXe = Convert.ToInt16(ctrl_LoaiXe_Combobox.LoaiXeID.ToString()); } TinhTienTheoKm objTinhTien = new TinhTienTheoKm(LoaiXe, SoKm, cbkHaiChieu.Checked); List <TinhTien_SuDungXe> lstTinhTien_TG = new TinhTien_SuDungXe().GetTinhTien_SuDungXe(LoaiXe); if (cbkHaiChieu.Checked) { SoKm2Chieu = SoKm; } if (lstTinhTien_TG.Count > 0) { TinhTien_SuDungXe objTinhTien_SuDungXe = lstTinhTien_TG.Find(T => T.Km_Tu <= SoKm2Chieu && T.Km_Den > SoKm2Chieu); if (objTinhTien_SuDungXe != null) { editTGSuDungXe.Text = string.Format("{0} giờ", objTinhTien_SuDungXe.TG); } else { editTGSuDungXe.Text = "0 giờ"; } } if (!cbkHaiChieu.Checked) { objTinhTien.TongTien2Chieu = 0; } G_TongTienChieuDi = objTinhTien.TongTien1Chieu; G_TongTienChieuVe = objTinhTien.TongTien2Chieu; editTienChieuDi.Text = string.Format("{0:0,0}", objTinhTien.TongTien1Chieu); editTienChieuVe.Text = string.Format("{0:0,0}", objTinhTien.TongTien2Chieu); editTongTien.Text = string.Format("{0:0,0}", objTinhTien.TongTien1Chieu + objTinhTien.TongTien2Chieu); lblTongTien.Text = string.Format("Tổng tiền ({0} Km)", SoKm2Chieu); } catch (Exception ex) { editKm.Focus(); editTienChieuDi.Text = string.Format("{0:0,0}", 0); editTienChieuVe.Text = string.Format("{0:0,0}", 0); editTongTien.Text = string.Format("{0:0,0}", 0); lblTongTien.Text = "Tổng tiền (" + 0 + " Km)"; G_TongTienChieuDi = 0; G_TongTienChieuVe = 0; } }
private void btnTinhTien_Click(object sender, EventArgs e) { float KmMoCua = (float)numKmMoCua.Value; float GiaMoCua = (float)numGiaMoCua.Value; float KmNguong1 = (float)numKmNguong1.Value; float GiaNguong1 = (float)numGiaNguong1.Value; float KmNguong2 = (float)numKmNguong2.Value; float GiaNguong2 = (float)numGiaNguong2.Value; float KmNguong3 = (float)numKmNguong3.Value; float GiaNguong3 = (float)numGiaNguong3.Value; float CVN1_NumDiTu = (float)CV_N1_NumDiTu.Value; float CVN1_NumDiDen = (float)CV_N1_NumDiDen.Value; float CVN1_NumGiam = (float)CV_N1_NumGiam.Value; float CVN2_NumDiTu = (float)CV_N2_NumDiTu.Value; float CVN2_NumGiam = (float)CV_N2_NumGiam.Value; int loaiXe = Convert.ToInt16(cbLoaiXe.SelectedValue.ToString()); TinhTienTheoKm objTinhTien = new TinhTienTheoKm( KmMoCua, GiaMoCua, KmNguong1, GiaNguong1, KmNguong2, GiaNguong2, KmNguong3, GiaNguong3, CVN1_NumDiTu, CVN1_NumDiDen, CVN1_NumGiam, CVN2_NumDiTu, CVN2_NumGiam, CV_N2_ChkAll.Checked, 0, 0, loaiXe, txtThongTinThueBao.Text); if (isUpdate) { if (!objTinhTien.Update_New()) { new MessageBox.MessageBoxBA().Show("Lỗi cập nhật thông tin giá cước mới."); return; } } else { if (!objTinhTien.Insert()) { new MessageBox.MessageBoxBA().Show("Lỗi cập nhật thông tin giá cước mới."); return; } } objTinhTien = null; SaveTinhTienSuDung(loaiXe); new MessageBox.MessageBoxBA().Show("Cập nhật thông tin giá cước mới thành công."); }
private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (radioButton2.Checked) { TinhTienTheoKm objTinhTien = new TinhTienTheoKm(7, 1); GetMessaage(objTinhTien); Calculator(); } }
private void GetMessaage(TinhTienTheoKm TinhTien) { //1,2 Km đầu tiên : lblMessage1.Text = string.Format("{0:0.0}", TinhTien.KmMoCua) + " Km đầu tiên : " + string.Format("{0:0,0}", TinhTien.GiaMoCua) + " VND"; //1,2 --> 30 Km tiếp theo : lblMessage2.Text = string.Format("{0:0.0}", TinhTien.KmMoCua) + " -->: " + string.Format("{0:0,0}", TinhTien.KmNguong1) + " Km tiếp theo : " + string.Format("{0:0,0}", TinhTien.GiaNguong1) + " VND"; // Từ Km 31 trở lên : lblMessage3.Text = "Từ Km " + string.Format("{0:0,0}", TinhTien.KmNguong1 + 1) + " : " + string.Format("{0:0,0}", TinhTien.GiaNguong2) + " VND"; // Khách đi 2 chiều mà lớn hơn bằng 30 Km, chiều về bằng 30% chiều đi lblMessage4.Text = "Khách đi 2 chiều mà lớn hơn bằng " + string.Format("{0:0,0}", TinhTien.KmNguong2Chieu) + " Km, chiều về bằng " + string.Format("{0:0,0}", 100 - TinhTien.TiLeGiamGia2Chieu) + "% chiều đi"; }
private void loadLoaiXe() { DataTable dt = new TinhTienTheoKm().GetAllLoaiXe(); if (dt != null && dt.Rows.Count > 0) { cbLoaiXe.DisplayMember = "TenLoaiXe_SoCho"; cbLoaiXe.ValueMember = "LoaiXeID"; cbLoaiXe.DataSource = dt; cbLoaiXe.SelectedIndex = 0; } }
private void frmTinhTienTheoKm_Load(object sender, EventArgs e) { if (rad4Cho.Checked) { TinhTienTheoKm objTinhTien = new TinhTienTheoKm(4, 1); GetMessaage(objTinhTien); } LoadDiaDanh(); chkDiaDanh.Checked = false; cboDiaDanh.Enabled = false; }
private void GetMessaage(TinhTienTheoKm TinhTien) { //1,2 Km đầu tiên : lblMessage1.Text = string.Format("{0:0.00}", TinhTien.KmMoCua) + " Km đầu tiên : " + string.Format("{0:0,0}", TinhTien.GiaMoCua) + " VND"; //1,2 --> 30 Km tiếp theo : lblMessage2.Text = string.Format("Km tiếp theo đến Km {0:0.0}", TinhTien.KmNguong1) + " " + string.Format("{0:0,0}", TinhTien.GiaNguong1) + " VND"; // Từ Km 31 trở lên : lblMessage3.Text = "Từ Km " + string.Format("{0:0.0}", TinhTien.KmNguong1 + 1) + " : " + string.Format("{0:0,0}", TinhTien.GiaNguong2) + " VND"; // Khách đi 2 chiều mà lớn hơn bằng 30 Km, chiều về bằng 30% chiều đi //khách đi 2 chiều trong ngày , cự ly 30 km (cả đi và về > 60 km), chiều về được giảm 60% // lblMessage4.Text = "Khách đi 2 chiều mà lớn hơn bằng " + string.Format("{0:0,0}", TinhTien.KmNguong2Chieu) + " Km, chiều về bằng " + string.Format("{0:0,0}", 100 - TinhTien.TiLeGiamGia2Chieu) + "% chiều đi"; txtThongTinThueBao.Text = TinhTien.ThongTinThueBao; }
private void btnLuu_Click(object sender, EventArgs e) { string TenDiaDanh = StringTools.TrimSpace(txtTenDiaDanh.Text); int Km = Convert.ToInt16(numKm.Value); if (!this.ValidateData(TenDiaDanh, Km)) { new MessageBox.MessageBoxBA().Show(this, "Bạn phải nhập thông tin tên địa danh và Km > 0.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information); return; } if (TinhTienTheoKm.CheckTrungTen(g_ID, TenDiaDanh)) { new MessageBox.MessageBoxBA().Show(this, "Bạn kiểm tra lại tên địa danh bị trùng.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information); return; } if (g_ID > 0) // Update { if (!TinhTienTheoKm.UpdateDiaDanhKm(g_ID, TenDiaDanh, Km)) { new MessageBox.MessageBoxBA().Show(this, "Lỗi cập nhật thông tin.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information); return; } else { new MessageBox.MessageBoxBA().Show(this, "Cập nhật thông tin thành công.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information); this.Close(); } } else { if (!TinhTienTheoKm.InsertDiaDanhKm(TenDiaDanh, Km)) { new MessageBox.MessageBoxBA().Show(this, "Lỗi cập nhật thông tin.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information); return; } else { new MessageBox.MessageBoxBA().Show(this, "Nhập mới thành thông tin thành công.", "Thông báo", Taxi.MessageBox.MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information); this.Close(); } } }
private void btnTimKiem_Click(object sender, EventArgs e) { string TenDiaDanh = StringTools.TrimSpace(txtTimKiem.Text); if (TenDiaDanh.Length <= 0) { this.LoadDiaDanh(); } else { gridDiaDanhKm.DataMember = "listDiaDanh"; gridDiaDanhKm.SetDataBinding(TinhTienTheoKm.SearchDiaDanhByTen(TenDiaDanh), "listDiaDanh"); } }
private void LoadDuLieu(int idLoaiXe) { try { TinhTienTheoKm obj4 = TinhTienTheoKm.GetThongSoTinhTen(idLoaiXe); if (obj4.LoaiXe == 0) { isUpdate = false; } else { isUpdate = true; } //mTongTien1Chieu = TinhTien1Chieu(SoKm); //if (SoKm < KmNguong2Chieu) mTongTien2Chieu = mTongTien1Chieu; //else mTongTien2Chieu = ((100 - TiLeGiamGia2Chieu) / 100) * mTongTien1Chieu; if (obj4.N1_ChieuDiTu <= 0 && obj4.N1_ChieuDiDen <= 0 && obj4.N1_Giam <= 0) { chk_Type.Checked = true; } numGiaMoCua.Value = (float)obj4.GiaMoCua; numKmMoCua.Value = (float)obj4.KmMoCua; numKmNguong1.Value = (float)obj4.KmNguong1; numGiaNguong1.Value = (float)obj4.GiaNguong1; numKmNguong2.Value = (float)obj4.KmNguong2; numGiaNguong2.Value = (float)obj4.GiaNguong2; numKmNguong3.Value = (float)obj4.KmNguong3; numGiaNguong3.Value = (float)obj4.GiaNguong3; CV_N1_NumDiTu.Value = (float)obj4.N1_ChieuDiTu; CV_N1_NumDiDen.Value = (float)obj4.N1_ChieuDiDen; CV_N1_NumGiam.Value = (float)obj4.N1_Giam; CV_N2_NumDiTu.Value = (float)obj4.N2_ChieuDiTu; CV_N2_NumGiam.Value = (float)obj4.N2_Giam; CV_N2_ChkAll.Checked = obj4.IsAll; //numGiaNguong3.Value = (float)obj4.GiaNguong3; //numKmNguong2.Value = (float)obj4.KmNguong2Chieu; //num.Value = (float)obj4.TiLeGiamGia2Chieu; txtThongTinThueBao.Text = obj4.ThongTinThueBao; LoadTinhTien_TG(idLoaiXe); } catch (Exception ex) { LogError.WriteLogError("CapNhatBangGiaCuoc_New.LoadDuLieu", ex); } }
private void DisplayInfo() { try { string strLoaiXe = ctrl_LoaiXe_Combobox.LoaiXeID.ToString(); if (!string.IsNullOrEmpty(strLoaiXe)) { TinhTienTheoKm objTien = new TinhTienTheoKm(Convert.ToInt16(strLoaiXe), 1); ResetLabel(); GetMessaage(objTien); this.Calculator(); } } catch (Exception ex) { LogError.WriteLogError("DisplayInfo: ", ex); } }
protected override object GetData() { var data = Booking.Inst.GetBaoCaoTongHop(ipFromDate.DateTime, ipToDate.DateTime, txtTenLaiXe.Text, txtSoXe.Text); return(data.GroupBy(p => new { p.SoHieuXe, p.LoaiXeID }).Select(p => new Booking() { SoHieuXe = p.Key.SoHieuXe, LoaiXeID = p.Key.LoaiXeID, SoDienThoai = p.First().SoDienThoai, TenLaiXe = p.First().TenLaiXe, TongCuocKhongThanhCong = p.Sum(pi => pi.TongCuocKhongThanhCong), TongCuocDuongDai = p.Sum(pi => pi.TongCuocDuongDai), TongCuocThanhCong = p.Sum(pi => pi.TongCuocThanhCong), KmCoKhach = p.Sum(pi => pi.KmCoKhach), KmRong = p.Sum(pi => { if (pi.KmRong < 0) { return 0 - pi.KmRong; } else { return pi.KmRong; } }), TongTien = p.Sum(pi => { if (pi.KmCoKhach <= 0) { return 0; } TinhTienTheoKm item = new TinhTienTheoKm(pi.LoaiXeID, pi.KmCoKhach); if (item != null) { return (decimal)item.TongTien1Chieu; } else { return (decimal)0; } }) }).OrderBy(p => p.SoHieuXe.To <int>()).ToList()); // Booking.Inst.Get //return base.GetData(); }
private void LoadDuLieu() { TinhTienTheoKm obj4 = new TinhTienTheoKm(G_LoaiCuoc, 4, 1); numGiaMoCua.Value = (float)obj4.GiaMoCua; numKmMoCua4.Value = (float)obj4.KmMoCua; numKmNguong1.Value = (float )obj4.KmNguong1; numGiaNguong1.Value = (float)obj4.GiaNguong1; numGiaNguong2.Value = (float)obj4.GiaNguong2; numKmNguong2Chieu.Value = (float)obj4.KmNguong2Chieu; numTiLeGiamGia2Chieu.Value = (float)obj4.TiLeGiamGia2Chieu; txtThongTinThueBao.Text = obj4.ThongTinThueBao; TinhTienTheoKm obj7 = new TinhTienTheoKm(G_LoaiCuoc, 7, 1); numGiaMoCua7.Value = (float)obj7.GiaMoCua; numKmMoCua7.Value = (float)obj7.KmMoCua; numKmNguong17.Value = (float)obj7.KmNguong1; numGiaNguong17.Value = (float)obj7.GiaNguong1; numGiaNguong27.Value = (float)obj7.GiaNguong2; numKmNguong2Chieu7.Value = (float)obj7.KmNguong2Chieu; numTiLeGiamGia2Chieu7.Value = (float)obj7.TiLeGiamGia2Chieu; }
private void Calculator(bool IsCP) { if (editKm.Text.Length <= 0) { return; } float SoKm = float.Parse(editKm.Text); float SoKm2Chieu = SoKm * 2; int LoaiXe = 4; if (rad4Cho.Checked) { LoaiXe = 4; } if (rad7Cho.Checked) { LoaiXe = 7; } TinhTienTheoKm objTinhTien = new TinhTienTheoKm(chkCuocDem.Checked, LoaiXe, SoKm); editTienChieuDi.Text = string.Format("{0:0,0}", objTinhTien.TongTien1Chieu); editTienChieuVe.Text = string.Format("{0:0,0}", objTinhTien.TongTien2Chieu); editTong.Text = string.Format("{0:0,0}", objTinhTien.TongTien1Chieu + objTinhTien.TongTien2Chieu); lblKm2Chieu.Text = "(" + SoKm2Chieu.ToString() + " Km)"; if (SoKm > objTinhTien.KmNguong2Chieu) { lblPhanTramGiam.Text = string.Format("{0:0}%", objTinhTien.TiLeGiamGia2Chieu); } else { lblPhanTramGiam.Text = ""; } GetMessaage(objTinhTien); }
private void LoadDiaDanh() { cboDiaDanh.DisplayMember = "TenDiaDanh"; cboDiaDanh.ValueMember = "ID"; cboDiaDanh.DataSource = TinhTienTheoKm.GetAllDiaDanh(); }
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 }
public void RouteThread() { IsProcess = true; new Thread(p => { if (IsProcess) { var frm = new DevExpress.Utils.WaitDialogForm("Vui lòng chờ giây lát.", "Hệ thống đang Xử lý...."); while (IsProcess) { frm.Refresh(); Thread.Sleep(100); } frm.Close(); } }).Start(); try { string khoangcach; string thoigian; string addressA = string.Empty; string addressB = string.Empty; string address = string.Empty; MapRoute route = null; InsertDataControl(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, null); // if (_gMapMarkerA == null || _gMapMarkerB == null) { if (_gMapMarkerA != null) { addressA = Service_Common.GetAddressByGeoBA((float)_gMapMarkerA.Position.Lat, (float)_gMapMarkerA.Position.Lng).RemoveRoutePr(); } if (_gMapMarkerB != null) { addressB = Service_Common.GetAddressByGeoBA((float)_gMapMarkerB.Position.Lat, (float)_gMapMarkerB.Position.Lng).RemoveRoutePr(); } } // else { if (!(LoTrinh.Distance > 0 && !processFisrt)) { this.LoTrinh = Taxi.Controls.FastTaxis.TaxiChieuVe.TaxiReturn_Process.LayLoTrinh(_gMapMarkerA.Position, _gMapMarkerB.Position); } processFisrt = true; if (!string.IsNullOrEmpty(LoTrinh.LoTrinh_DiaChi)) { this.Distance = (int)LoTrinh.Distance; khoangcach = (this.Distance).ToString("#,##0.##") + " km"; TinhTienTheoKm objTinhTien = new TinhTienTheoKm(this.LoaiXeId, Distance); TienDuKien = objTinhTien.TongTien1Chieu; time = (float)((float)this.Distance / 40); if (time < 1) { thoigian = ((int)(time * 60)).ToString() + " phút"; } else { thoigian = ((int)time).ToString() + " giờ " + ((int)(((time - ((int)time))) * 60)).ToString() + " phút"; } address = this.LoTrinh.LoTrinh_DiaChi.Replace("=>", "<br/>=>"); route = new MapRoute(this.LoTrinh.ListPoint, "Lộ trình"); } else { khoangcach = "-1"; thoigian = "Không tồn tại đường"; } } InsertDataControl(khoangcach, thoigian, addressA, addressB, address, route); } catch (Exception ex) { new Log().WriteLog(ThongTinDangNhap.USER_ID, "frmUpdateTrip_Map\\RouteThread", DateTime.Now, string.Format("Số lần {0}:{1}", countRouteThread, ex.Message)); if (countRouteThread < 5) { countRouteThread++; RouteThread(); } else { countRouteThread = 0; } } countRouteThread = 0; IsProcess = false; }
private void GetMessaage(TinhTienTheoKm pTien) { if (pTien.GiaMoCua > 0) { lblMessage1.Text = string.Format("{0:0.0} Km đầu tiên : {1:0,0} VND", pTien.KmMoCua, pTien.GiaMoCua); } if (pTien.GiaNguong1 > 0) { lblMessage2.Text = string.Format("Từ {0:0.0} --> {1:0,0}Km : {2:0,0} VND", pTien.KmMoCua, pTien.KmNguong1, pTien.GiaNguong1); } if (pTien.KmNguong2 > 0) { if (pTien.GiaNguong2 > 0) { lblMessage3.Text = string.Format("Từ {0:0.0} --> {1:0,0}Km : {2:0,0} VND", pTien.KmNguong1 + 1, pTien.KmNguong2, pTien.GiaNguong2); } } else { if (pTien.GiaNguong2 > 0) { lblMessage3.Text = string.Format("Từ {0:0.0}Km trở đi : {1:0,0} VND", pTien.KmNguong1 + 1, pTien.GiaNguong2); } } if (pTien.KmNguong3 > 0) { if (pTien.GiaNguong3 > 0) { lblMessage4.Text = string.Format("Từ {0:0,0} --> {1:0,0}Km : {2:0,0} VND", pTien.KmNguong2 + 1, pTien.KmNguong3, pTien.GiaNguong3); } } else { if (pTien.GiaNguong3 > 0) { lblMessage4.Text = string.Format("Từ {0:0,0} trở đi : {1:0,0} VND", pTien.KmNguong2 + 1, pTien.GiaNguong3); } } //lblMessage5.Text = "Khách đi 2 chiều mà lớn hơn bằng " + string.Format("{0:0,0}", TinhTien.KmNguong2Chieu) + " Km, chiều về bằng " + string.Format("{0:0,0}", 100 - TinhTien.TiLeGiamGia2Chieu) + "% chiều đi"; if (pTien.N1_Giam > 0) { cv_lblMsg1.Text = string.Format("Chiều đi từ {0:0.0} --> {1:0,0} : {2:0,0} %", pTien.N1_ChieuDiTu, pTien.N1_ChieuDiDen, pTien.N1_Giam); } else { cv_lblMsg1.Text = ""; } if (pTien.IsAll) { if (pTien.N2_Giam > 0) { cv_lblMsg2.Text = string.Format("Chiều đi > {0:0.0} : giảm {1:0,0} %", pTien.N2_ChieuDiTu, pTien.N2_Giam); } } else { if (pTien.N2_Giam > 0) { cv_lblMsg2.Text = string.Format("Chiều đi > {0:0.0} : giảm {1:0,0} % của phần vượt", pTien.N1_ChieuDiTu, pTien.N2_Giam); } } txtThongTinThueBao.Text = pTien.ThongTinThueBao; }
private void LoadDiaDanh() { gridDiaDanhKm.DataMember = "listDiaDanh"; gridDiaDanhKm.SetDataBinding(TinhTienTheoKm.GetAllDiaDanh(), "listDiaDanh"); }