public JsonResult GetCustomerById(string ID) { CUSTOMER cus = new CUSTOMER(); List <CUSTOMER> lst = cus.Select(ID); return(Json(lst)); }
public JsonResult GetContact(string CUS_ID) { CUSTOMER cus = new CUSTOMER(); CONTACT vc = new CONTACT(); var lst = vc.SelectCusContact(CUS_ID); cus = cus.Select(CUS_ID).FirstOrDefault(); var result = new { CONTACTS = lst, CUSTOMER = cus }; return(Json(result)); }
public JsonResult GetInfo(string CUS_ID, string EMP_ID) { CUSTOMER cus = new CUSTOMER(); EMPLOYEE em = new EMPLOYEE(); List <string> lst = new List <string>(); //List<END_USER> end = cus.GetEndUser(CUS_ID); cus = cus.Select(CUS_ID).FirstOrDefault(); em = em.Select(EMP_ID).FirstOrDefault(); lst.Add(em.EMP_NAME); lst.Add(cus == null ? "" : cus.NAME); return(Json(lst)); }
public JsonResult GetEndUserById(string ID) { CUSTOMER cus = new CUSTOMER(); END_USER end = cus.GetEndUserById(ID); if (end == null) { end = new END_USER(); cus = cus.Select(ID).FirstOrDefault(); end.CUS_ID = ID; end.NAME = cus.NAME; end.END_USER_ID = ID; } return(Json(end)); }
public JsonResult InsertUpdateCustomer(CUSTOMER CUS, List <CONTACT> CONTACTS, int ACTION) { CUSTOMER cus = new CUSTOMER(); CONTACT con = new CONTACT(); var result = 0; if (ACTION == 1) { result = cus.Update(CUS.ID, CUS.NAME, CUS.ADDRESS, CUS.LOCATION, CUS.TEL, CUS.FAX, CUS.ESTABLE, CUS.CONTACT, CUS.CLASS, CUS.APPLICATION, CUS.PERSON, CUS.SPEC, CUS.TYPE); if (CONTACTS != null) { foreach (var contact in CONTACTS) { if (string.IsNullOrWhiteSpace(contact.ID)) { con.Insert(CUS.ID, contact.NAME, contact.DOB, contact.POSITION, contact.MOBILE, contact.EMAIL, contact.SEX); } else { con.Update(contact.ID, contact.NAME, contact.DOB, contact.POSITION, contact.MOBILE, contact.EMAIL, contact.SEX); } } } } else { CUSTOMER checkExist = cus.Select(CUS.ID).FirstOrDefault(); if (checkExist != null) { return(Json(-1)); } result = cus.Insert(CUS.ID, CUS.NAME, CUS.ADDRESS, CUS.LOCATION, CUS.TEL, CUS.FAX, CUS.ESTABLE, CUS.CONTACT, CUS.CLASS, CUS.APPLICATION, CUS.PERSON, CUS.SPEC, CUS.TYPE); if (CONTACTS != null) { foreach (var contact in CONTACTS) { con.Insert(CUS.ID, contact.NAME, contact.DOB, contact.POSITION, contact.MOBILE, contact.EMAIL, contact.SEX); } } } return(Json(result)); }
public JsonResult GetEndUser(string CUS_ID) { CUSTOMER cus = new CUSTOMER(); List <END_USER> end = cus.GetEndUser(CUS_ID); cus = cus.Select(CUS_ID).FirstOrDefault(); if (end == null || end.Count == 0) { var endUser = new END_USER(); endUser.END_USER_ID = CUS_ID; endUser.CUS_ID = CUS_ID; endUser.NAME = cus.NAME; end.Add(endUser); } var result = new { CUSTOMER = cus, END = end }; return(Json(result)); }