public HttpResponseMessage kiemtradangkyxebus(string manhansu) { using (QLDX_DB db = new QLDX_DB()) { var check = db.Database.SqlQuery <DX0020>(@" select * from dx0020 where manhansu='" + manhansu + @"' ").FirstOrDefault(); if (check == null) { return(REST.GetHttpResponseMessFromObject(new { value = false, messager = "Bạn chưa đăng ký sử dụng xe bus hằng ngày nên chưa thể yêu cầu sử dụng xe taxi." })); } else { var check2 = db.Database.SqlQuery <DX0010>(@" select top(1) * from dx0010 where type=3 and dx0010_ID in ( select dx0010_id from dx0010d where dx0011_id= (select top(1) dx0011_id from dx0011 where dx0011_ID=(select top(1) dx0011_id from dx0020 where manhansu='" + manhansu + @"'))) ").FirstOrDefault(); if (check2 == null) { return(REST.GetHttpResponseMessFromObject(new { value = false, messager = "Tuyến xe bus bạn đăng ký đi làm hằng ngày chưa hỗ trợ sử dụng taxi khi làm thêm giờ." })); } else { return(REST.GetHttpResponseMessFromObject(new { value = true, messager = "" })); } } return(REST.GetHttpResponseMessFromObject(check)); } }
public HttpResponseMessage Deletes([FromBody] DX0011[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0011.SingleOrDefault(p => p.DX0011_ID == val.DX0011_ID); if (check != null) { db.DX0011.Remove(check); try { db.SaveChanges(); rel.set("DELETE", getDX0011(check)); } catch (Exception s) { rel.set("ERR", getDX0011(check), s.Message); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage getall(string id) { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0011.Where(p => id == "all" ? true : (p.DX0011_ID == id)).OrderBy(t => t.tenDiemDon).Select(p => new { p.DX0011_ID, p.DX0013_ID, p.DX0014_ID, p.maDiemDon, p.tenDiemDon, p.ghiChu, p.trangThai, p.taxi, p.gioDon, p.thuTu, p.lat, p.lng, DX0010D = p.DX0010D.Select(o => new { o.DX0010_ID, o.DX0011_ID, DX0010 = new { o.DX0010.bienSoXe, o.DX0010.DX0010_ID, o.DX0010.ghiChu, o.DX0010.maTuyenXe, o.DX0010.mobile, o.DX0010.tenLaiXe, o.DX0010.tenTuyenXe, o.DX0010.thuTu, o.DX0010.trangThai } }), DX0014 = new { p.DX0014.DX0014_ID, p.DX0014.tenDiaDanh } }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage add([FromBody] DX0001[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0001.Where(p => p.A0028_ID == val.A0028_ID).FirstOrDefault(); if (check == null) { db.DX0001.Add(val); try { db.SaveChanges(); rel.set("OK", getDX0001(val)); } catch (Exception f) { rel.set("ERR", getDX0001(val), f.Message); } } else { rel.set("EXIST", getDX0001(check)); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage getalldiemdonduocditaxi(string DX0070_id) { using (QLDX_DB db = new QLDX_DB()) { // var data = db.Database.SqlQuery<DX0011>("select * from dx0011 as G where DX0013_ID in (select dx0013_id from dx0013) order by DX0013_ID"); var data = db.DX0011.AsEnumerable().Where(p => db.DX0013.Select(f => f.DX0013_ID).Contains(p.DX0013_ID)).Select(p => new { p.DX0011_ID, p.DX0013_ID, p.DX0014_ID, p.maDiemDon, p.tenDiemDon, p.ghiChu, p.gioDon, p.trangThai, p.taxi, p.thuTu, p.lat, p.lng, DX0013 = db.DX0013.AsEnumerable().Where(f => f.trangThai == true).OrderBy(f => f.DX0013_ID).Select(f => new { f.DX0011_ID, f.DX0013_ID, f.ghiChu, f.lat, f.lng, f.maDiemTaxi, f.tenDiemTaxi, f.trangThai, count = p.DX0013_ID == f.DX0013_ID? db.Database.SqlQuery <DX0001>("select * from dx0001 as G where maForm='SF015' and T007C='" + DX0070_id + "' and T002C in (select manhansu from dx0020 where DX0011_ID='" + p.DX0011_ID + "') and ngayTao>=CONVERT(date,getdate(),23)") : null }) });; return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage delete([FromBody] DX0070[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0070.SingleOrDefault(p => p.DX0070_ID == val.DX0070_ID); if (check != null) { db.DX0070.Remove(check); try { db.SaveChanges(); rel.set("OK", getDX0070(val)); } catch (Exception d) { rel.set("ERR", val, d.Message); } } else { rel.set("NOT_EXIST", val); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage getall() { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0012.AsEnumerable().Select(p => new { p.DX0012_ID, p.ghiChu, p.bienSoXe, p.DX0010_ID, p.mobile, p.soLuongGhe, p.tenLaiXe, p.trangThai, DX0010 = p.DX0010 == null?null: new { p.DX0010.bienSoXe, p.DX0010.DX0010_ID, p.DX0010.ghiChu, p.DX0010.maTuyenXe, p.DX0010.mobile, p.DX0010.tenLaiXe, p.DX0010.tenTuyenXe, p.DX0010.thuTu, p.DX0010.trangThai, p.DX0010.type } }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage getall() { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0050.AsEnumerable().Select(p => new { p.DX0050_ID, p.ghiChu, p.hangTaxi, p.loaiThe, p.maThe, p.ngayHetHan, p.ngayPhatHanh, p.soThe, p.trangThai, DX0060 = p.DX0060.Select(k => new { k.DX0050_ID, k.DX0060_ID, k.ghiChu, k.thoiGian, DX0061 = k.DX0061.Select(f => new { f.DX0001_ID, f.DX0060_ID, f.DX0061_ID, f.ghiChu }) }) }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage gettuyenbus(string id) { using (QLDX_DB db = new QLDX_DB()) { var check = db.Database.SqlQuery <DX0010>("select top(1) * from dx0010 where type=3 and dx0010_ID in (select dx0010_id from dx0010d where dx0011_id= (select top(1) dx0011_id from dx0011 where dx0011_ID=(select top(1) dx0011_id from dx0020 where manhansu='" + id + "')))").FirstOrDefault(); return(REST.GetHttpResponseMessFromObject(check)); } }
public HttpResponseMessage getallLocation(string DX0014_ID) { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0011.Where(x => x.DX0014_ID == DX0014_ID).Select(g => new { g.DX0011_ID, g.DX0013_ID, g.DX0014_ID, g.ghiChu, g.lat, g.lng, g.maDiemDon, g.taxi, g.tenDiemDon, g.thuTu, g.trangThai }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage Getdondangky() { using (QLDX_DB db = new QLDX_DB()) { var data = db.Database.SqlQuery <DX0001>(@"select * from DX0001 where maForm='SF014'"); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage Getdondangky(string id) { using (QLDX_DB db = new QLDX_DB()) { var data = db.Database.SqlQuery <DX0001>(@"select * from DX0001 where DX0001_ID='" + id + "'").FirstOrDefault(); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage getall([FromBody] filter filter) { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0060.AsEnumerable().Select(p => getDX00600(p)); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage getall(string id) { using (QLDX_DB db = new QLDX_DB()) { var data = db.Database.SqlQuery <DX0013>(@"select * from DX0013 where trangthai=1" + (id != "all" ? " and DX0013_ID='" + id + "'" : "") + " order by DX0013_ID"); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage getdx0011(string id) { using (QLDX_DB db = new QLDX_DB()) { var data = db.Database.SqlQuery <DX0011>(@"select * from DX0011 where DX0013_ID='" + id + "'"); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage getall(string id) { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0010.AsEnumerable().Where(p => id == "all" ? true : (p.DX0010_ID == id)).Select(p => new { p.DX0010_ID, p.ghiChu, p.maTuyenXe, p.tenTuyenXe, p.thuTu, p.trangThai, DX0010D = p.DX0010D.Select(o => new { o.DX0010_ID, o.DX0011_ID, o.thuTu, DX0011 = new { o.DX0011.DX0011_ID, o.DX0011.DX0013_ID, o.DX0011.ghiChu, o.DX0011.lat, o.DX0011.lng, o.DX0011.maDiemDon, o.DX0011.taxi, o.DX0011.tenDiemDon, o.DX0011.thuTu, o.DX0011.trangThai, DX0020 = (o.DX0011.DX0020.Count == 0 ? null : o.DX0011.DX0020.Select(h => new { h.ban_id, h.capbac, h.chucvu, h.cmtnd_so, h.diachitamtru, h.diachithuongtru, h.dienthoai_didong, h.DX0011_ID, h.DX0020_ID, h.email, h.gioitinh, h.hodem, h.manhansu, h.ngaysinh, h.phong_id, h.ten, h.thetu_id, h.trangThai })) } }).OrderBy(f => f.thuTu) }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage Getdondangkylamthem([FromBody] filter filter) { using (QLDX_DB db = new QLDX_DB()) { var data = db.Database.SqlQuery <DX0001>(@"select * from DX0001 where maForm='SF015' " + (filter.trangThai != null? ("and trangThai=" + filter.trangThai) : "") + (filter.ngaytao == null?"": (filter.ngaytao == true ? "and CONVERT(date, ngaytao, 111)<CONVERT(date, getdate(), 111)" : "and CONVERT(date, ngaytao, 111)>=CONVERT(date, getdate(), 111)")) ); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage getall_tuyenduong() { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0020.Select(p => new { p.ban_id, p.capbac, p.chucvu, p.cmtnd_so, p.diachitamtru, p.diachithuongtru, p.dienthoai_didong, p.DX0010_ID, p.DX0011_ID, p.DX0020_ID, p.email, p.gioitinh, p.hodem, p.manhansu, p.ngaysinh, p.phong_id, p.ten, p.thetu_id, p.thoiGianSuDung, p.trangThai, DX0010 = new { p.DX0010.bienSoXe, p.DX0010.DX0010_ID, p.DX0010.ghiChu, p.DX0010.maTuyenXe, p.DX0010.mobile, p.DX0010.tenLaiXe, p.DX0010.tenTuyenXe, p.DX0010.thuTu, p.DX0010.trangThai, p.DX0010.type, }, DX0011 = new { p.DX0011.DX0011_ID, p.DX0011.DX0013_ID, p.DX0011.DX0014_ID, p.DX0011.ghiChu, p.DX0011.lat, p.DX0011.lng, p.DX0011.maDiemDon, p.DX0011.taxi, p.DX0011.tenDiemDon, p.DX0011.thuTu, p.DX0011.trangThai }, }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage Getdondicongtac(string trangThai) { using (QLDX_DB db = new QLDX_DB()) { var sqlcmd = trangThai == "1" ? " select * from DX0001 where maForm = 'SF013' and trangThai = 1 " : trangThai == "2" ? "select * from DX0001 where maForm='SF013' and trangThai=2 " : trangThai == "3" ? "select * from DX0001 where maForm='SF013' and trangThai=3 and CONVERT(date,T012C,23)<GETDATE()" : "select * from DX0001 where maForm='SF013'"; var data = db.Database.SqlQuery <DX0001>(sqlcmd); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage Update([FromBody] DX0011[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0011.SingleOrDefault(p => p.DX0011_ID == val.DX0011_ID); if (check != null) { check.DX0013_ID = val.DX0013_ID; check.DX0014_ID = val.DX0014_ID; check.ghiChu = val.ghiChu; check.lat = val.lat; check.lng = val.lng; check.gioDon = val.gioDon; check.maDiemDon = val.maDiemDon; check.taxi = val.taxi; check.tenDiemDon = val.tenDiemDon; check.thuTu = val.thuTu; check.trangThai = val.trangThai; try { db.SaveChanges(); rel.set("UPDATE", getDX0011(check)); } catch (Exception s) { rel.set("ERR", null, s.Message); } } else { db.DX0011.Add(val); try { db.SaveChanges(); rel.set("OK", getDX0011(val)); } catch (Exception s) { rel.set("ERR", null, s.Message); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage getall() { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0014.Where(f => f.trangThai == true).Select(p => new { p.DX0014_ID, p.ghiChu, p.tenDiaDanh, p.trangThai, //DX0011 = p.DX0011.Select(g => new { g.DX0011_ID,g.DX0013_ID,g.DX0014_ID,g.ghiChu,g.lat,g.lng,g.maDiemDon,g.taxi,g.tenDiemDon,g.thuTu,g.trangThai}) }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage add([FromBody] DX0013[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0013.SingleOrDefault(p => p.DX0013_ID == val.DX0013_ID); if (check == null) { db.DX0013.Add(val); try { db.SaveChanges(); rel.set("OK", getDX0013(val), "Thành công."); } catch (Exception f) { rel.set("ERR", getDX0013(val), "Thất bại: "); } } else { check.ghiChu = val.ghiChu; check.lat = val.lat; check.lng = val.lng; check.maDiemTaxi = val.maDiemTaxi; check.tenDiemTaxi = val.tenDiemTaxi; check.trangThai = val.trangThai; try { db.SaveChanges(); rel.set("UPDATE", getDX0013(check), "Thành công."); } catch (Exception f) { rel.set("ERR", getDX0013(val), "Thất bại: "); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage getall(string id) { using (QLDX_DB db = new QLDX_DB()) { var data = db.DX0070.AsEnumerable().Where(p => id == "all" ? true : (p.DX0070_ID == id)).Select(p => new { p.DX0070_ID, p.ghiChu, p.tenKhungGio, p.timeMax, p.timeMin, p.trangThai }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage getall(filter filter) { var test = DateTime.Parse(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day); using (QLDX_DB db = new QLDX_DB()) { DateTime oo = new DateTime(); var data = db.DX0010.AsEnumerable().Where(p => p.trangThai == true && p.type == 3).Select(p => new { p.DX0010_ID, p.ghiChu, p.maTuyenXe, p.tenTuyenXe, p.thuTu, p.type, p.trangThai, DX0010D = p.DX0010D.Select(o => new { o.DX0010_ID, o.DX0011_ID, o.thuTu, DX0011 = new { o.DX0011.DX0011_ID, o.DX0011.DX0013_ID, o.DX0011.ghiChu, o.DX0011.lat, o.DX0011.lng, o.DX0011.maDiemDon, o.DX0011.taxi, o.DX0011.tenDiemDon, o.DX0011.thuTu, o.DX0011.trangThai }, count = db.DX0001.AsEnumerable().Where(a => a.trangThai == 2 && a.maForm == "SF015" && a.T007C == filter.DX0070_ID && db.DX0020.Where(vv => vv.DX0011_ID == o.DX0011_ID).Select(vv => vv.manhansu).Contains(a.T002C) && (DateTime.TryParse(a.ngayTao, out oo)?oo >= test:false) ) }).OrderBy(f => f.thuTu), }); return(REST.GetHttpResponseMessFromObject(data)); } }
public HttpResponseMessage add([FromBody] DX0050[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0050.SingleOrDefault(p => p.DX0050_ID == val.DX0050_ID); if (check == null) { db.DX0050.Add(val); try { db.SaveChanges(); rel.set("OK", getDX0050(val)); } catch (Exception d) { rel.set("ERR", val, d.Message); } } else { check.ghiChu = val.ghiChu; check.hangTaxi = val.hangTaxi; check.trangThai = val.trangThai; check.loaiThe = val.loaiThe; check.maThe = val.maThe; check.ngayHetHan = val.ngayHetHan; check.ngayPhatHanh = val.ngayPhatHanh; check.soThe = val.soThe; try { db.SaveChanges(); rel.set("OK", getDX0050(check)); } catch (Exception d) { rel.set("ERR", getDX0050(check), d.Message); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] DX0010[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0010.SingleOrDefault(p => p.DX0010_ID == val.DX0010_ID); if (check != null) { check.ghiChu = val.ghiChu; check.maTuyenXe = val.maTuyenXe; check.tenTuyenXe = val.tenTuyenXe; check.thuTu = val.thuTu; check.trangThai = val.trangThai; check.type = val.type; try { db.SaveChanges(); rel.set("OK", getDX0010(check)); } catch (Exception ee) { rel.set("ERR", getDX0010(val), ee.Message); } } else { db.DX0010.Add(val); try { db.SaveChanges(); rel.set("OK", getDX0010(val)); } catch (Exception ee) { rel.set("ERR", getDX0010(val), ee.Message); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] DX0001[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var data = db.Database.SqlQuery <DX0020>("select * from DX0020 where manhansu='" + val.T002C + "'").FirstOrDefault(); if (data == null) { var kl = new DX0020() { ban_id = val.T098C, capbac = val.T005C, dienthoai_didong = val.T004C, DX0011_ID = val.T008C, DX0010_ID = val.T009C, hodem = val.T001C, manhansu = val.T002C, trangThai = 1, phong_id = val.T098C, thoiGianSuDung = val.T010C, }; db.DX0020.Add(kl); try { db.SaveChanges(); rel.set("OK", val, "Thành công."); } catch (Exception g) { rel.set("ERR", val, "Thất bại: "); } } else { rel.set("EXIST", val, "Đã tồn tại."); } list.add(rel); }); return(list.ToHttpResponseMessage());; } }
public HttpResponseMessage add([FromBody] DX0012[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0012.SingleOrDefault(p => p.DX0012_ID == val.DX0012_ID); if (check == null) { db.DX0012.Add(val); try { db.SaveChanges(); rel.set("OK", getDX0012(val)); } catch (Exception d) { rel.set("ERR", val, d.Message); } } else { check.ghiChu = val.ghiChu; check.bienSoXe = val.bienSoXe; check.DX0010_ID = val.DX0010_ID; check.mobile = val.mobile; check.soLuongGhe = val.soLuongGhe; check.tenLaiXe = val.tenLaiXe; check.trangThai = val.trangThai; try { db.SaveChanges(); rel.set("OK", getDX0012(check)); } catch (Exception d) { rel.set("ERR", getDX0012(check), d.Message); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] DX0010D[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0010D.Where(p => p.DX0010_ID == val.DX0010_ID && p.DX0011_ID == val.DX0011_ID).FirstOrDefault(); if (check == null) { var l = new DX0010D() { thuTu = val.thuTu, DX0010_ID = val.DX0010_ID, DX0011_ID = val.DX0011_ID, ghiChu = val.ghiChu }; db.DX0010D.Add(l); try { db.SaveChanges(); rel.set("OK", getDX0010D(val)); } catch (Exception f) { rel.set("ERR", getDX0010D(val), f.Message); } } else { check.thuTu = val.thuTu; try { db.SaveChanges(); rel.set("UPDATE", getDX0010D(val)); } catch (Exception f) { rel.set("ERR", getDX0010D(val), f.Message); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] DX0070[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0070.SingleOrDefault(p => p.DX0070_ID == val.DX0070_ID); if (check == null) { db.DX0070.Add(val); try { db.SaveChanges(); rel.set("OK", getDX0070(val)); } catch (Exception d) { rel.set("ERR", val, d.Message); } } else { check.ghiChu = val.ghiChu; check.timeMin = val.timeMin; check.timeMax = val.timeMax; check.tenKhungGio = val.tenKhungGio; check.trangThai = val.trangThai; try { db.SaveChanges(); rel.set("UPDATE", getDX0070(check)); } catch (Exception d) { rel.set("ERR", getDX0070(check), d.Message); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }