예제 #1
0
 public static string addUpdateGroup(group cp)
 {
     try
     {
         using (var db = new hoccattocEntities())
         {
             if (cp.id == 0)
             {
                 db.groups.Add(cp);
             }
             else
             {
                 db.Entry(cp).State = EntityState.Modified;
             }
             db.SaveChanges();
             if (cp.id != 0)
             {
                 db.Database.ExecuteSqlCommand("update video set group_name=N'" + cp.group_name + "' where group_id=" + cp.id);
                 db.Database.ExecuteSqlCommand("update customers set group_name=N'" + cp.group_name + "' where group_id=" + cp.id);
             }
         }
         return(string.Empty);
     }
     catch (Exception ex)
     {
         return("Thất bại: " + ex.Message);
     }
 }
예제 #2
0
 public static string deletevideo(int cpId)
 {
     try
     {
         using (var db = new hoccattocEntities())
         {
             var cp = new video()
             {
                 id = cpId
             };
             db.Entry(cp).State = EntityState.Deleted;
             db.SaveChanges();
         }
         return(string.Empty);
     }
     catch (Exception ex)
     {
         return("Thất bại: " + ex.Message);
     }
 }
예제 #3
0
 public static string addUpdateVideo(video cp)
 {
     try
     {
         using (var db = new hoccattocEntities())
         {
             if (cp.id == 0)
             {
                 db.videos.Add(cp);
             }
             else
             {
                 db.Entry(cp).State = EntityState.Modified;
             }
             db.SaveChanges();
         }
         return(cp.id.ToString());
     }
     catch (Exception ex)
     {
         return("0");
     }
 }
예제 #4
0
 public static string addUpdateLink(link cp)
 {
     try
     {
         using (var db = new hoccattocEntities())
         {
             if (cp.id == 0)
             {
                 db.links.Add(cp);
             }
             else
             {
                 db.Entry(cp).State = EntityState.Modified;
             }
             db.SaveChanges();
         }
         return(string.Empty);
     }
     catch (Exception ex)
     {
         return("Thất bại: " + ex.Message);
     }
 }