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 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 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 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 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 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 Sendmail([FromBody] mail value) { result <object> tel = new result <object>(); try { SmtpClient mailclient = new SmtpClient(value.server, value.port); mailclient.EnableSsl = true; mailclient.Credentials = new NetworkCredential(value.user, value.pass); MailMessage message = new MailMessage("*****@*****.**", value.to); message.Subject = value.subject; message.Body = value.bobdy; mailclient.Send(message); tel.code = "OK"; tel.mess = "Đã gửi thư thành công..."; } catch (Exception df) { tel.code = "ERR"; tel.mess = df.Message; } return(tel.ToHttpResponseMessage()); }
public HttpResponseMessage Sendmail([FromBody] mail value) { result <object> tel = new result <object>(); try { SmtpClient mailclient = new SmtpClient("smtp.gmail.com", 587); mailclient.EnableSsl = true; mailclient.Credentials = new NetworkCredential("*****@*****.**", "duytuit89!"); MailMessage message = new MailMessage("*****@*****.**", value.to); message.Subject = value.subject; message.Body = value.bobdy; mailclient.Send(message); tel.code = "OK"; tel.mess = "Đã gửi thư thành công..."; } catch (Exception df) { tel.code = "ERR"; tel.mess = df.Message; } return(tel.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 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(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 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 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 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 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] 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 Run([FromBody] y values) { using (DB db = new DB()) { result <object> rel = new result <object>(); try { var kl = db.Database.SqlQuery <IQueryable>(values.cmd).ToList(); rel.set("OK", kl, "thành công"); }catch (Exception fd) { rel.set("ERR", null, "Thất bại: " + fd.Message); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage AddAction([FromBody] MKV9981 value) { result <MKV9981> rel = new result <MKV9981>(); DB db = new DB(); db.MKV9981.Add(value); try { db.SaveChanges(); rel.set("OK", value, "Thành Công"); } catch (Exception ee) { rel.set("ERR", value, "Thất bại: " + ee.Message); } return(rel.ToHttpResponseMessage()); }
public HttpResponseMessage add([FromBody] MKV8002 values) { using (DB db = new DB()) { result <MKV8002> list = new result <MKV8002>(); db.MKV8002.Add(values); try { db.SaveChanges(); list.set("OK", values, ""); }catch (Exception ef) { list.set("ERR", values, ef.Message); } return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] KTX0023 values) { using (DB db = new DB()) { result <KTX0023> rel = new result <KTX0023>(); KTX0023 newKTX0023 = new KTX0023(); newKTX0023.MKV9999_ID = values.MKV9999_ID; newKTX0023.trakytucxa = values.trakytucxa; newKTX0023.ngaytrakytucxa = values.ngaytrakytucxa; newKTX0023.lydotra = values.lydotra; newKTX0023.somayle = values.somayle; newKTX0023.didong = values.didong; newKTX0023.chunhiemnoilam = values.chunhiemnoilam; newKTX0023.truongphongnoilam = values.truongphongnoilam; newKTX0023.banqlktx = values.banqlktx; newKTX0023.chunhiemGA = values.chunhiemGA; newKTX0023.KTX0001_ID = values.KTX0001_ID; newKTX0023.KTX0002_ID = values.KTX0002_ID; newKTX0023.KTX0003_ID = values.KTX0003_ID; newKTX0023.khoaphong = values.khoaphong; newKTX0023.sotu = values.sotu; newKTX0023.sokhoatu = values.sokhoatu; newKTX0023.ngaycohieuluc = values.ngaycohieuluc; newKTX0023.tonggiatriboithuong = values.tonggiatriboithuong; newKTX0023.bqlhoten = values.bqlhoten; newKTX0023.bqlkynhan = values.bqlkynhan; newKTX0023.nldhoten = values.nldhoten; newKTX0023.nldkynhan = values.nldkynhan; newKTX0023.trangthai = values.trangthai; newKTX0023.ngaytaodon = DateTime.Now; db.KTX0023.Add(newKTX0023); try { db.SaveChanges(); newKTX0023.MKV9999 = values.MKV9999; rel.set("OK", newKTX0023, REST.OK); } catch (Exception t) { rel.set("ERR", values, REST.ERR + t.Message); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] RM0009 value) { using (DB db = new DB()) { result <RM0009> rel = new result <RM0009>(); db.RM0009.Add(value); 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 add([FromBody] MKV8001 value) { using (DB db = new DB()) { result <MKV8001> rel = new result <MKV8001>(); db.MKV8001.Add(value); try { 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] RM0015 values) { using (DB db = new DB()) { 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; check.kqChung = values.kqChung; check.ngoaingu = values.ngoaingu; check.IQ = values.IQ; 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."); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage Delete(int id) { using (DB db = new DB()) { result <KTX0001> rel = new result <KTX0001>(); var check = db.KTX0001.SingleOrDefault(p => p.KTX0001_ID == id); if (check != null) { var check2 = db.KTX0001.FirstOrDefault(p => p.idcha == id); if (check2 == null) { var check3 = (from l in db.KTX0020 where l.KTX0001_ID == check.KTX0001_ID && l.trangthai2 != true select l).FirstOrDefault(); if (check3 == null) { try { db.KTX0001.Remove(check); 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("ERR", check, "Thất bại: Phòng này đang có người ở, hãy chuyển hết nhân viên trong phòng ra ngoài rồi thực hiện lại."); } } else { rel.set("ERR", check, "Thất bại: Tòa nhà hoặc tầng này đang chứa phòng, hãy xóa phòng hoặc tầng bên trong nó."); } } else { rel.set("ERR", check, "Thất bại: Không tồn tại bản ghi."); } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage delete([FromBody] DX0010D val) { using (QLDX_DB db = new QLDX_DB()) { 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) { db.DX0010D.Remove(check); try { db.SaveChanges(); rel.set("OK", getDX0010D(val)); } catch (Exception f) { rel.set("ERR", getDX0010D(val), f.Message); } } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage AddEPToGiuong(int id, [FromBody] KTX0020 EP) { using (var db = new DB()) { result <KTX0020> rel = new result <KTX0020>(); if (EP.KTX0002_ID == null) { var check = (from temp in db.KTX0020 where temp.KTX0020_ID == EP.KTX0020_ID select temp).FirstOrDefault(); if (check != null) { var ktx02 = db.KTX0002.SingleOrDefault(p => p.KTX0002_ID == id); if (ktx02.trangthai == false) { var ktx1 = db.KTX0001.SingleOrDefault(p => p.KTX0001_ID == ktx02.KTX0001_ID); check.khoaphong = ktx1 != null ? ktx1.makhoa : ""; check.KTX0002_ID = id; check.KTX0001_ID = ktx02.KTX0001_ID; try { db.SaveChanges(); ktx02.trangthai = true; db.SaveChanges(); check.MKV9999 = EP.MKV9999; rel.set("OK", check, "Thành công"); } catch (Exception d) { rel.set("ERR", EP, "Thất bại: " + d.Message); } } else { rel.set("ERR", EP, "Thất bại: Giường này đã có người ở."); } } } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage Delete([FromBody] DX0011 val) { using (QLDX_DB db = new QLDX_DB()) { 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("OK", null); } catch (Exception s) { rel.set("ERR", null, s.Message); } } return(rel.ToHttpResponseMessage()); } }
public HttpResponseMessage AddAction(int mkv9983_id, int mkv9981_id) { result <MKV9982> rel = new result <MKV9982>(); DB db = new DB(); MKV9982 check = (from kjkj in db.MKV9982 where kjkj.MKV9981_ID == mkv9981_id && kjkj.MKV9983_ID == mkv9983_id select kjkj).FirstOrDefault(); if (check == null) { MKV9982 p = new MKV9982() { MKV9981_ID = mkv9981_id, MKV9983_ID = mkv9983_id }; db.MKV9982.Add(p); try { db.SaveChanges(); rel.set("OK", p, "them Thành công"); } catch (Exception d) { rel.set("ERR", p, "Thất bại: " + d.Message); } } else { db.MKV9982.Remove(check); try { db.SaveChanges(); rel.set("OK", check, "xoas Thành công"); } catch (Exception d) { rel.set("ERR", check, "Thất bại: " + d.Message); } } return(rel.ToHttpResponseMessage()); }
public HttpResponseMessage add([FromBody] KTX0052 value) { using (DB db = new DB()) { result <KTX0052> rel = new result <KTX0052>(); var check = db.KTX0052.Where(p => p.User_ID == value.User_ID || p.manhansu == value.manhansu).FirstOrDefault(); if (check == null) { try { db.KTX0052.Add(value); db.SaveChanges(); rel.set("OK", value); } catch { rel.set("ERR", null); } } else { rel.set("ESIXT", null); } return(rel.ToHttpResponseMessage()); } }