Ejemplo n.º 1
0
 public ActionResult GetlistUser(string PKContactID)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
     {
         if (PKContactID != null && PKContactID != "")
         {
             var data = dbConn.Select <ERPAPD_Contacts>(s => s.PKContactID == int.Parse(PKContactID)).FirstOrDefault();
             return(Json(new { data = data, success = true }));
         }
         else
         {
             var data = new ERPAPD_Contacts();
             return(Json(new { data = data, success = true }));
         }
     }
 }
Ejemplo n.º 2
0
 public ActionResult GetContactByCusID(string Id)
 {
     using (var dbConn = ERPAPD.Helpers.OrmliteConnection.openConn())
     {
         if (Id != null && Id != "")
         {
             var data = dbConn.Select <ERPAPD_Contacts>("Select PKContactID, Name FROM ERPAPD_Contacts WHERE CustomerID ={0}", Id);
             return(Json(new { data = data, success = true }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             var data = new ERPAPD_Contacts();
             return(Json(new { data = data, success = true }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Ejemplo n.º 3
0
 public ActionResult CRMContactList_Update(ERPAPD_Contacts request)
 {
     using (IDbConnection dbConn = ERPAPD.Helpers.OrmliteConnection.openConn())
     {
         try
         {
             if (request.PKContactID != 0)
             {
                 var contacts = dbConn.FirstOrDefault <ERPAPD_Contacts>("PKContactID={0}", request.PKContactID);
                 contacts.FirstName       = !string.IsNullOrEmpty(request.FirstName) ? request.FirstName.Trim() : "";
                 contacts.MiddleName      = !string.IsNullOrEmpty(request.MiddleName) ? request.MiddleName.Trim() : "";
                 contacts.LastName        = !string.IsNullOrEmpty(request.LastName) ? request.LastName.Trim() : "";
                 contacts.Name            = contacts.FirstName + " " + contacts.MiddleName + " " + contacts.LastName;
                 contacts.DayOfBirth      = request.DayOfBirth != 0 ? request.DayOfBirth : 1;
                 contacts.MonthOfBirth    = request.MonthOfBirth != 0 ? request.MonthOfBirth : 1;
                 contacts.YearOfBirth     = request.YearOfBirth != 0 ? request.YearOfBirth : 1900;
                 contacts.Birthday        = DateTime.Parse(contacts.YearOfBirth + "-" + contacts.MonthOfBirth + "-" + contacts.DayOfBirth);
                 contacts.Category        = !string.IsNullOrEmpty(request.Category) ? request.Category : "";
                 contacts.Mobile          = !string.IsNullOrEmpty(request.Mobile) ? request.Mobile.Trim() : "";
                 contacts.TelephoneHome   = !string.IsNullOrEmpty(request.TelephoneHome) ? request.TelephoneHome.Trim() : "";
                 contacts.TelephoneOffice = !string.IsNullOrEmpty(request.TelephoneOffice) ? request.TelephoneOffice.Trim() : "";
                 contacts.Email           = !string.IsNullOrEmpty(request.Email) ? request.Email.Trim() : "";
                 contacts.Notes           = !string.IsNullOrEmpty(request.Notes) ? request.Notes.Trim() : "";
                 contacts.Title           = !string.IsNullOrEmpty(request.Title) ? request.Title.Trim() : "";
                 contacts.FKCustomer      = request.FKCustomer;
                 contacts.Decided         = request.Decided;
                 contacts.Sex             = request.Sex;
                 contacts.Decided         = request.Decided;
                 contacts.Status          = request.Status;
                 contacts.RowUpdatedAt    = DateTime.Now;
                 contacts.RowUpdatedUser  = currentUser.UserName;
                 contacts.IsNew           = 1;
                 dbConn.Update(contacts);
             }
             else
             {
                 ModelState.AddModelError("error", "");
                 return(Json(new { success = false }));
             }
         }
         catch (Exception e)
         {
             return(Json(new { success = false, message = e.Message }));
         }
     }
     return(Json(new { success = true }));
 }
Ejemplo n.º 4
0
 public ActionResult getSubCategory(string ParentID)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
     {
         if (ParentID != null && ParentID != "")
         {
             var data = dbConn.Select <ERPAPD_Contacts>(@"SELECT ID,[HierarchyID],Value,ParentID,[Level] FROM CRM_CategoryHierarchy
                             WHERE  ParentID='" + int.Parse(ParentID) + "'");
             return(Json(new { data = data, success = true }));
         }
         else
         {
             var data = new ERPAPD_Contacts();
             return(Json(new { data = data, success = true }));
         }
     }
 }