public HttpResponseMessage Getall([FromBody] RM0015A[] values) { using (DB db = new DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.RM0015A.SingleOrDefault(p => p.RM0015A_ID == val.RM0015A_ID); if (check != null) { check.ghiChu = val.ghiChu; check.trangThai = val.trangThai; try { db.SaveChanges(); rel.set("OK", GetRM0015A.Get(new GetRM0015A.filter() { id = check.RM0015A_ID }), "Thành công."); } catch (Exception fd) { rel.set("ERR", null, "Thất bại: " + fd.Message); } } else { rel.set("NaN", null, "Không thấy dữ liệu."); } 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 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 RmUserToGr([FromBody] MKV9984[] values) { results <MKV9999> rel = new results <MKV9999>(); DB db = new DB(); foreach (MKV9984 val in values) { result <MKV9999> tm = new result <MKV9999>(); MKV9984 check = (from kjkj in db.MKV9984 where kjkj.MKV9999_ID == val.MKV9999_ID && kjkj.MKV9983_ID == val.MKV9983_ID select kjkj).FirstOrDefault(); if (check == null) { } else { db.MKV9984.Remove(check); try { db.SaveChanges(); tm.set("OK", db.MKV9999.SingleOrDefault(p => p.MKV9999_ID == val.MKV9999_ID), "Thành công"); } catch (Exception d) { tm.set("ERR", db.MKV9999.SingleOrDefault(p => p.MKV9999_ID == val.MKV9999_ID), "Thất bại: " + d.Message); } } rel.add(tm); } return((rel.ToHttpResponseMessage())); }
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 update([FromBody] RM0009[] values) { using (DB db = new DB()) { results <RM0009> list = new results <RM0009>(); values.ToList().ForEach(value => { result <RM0009> rel = new result <RM0009>(); var check = db.RM0009.SingleOrDefault(p => p.RM0009_ID == value.RM0009_ID); if (check != null) { db.RM0009.Remove(check); try { db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception l) { rel.set("ERR", value, "Thất bại:" + l.Message); } } else { rel.set("NaN", null, "Thành công"); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage approval([FromBody] KTX0020[] values) { results <KTX0020> rel = new results <KTX0020>(); using (DB db = new DB()) { foreach (var k in values) { result <KTX0020> re = new result <KTX0020>(); var check = db.KTX0020.SingleOrDefault(p => p.KTX0020_ID == k.KTX0020_ID); if (check != null) { check.trangthai = true; check.hotenbengiao = k.hotenbengiao; check.ngayduyetdon = DateTime.Now; check.ngaycohieuluc = DateTime.Now; try { db.SaveChanges(); k.ngayduyetdon = DateTime.Now; k.ngaycohieuluc = DateTime.Now; k.trangthai = true; re.set("OK", k, "Thành công"); } catch (Exception fd) { re.set("ERR", k, "Thất bại: " + fd.Message); } } rel.add(re); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] A0028[] values) { using (DB db = new DB()) { results <A0028> list = new results <A0028>(); values.ToList().ForEach(value => { result <A0028> rel = new result <A0028>(); var check = db.A0028.SingleOrDefault(p => p.A0028_ID == value.A0028_ID); if (check == null) { var c = db.A0028.Select(p => p.sophieu).Max(); value.sophieu = (c == null ? 0 : c) + 1; db.A0028.Add(value); try { db.SaveChanges(); rel.set("OK", value); } catch (Exception d) { rel.set("ERR", value, "Thất bại: " + d.Message); } } else { rel.set("EXIST", value, "Lỗi: Đã tồn tại"); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage Edit([FromBody] MKV9981[] value) { using (DB db = new DB()) { results <MKV9981> list = new results <MKV9981>(); foreach (var val in value) { result <MKV9981> rel = new result <MKV9981>(); var data = db.MKV9981.SingleOrDefault(p => p.MKV9981_ID == val.MKV9981_ID); if (data != null) { data.TENHANHDONG = val.TENHANHDONG; data.LINKMENU = val.LINKMENU; data.IMAGE = val.IMAGE; data.THUTU = val.THUTU; try { db.SaveChanges(); rel.set("OK", data, "Thành công"); } catch (Exception rr) { rel.set("ERR", data, "Thất bại: " + rr.Message); } } else { rel.set("ERR", val, "Thất bại: Không tìm thấy dữ liệu."); } list.add(rel); } return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage delete([FromBody] KTX0010[] values) { DB db = new DB(); results <KTX0010> list = new results <KTX0010>(); foreach (var value in values) { result <KTX0010> rel = new result <KTX0010>(); var check = db.KTX0010.SingleOrDefault(p => p.KTX0010_ID == value.KTX0010_ID); if (check != null) { try { db.KTX0010.Remove(check); db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception rr) { rel.set("ERR", value, "Thất bại: " + rr.Message); } } else { rel.set("ERR", value, "Không thấy dữ liệu bản ghi."); } list.add(rel); } return(list.ToHttpResponseMessage()); }
public HttpResponseMessage Getall([FromBody] KTX0049[] values) { using (DB db = new DB()) { results <KTX0049> list = new results <KTX0049>(); values.ToList().ForEach(value => { result <KTX0049> rel = new result <KTX0049>(); var check = db.KTX0049.SingleOrDefault(ppp => ppp.User_ID == value.User_ID); if (check == null) { var k = db.Database.SqlQuery <object>(@"insert into ktx0049(User_ID,startdate,enddate,ghichu,trangthai) values ('" + value.User_ID + "','" + value.startdate + "','" + value.enddate + "',N'" + value.ghichu + "'," + (value.trangthai == true?1:0) + ");").ToList(); //if (k.FirstOrDefault() == 1) rel.set("OK", value); } else { if (value.startdate < check.startdate) { check.startdate = value.startdate; } if (value.enddate > check.enddate) { check.enddate = value.enddate; } check.ghichu = value.ghichu; check.trangthai = value.trangthai; rel.set("OK", value); } list.add(rel); }); db.SaveChanges(); return(list.ToHttpResponseMessage()); } }
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 Update([FromBody] KTX0031[] values) { using (var db = new DB()) { results <KTX0031> list = new results <KTX0031>(); foreach (var value in values) { result <KTX0031> rel = new result <KTX0031>(); var check = db.KTX0031.SingleOrDefault(p => p.KTX0031_ID == value.KTX0031_ID); if (check != null) { check.soluongtra = value.soluongtra; check.ngaytra = DateTime.Now; try { db.SaveChanges(); rel.set("OK", check, "Thành công."); } catch { rel.set("ERR", value, REST.ERR); } } else { rel.set("NaN", check, REST.NaN); } list.add(rel); } return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage updatenguoiphongvan([FromBody] A0028E[] value) { using (DB db = new DB()) { results <Exception> list = new results <Exception>(); value.ToList().ForEach(val => { result <Exception> rel = new result <Exception>(); var check = db.A0028E.Where(p => p.A0028_ID == val.A0028_ID && p.MKV9999_ID == val.MKV9999_ID); if (check == null) { db.A0028E.Add(new A0028E() { A0028E_ID = val.A0028E_ID, MKV9999_ID = val.MKV9999_ID }); } try { db.SaveChanges(); rel.set("OK", null); } catch (Exception j) { rel.set("OK", j); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] KTX0010[] values) { DB db = new DB(); results <KTX0010> list = new results <KTX0010>(); foreach (var value in values) { result <KTX0010> rel = new result <KTX0010>(); KTX0010 t = value; var check = db.KTX0010.FirstOrDefault(p => p.WH0007_ID == t.WH0007_ID && p.WH0007_ID != null); if (check == null) { try { var kkk = db.KTX0010.Add(t); db.SaveChanges(); rel.set("OK", t, "Thành công"); } catch (Exception rr) { rel.set("ERR", t, "Thất bại: " + rr.Message); } } else { rel.set("ERR", t, "Thất bại: Mặt hàng này đã tồn tại trên hệ thống."); } list.add(rel); } return(list.ToHttpResponseMessage()); }
public HttpResponseMessage add([FromBody] KTX0001[] values) { if (values == null) { return(null); } DB db = new DB(); results <KTX0001> list = new results <KTX0001>(); foreach (var value in values) { result <KTX0001> rel = new result <KTX0001>(); var checkgiuong = db.KTX0001.FirstOrDefault(p => p.ten == value.ten && p.type == 4); if (checkgiuong == null) { KTX0001 t = value; try { var kkk = db.KTX0001.Add(t); db.SaveChanges(); for (int i = 0; i < t.slot; i++) { db.KTX0002.Add(new KTX0002() { ghichu = "Giường trống", KTX0001_ID = t.KTX0001_ID, ten = "GA-" /*+ t.ten.Replace("", "")*/ + t.ten + "-G0" + (i + 1), thutu = i, trangthai = false }); } db.SaveChanges(); if (t.type == 4) { var arrtaisan = db.KTX0010.Where(p => p.loai == 1).Select(p => new { p.KTX0010_ID, p.soluongmacdinh }).ToList(); arrtaisan.ForEach(val => { var g = new KTX0011() { KTX0001_ID = t.KTX0001_ID, KTX0010_ID = val.KTX0010_ID, soluong = val.soluongmacdinh }; db.KTX0011.Add(g); //t.KTX0011.Add(g); }); try { db.SaveChanges(); } catch { } } rel.set("OK", t, "Thành công"); } catch (Exception rr) { rel.set("ERR", t, "Thất bại: " + rr.Message); } } else { rel.set("ERR", value, "Thất bại: Phòng có mã " + value.ten + " đã tồn tại, xin nhập tên khác."); } list.add(rel); } return(list.ToHttpResponseMessage()); }
public HttpResponseMessage Agree([FromBody] KTX0023[] values) { using (DB db = new DB()) { results <KTX0023> list = new results <KTX0023>(); foreach (var k in values) { result <KTX0023> rel = new result <KTX0023>(); var check = (from kkk in db.KTX0023 where kkk.KTX0023_ID == k.KTX0023_ID select kkk).FirstOrDefault(); if (check != null) { var check_kt20 = (from temp in db.KTX0020 where temp.KTX0002_ID == k.KTX0002_ID && temp.MKV9999_ID == k.MKV9999_ID select temp).FirstOrDefault(); if (check_kt20 != null) { var kt02 = db.KTX0002.FirstOrDefault(p => p.KTX0002_ID == check_kt20.KTX0002_ID); kt02.trangthai = false; var kt03 = db.KTX0003.FirstOrDefault(p => p.KTX0003_ID == check_kt20.KTX0003_ID); if (kt03 != null) { kt03.trangthai = false; } check_kt20.trangthai2 = true; db.SaveChanges(); check.trangthai = true; check.nhanxet = k.nhanxet; db.KTX0031.Where(p => p.MKV9999_ID == check.MKV9999_ID && p.trangthai == true).ToList().ForEach(val => { val.trangthai = false; val.ngaytra = DateTime.Now; val.KTX0023_ID = check.KTX0023_ID; }); db.SaveChanges(); rel.set("OK", k, "Thành công"); try { } catch (Exception fd) { rel.set("ERR", check, "Thất bại: " + fd.Message); } } else { rel.set("NaN", check, "Không tìm thất dữ liệu KTX0020."); } } else { rel.set("NaN", k, "Không tìm thấy bản ghi mã: KTX0023_ID " + k.KTX0023_ID); } list.add(rel); } return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] RM0010[] values) { using (DB db = new DB()) { results <object> list = new results <object>(); values.ToList().ForEach(value => { result <object> rel = new result <object>(); var check = db.RM0010.SingleOrDefault(p => p.RM0010_ID == value.RM0010_ID); if (check == null) { RM0010 newj = value; if (newj.sophieu != null) { newj.A0028_ID = db.A0028.Where(p => p.sophieu == newj.sophieu).Select(p => p.A0028_ID).FirstOrDefault(); var rm01_id = db.A0028.Where(p => p.sophieu == newj.sophieu).Select(p => p.T005C).FirstOrDefault(); newj.RM0001_ID = rm01_id != null ? int.Parse(rm01_id) : 0; newj.bophanid = db.A0028.Where(p => p.sophieu == newj.sophieu).Select(p => p.T098C).FirstOrDefault(); } newj.trangthai = true; db.RM0010.Add(newj); try { db.SaveChanges(); rel.set("OK", ungvienget.Getallungvien(new ungvienget.filterungvien() { id = value.RM0010_ID }), "Thành công"); } catch (Exception l) { rel.set("ERR", null, "Thất bại:" + l.Message); } } else { if (ungvienget.updateungvien(value)) { rel.set("OK", ungvienget.Getallungvien(new ungvienget.filterungvien() { id = value.RM0010_ID }), "Thành công"); } else { rel.set("ERR", null, "Thất bại:"); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] RM0013[] values) { using (DB db = new DB()) { results <object> list = new results <object>(); values.ToList().ForEach(value => { result <object> rel = new result <object>(); var check = db.RM0013.SingleOrDefault(p => p.RM0013_ID == value.RM0013_ID); if (check == null) { db.RM0013.Add(value); try { db.SaveChanges(); rel.set("OK", GettRM0013(new filter() { id = value.RM0013_ID }), "Thành công"); } catch (Exception fd) { rel.set("ERR", null, "Thất bại: " + fd.Message); } } else { check.ghiChu = value.ghiChu; check.ketQua = value.ketQua; check.MKV9999_ID = value.MKV9999_ID; check.nhanXet = value.nhanXet; check.trangThai = value.trangThai; try { db.SaveChanges(); rel.set("OK", GettRM0013(new filter() { id = check.RM0013_ID }), "Thành công"); } catch (Exception fd) { rel.set("ERR", null, "Thất bại: " + fd.Message); } } updateKetqua(value.RM0015_ID); list.add(rel); }); return(list.ToHttpResponseMessage()); } }
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 DeleteBed([FromBody] KTX0002[] EPs) { using (var db = new DB()) { results <KTX0002> list = new results <KTX0002>(); foreach (var EP in EPs) { result <KTX0002> rel = new result <KTX0002>(); var check = (from temp in db.KTX0020 where temp.KTX0002_ID == EP.KTX0002_ID select temp).FirstOrDefault(); if (check != null) { check.KTX0002_ID = null; check.KTX0001_ID = null; check.KTX0003_ID = null; check.khoaphong = null; check.sotu = null; string sokhoatu = check.sokhoatu; check.sokhoatu = null; try { db.SaveChanges(); rel.set("OK", EP, "Thành công"); var k = db.KTX0002.FirstOrDefault(p => p.KTX0002_ID == EP.KTX0002_ID); k.trangthai = false; db.SaveChanges(); if (sokhoatu != null) { var kk = db.KTX0003.FirstOrDefault(p => p.MaKhoa == sokhoatu); if (kk != null) { kk.trangthai = false; db.SaveChanges(); } } } catch (Exception j) { rel.set("ERR", EP, "Thất bại: " + j.Message); } } else { rel.set("ERR", EP, "Không có dữ liệu"); } list.add(rel); } return(list.ToHttpResponseMessage()); } }
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 Add([FromBody] KTX0002[] values) { if (values == null) { return(null); } using (DB db = new DB()) { results <KTX0002> list = new results <KTX0002>(); foreach (var value in values) { result <KTX0002> rel = new result <KTX0002>(); var checkphong = db.KTX0001.Where(p => p.KTX0001_ID == value.KTX0001_ID || p.ten == value.ghichu).FirstOrDefault(); if (checkphong != null) { var checkmakhoa = db.KTX0002.FirstOrDefault(p => p.ten == value.ten); if (checkmakhoa == null) { KTX0002 k = new KTX0002() { KTX0001_ID = checkphong.KTX0001_ID, ghichu = value.ghichu, ten = value.ten, trangthai = value.trangthai, type = value.type }; db.KTX0002.Add(k); try { db.SaveChanges(); //k.KTX0001 = null; rel.set("OK", k, "Thành Công."); } catch (Exception t) { rel.set("ERR", value, "Thất bại: " + t.Message); } } else { rel.set("ERR", value, "Thất bại: Mã khóa phòng này đã tồn tại."); } } else { rel.set("NaN", value, "Thất bại: Không tìm thấy thông tin phòng."); } list.add(rel); } return(list.ToHttpResponseMessage()); } }
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] 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] 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 hoanthanhdanhgia([FromBody] RM0015[] data) { using (DB db = new DB()) { results <object> list = new results <object>(); data.ToList().ForEach(values => { result <object> rel = new result <object>(); var check = db.RM0015.SingleOrDefault(p => p.RM0015_ID == values.RM0015_ID); if (check != null) { check.ghiChu = values.ghiChu; check.ketQua = values.ketQua; check.RM0008_ID = values.RM0008_ID; check.RM0010_ID = values.RM0010_ID; check.thoiGianPhongVan = values.thoiGianPhongVan; check.trangThai = values.trangThai; check.vongPhongVan = values.vongPhongVan; try { db.SaveChanges(); db.RM0015A.RemoveRange(check.RM0015A); db.SaveChanges(); check.RM0015A = values.RM0015A; db.SaveChanges(); rel.set("OK", getallRM0015(new filter() { id = check.RM0015_ID }), "Thành công."); } catch (Exception fd) { rel.set("ERR", null, "Thất bại: " + fd.Message); } } else { rel.set("NaN", null, "Không thấy dữ liệu."); } 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()); } }
public HttpResponseMessage update([FromBody] KTX0003[] values) { using (DB db = new DB()) { results <KTX0003> list = new results <KTX0003>(); foreach (var value in values) { result <KTX0003> rel = new result <KTX0003>(); var check = db.KTX0003.SingleOrDefault(p => p.KTX0003_ID == value.KTX0003_ID); if (check != null) { check.ghichu = value.ghichu; check.MaKhoa = value.MaKhoa; check.SoTu = value.SoTu; check.trangthai = value.trangthai; check.type = value.type; try { db.SaveChanges(); rel.set("OK", value, "Thành Công."); var k20 = db.KTX0020.FirstOrDefault(p => p.KTX0003_ID == value.KTX0003_ID); if (k20 != null) { k20.sokhoatu = value.MaKhoa; k20.sotu = value.SoTu; db.SaveChanges(); } } catch (Exception t) { rel.set("ERR", value, "Thất bại: " + t.Message); } } else { rel.set("NaN", value, "Thất bại: Không tìm thấy thông tin phòng."); } list.add(rel); } return(list.ToHttpResponseMessage()); } }