public HttpResponseMessage Update2([FromBody] KTX0001 value) { using (DB db = new DB()) { result <KTX0001> rel = new result <KTX0001>(); var check = db.KTX0001.SingleOrDefault(p => p.KTX0001_ID == value.KTX0001_ID); if (check != null) { check.ghichu = value.ghichu; check.khu = value.khu; check.slot = value.slot; check.capbac = value.capbac; check.ten = value.ten; check.thutu = value.thutu; check.trangthai = value.trangthai; check.type = value.type; try { db.SaveChanges(); rel.set("OK", check, "Thành công: "); } catch (Exception d) { rel.set("ERR", check, "Thất bại: " + d.Message); } } return(rel.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 add2([FromBody] RM0007 value) { using (DB db = new DB()) { result <object> rel = new result <object>(); var check = db.RM0007.SingleOrDefault(p => p.MKV9999_ID == value.MKV9999_ID && p.RM0006_ID == value.RM0006_ID); if (check == null) { db.RM0007.Add(value); try { db.SaveChanges(); rel.set("OK", RM0007Get(new filter() { RM0007_ID = value.RM0007_ID })); } catch (Exception fd) { rel.set("ERR", null, "Thất bại: " + fd.Message); } } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage update([FromBody] KTX0040 values) { using (DB db = new DB()) { result <KTX0040> rel = new result <KTX0040>(); var check = db.KTX0040.SingleOrDefault(p => p.KTX0040_ID == values.KTX0040_ID); if (check != null) { check.ghichu = values.ghichu; check.image = values.image; check.noidung = values.noidung; check.thutu = values.thutu; check.tieude = values.tieude; check.trangthai = values.trangthai; try { db.SaveChanges(); rel.set("OK", check, "Thành Công"); } catch (Exception tf) { rel.set("ERR", values, "Thất bại: " + tf.Message); } } else { rel.set("NaN", values, "Không thất dữ liệu"); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage Delete(int id) { using (DB db = new DB()) { result <KTX0002> rel = new result <KTX0002>(); var check = db.KTX0002.SingleOrDefault(p => p.KTX0002_ID == id); if (check != null) { var check2 = db.KTX0020.FirstOrDefault(p => p.KTX0002_ID == check.KTX0002_ID); if (check2 != null) { rel.set("ERR", check, "Thất bại: Giường này đang có người ở, Hãy chuyển người này ra ngoài trước khi xóa giường."); } else { db.KTX0002.Remove(check); try { db.SaveChanges(); rel.set("OK", check, "Thành công."); } catch (Exception t) { rel.set("ERR", check, "Thất bại: " + t.Message); } } } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage update([FromBody] KTX0052 value) { using (DB db = new DB()) { result <KTX0052> rel = new result <KTX0052>(); var check = db.KTX0052.SingleOrDefault(p => p.KTX0052_ID == value.KTX0052_ID); if (check != null) { check.capbac = value.capbac; check.chucvu = value.chucvu; check.cmtnd_ngayhethan = value.cmtnd_ngayhethan; check.cmtnd_noicap = value.cmtnd_noicap; check.cmtnd_so = value.cmtnd_so; check.dienthoai_didong = value.dienthoai_didong; check.gioitinh = value.gioitinh; check.hodem = value.hodem; check.manhansu = value.manhansu; check.ngaysinh = value.ngaysinh; check.phong_id = value.phong_id; check.ten = value.ten; check.thetu_id = value.thetu_id; check.User_ID = value.User_ID; try { db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception l) { rel.set("ERR", value, "Thất bại:" + l.Message); } } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage delete(int id) { using (DB db = new DB()) { result <object> rel = new result <object>(); var check = db.RM0015.SingleOrDefault(p => p.RM0015_ID == id); if (check != null) { db.RM0015.Remove(check); try { db.SaveChanges(); var kl = db.RM0010.SingleOrDefault(p => p.RM0010_ID == check.RM0010_ID); if (kl != null) { kl.trangthai = true; db.SaveChanges(); } rel.set("OK", null, "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."); } return(rel.ToHttpResponseMessage());; } }
public HttpResponseMessage add([FromBody] MKV9998 values) { using (DB db = new DB()) { result <MKV9998> rel = new result <MKV9998>(); { var check = db.MKV9998.SingleOrDefault(p => p.phong_id == values.phong_id); if (check == null) { db.MKV9998.Add(values); try { db.SaveChanges(); rel.set("OK", values, "OK"); } catch { rel.set("ERR", values, "NG"); } } rel.set("ERR", values, "Đã có"); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage Update([FromBody] MKV9999 value) { using (DB db = new DB()) { result <MKV9999> rel = new result <MKV9999>(); var check = db.MKV9999.SingleOrDefault(p => p.MKV9999_ID == value.MKV9999_ID); if (check != null) { check.matkhau = value.matkhau; try { db.SaveChanges(); rel.set("OK", value, "Thành công"); }catch (Exception fd) { rel.set("ERR", value, "Thất bại: " + fd.Message); } } else { rel.set("NaN", value, "Thất bại: Không có dữ liệu"); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] MKV9999 value) { result <MKV9999> rel = new result <MKV9999>(); DB db = new DB(); var kj = value; var ch = db.MKV9999.Where(p => p.manhansu == value.manhansu).FirstOrDefault(); if (ch == null) { db.MKV9999.Add(kj); try { db.SaveChanges(); rel.set("OK", kj, "Thành công"); db.MKV9984.Add(new MKV9984() { MKV9999_ID = kj.MKV9999_ID, MKV9983_ID = 2 });; db.SaveChanges(); } catch (Exception ee) { rel.set("ERR", value, ee.Message); } } else { rel.set("exist", ch, "Tài khoản này đã tồn tại, bạn hãy sử dụng chức năng Quên mật khẩu!"); } return(rel.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 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 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 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 update([FromBody] MKV8002 value) { using (DB db = new DB()) { result <MKV8002> rel = new result <MKV8002>(); var check = db.MKV8002.SingleOrDefault(p => p.MKV8002_ID == value.MKV8002_ID); if (check != null) { check.ghiChu = value.ghiChu; check.ten = value.ten; check.ip = value.ip; check.port = value.port; check.commkey = value.commkey; check.trangthai = value.trangthai; check.thutu = value.thutu; try { db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception l) { rel.set("ERR", value, "Thất bại:" + l.Message); } } return(rel.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 update([FromBody] MKV8001 value) { using (DB db = new DB()) { result <MKV8001> rel = new result <MKV8001>(); var check = db.MKV9999.Where(p => p.manhansu == value.taikhoan || p.cmtnd_so == value.cmnd).FirstOrDefault(); if (check != null) { check.matkhau = "123456"; try { db.SaveChanges(); var k = db.MKV8001.SingleOrDefault(p => p.MKV8001_ID == value.MKV8001_ID); if (k != null) { k.trangthai = true; } db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception rr) { rel.set("ERR", value, "Thất bại: " + rr.Message); } } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage update([FromBody] KTX0002 value) { using (DB db = new DB()) { result <KTX0002> rel = new result <KTX0002>(); var check = db.KTX0002.SingleOrDefault(p => p.KTX0002_ID == value.KTX0002_ID); if (check != null) { check.ten = value.ten; check.ghichu = value.ghichu; try { db.SaveChanges(); rel.set("OK", check, "Thành công."); } catch (Exception t) { rel.set("ERR", check, "Thất bại: " + t.Message); } } else { rel.set("NaN", check, "Thất bại: Không tìm thấy bản ghi."); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage updatecomment([FromBody] RM0010 value) { using (DB db = new DB()) { result <RM0010> rel = new result <RM0010>(); var check = db.RM0010.SingleOrDefault(p => p.RM0010_ID == value.RM0010_ID); if (check != null) { check.ghichu = value.ghichu; try { db.SaveChanges(); rel.set("OK", null); } catch (Exception g) { rel.set("ERR", null, g.Message); } } else { rel.set("NaN", null); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage update([FromBody] KTX0053 value) { using (DB db = new DB()) { result <KTX0053> rel = new result <KTX0053>(); var check = db.KTX0053.SingleOrDefault(p => p.KTX0053_ID == value.KTX0053_ID); if (check != null) { check.buasang = value.buasang; check.buatoi = value.buatoi; check.buatrua = value.buatrua; check.ngay = value.ngay; try { db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception l) { rel.set("ERR", value, "Thất bại:" + l.Message); } } return(rel.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 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 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 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 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 update([FromBody] RM0001 value) { using (DB db = new DB()) { result <RM0001> rel = new result <RM0001>(); var check = db.RM0001.SingleOrDefault(p => p.RM0001_ID == value.RM0001_ID); if (check != null) { check.ghiChu = value.ghiChu; check.maCongViec = value.maCongViec; check.moTa = value.moTa; check.RM0004_ID = value.RM0004_ID; check.tenCongViec = value.tenCongViec; check.thuTu = value.thuTu; check.tinhTrang = value.tinhTrang; try { db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception l) { rel.set("ERR", value, "Thất bại:" + l.Message); } } 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 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()); }