public ActionResult GetDetailCustomerByID(string Id) { using (var dbConn = ERPAPD.Helpers.OrmliteConnection.openConn()) { if (Id != null && Id != "") { // var data = dbConn.FirstOrDefault<CRM_Customer_Presenter>("Id ={0}", Id); var data = dbConn.Select <CRM_CustomerLead_Generation>("PresenterId ={0}", Id); return(Json(new { data = data, success = true }, JsonRequestBehavior.AllowGet)); } else { var data = new CRM_Customer_Presenter(); return(Json(new { data = data, success = true }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult GetDetailCustomerPresenter(string Id) { using (var dbConn = ERPAPD.Helpers.OrmliteConnection.openConn()) { if (Id != null && Id != "") { var data = dbConn.FirstOrDefault <CRM_Customer_Presenter>("Id ={0}", Id); var listCustomer = dbConn.Select <CRM_CustomerLead_Generation>("PresenterId ={0}", data.Id); return(Json(new { data = data, listCustomer = listCustomer, success = true })); } else { var data = new CRM_Customer_Presenter(); return(Json(new { data = data, success = true })); } } }
public ActionResult CustomerPresenter_Update(CRM_Customer_Presenter item) { if (asset.View) { using (var dbConn = ERPAPD.Helpers.OrmliteConnection.openConn()) { if (item != null) { try { CRM_Customer_Presenter insert = new CRM_Customer_Presenter(); insert.Id = item.Id; insert.FirstName = !String.IsNullOrEmpty(item.FirstName) ? item.FirstName : ""; insert.MiddleName = !String.IsNullOrEmpty(item.MiddleName) ? item.MiddleName : ""; insert.LastName = !String.IsNullOrEmpty(item.LastName) ? item.LastName : ""; insert.Personal = !String.IsNullOrEmpty(item.Personal) ? item.Personal : ""; insert.DayOfBirth = !String.IsNullOrEmpty(item.DayOfBirth) ? item.DayOfBirth : ""; insert.MonthOfBirth = !String.IsNullOrEmpty(item.MonthOfBirth) ? item.MonthOfBirth : ""; insert.YearOfBirth = !String.IsNullOrEmpty(item.YearOfBirth) ? item.YearOfBirth : ""; insert.Phone = !String.IsNullOrEmpty(item.Phone) ? item.Phone : ""; insert.Email = !String.IsNullOrEmpty(item.Email) ? item.Email : ""; insert.Position = !String.IsNullOrEmpty(item.Position) ? item.Position : ""; insert.Company = !String.IsNullOrEmpty(item.Company) ? item.Company : ""; //insert.CustomerID = !String.IsNullOrEmpty(item.CustomerID) ? item.CustomerID : ""; insert.Note = !String.IsNullOrEmpty(item.Note) ? item.Note : ""; dbConn.Update <CRM_Customer_Presenter>(insert); if (item.customerArray != null && item.customerArray.Length > 0) { foreach (string s in item.customerArray) { CRM_CustomerLead_Generation g = new CRM_CustomerLead_Generation(); g.CustomerID = s; g.PresenterID = insert.Id; g.RowCreatedTime = DateTime.Now; g.RowCreatedUser = currentUser.UserName; if (g != null) { dbConn.Delete <CRM_CustomerLead_Generation>(g); } dbConn.Insert <CRM_CustomerLead_Generation>(g); } } return(Json(new { success = true })); } catch (Exception ex) { return(Json(new { success = false, error = ex.Message })); } finally { dbConn.Close(); } } else { return(Json(new { success = false, error = "Bạn không có quyền" })); } } } else { return(Json(new { success = false, error = "Bạn không có quyền" })); } }