Example #1
0
 internal static void AddProject(int tripID, int seq, string start, string end, string projectID)
 {
     using (var db = new TravelEntities())
     {
         T_ScheduleDetail detail = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID && a.Seq == seq).First();
         if (detail == null)
         {
             return;
         }
         string[]      id_type       = projectID.Split(':');
         DetailProject detailProject = new DetailProject
         {
             Start     = start,
             End       = end,
             ProjectID = Convert.ToInt16(id_type[0]),
             TypeID    = Convert.ToInt16(id_type[1]),
         };
         List <DetailProject> detailProjects;
         if (detail.ProjectList == null || detail.ProjectList.Equals(string.Empty))
         {
             detailProjects = new List <DetailProject>();
         }
         else
         {
             detailProjects = Common.AppUtils.JsonDeserialize <List <DetailProject> >(detail.ProjectList);
         }
         detailProjects.Add(detailProject);
         detail.ProjectList = Common.AppUtils.JsonSerializer(detailProjects);
         detail.Description = detail.Description;
         db.T_ScheduleDetail.Attach(detail);
         db.Entry(detail).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #2
0
 internal static void DeleteProject(int tripID, int seq, int projectSeq)
 {
     using (var db = new TravelEntities())
     {
         T_ScheduleDetail detail = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID && a.Seq == seq).First();
         if (detail == null)
         {
             return;
         }
         List <DetailProject> detailProjects;
         if (detail.ProjectList == null || detail.ProjectList.Equals(string.Empty))
         {
             return;
         }
         else
         {
             detailProjects = Common.AppUtils.JsonDeserialize <List <DetailProject> >(detail.ProjectList);
         }
         if (detailProjects.Count < projectSeq)
         {
             return;
         }
         detailProjects.RemoveAt(projectSeq);
         detail.ProjectList = Common.AppUtils.JsonSerializer(detailProjects);
         detail.Description = detail.Description;
         db.T_ScheduleDetail.Attach(detail);
         db.Entry(detail).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #3
0
        private static void AddEmptyDay(TravelEntities db, int tripID, int i)
        {
            T_ScheduleDetail detail = new T_ScheduleDetail();

            detail.ScheduleID  = tripID;
            detail.Seq         = i;
            detail.ProjectList = string.Empty;
            detail.Description = string.Empty;
            db.T_ScheduleDetail.Add(detail);
        }
Example #4
0
 internal static void EditDayDesc(int tripID, int seq, string desc)
 {
     using (var db = new TravelEntities())
     {
         T_ScheduleDetail detail = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID && a.Seq == seq).First();
         detail.Description = desc;
         detail.ProjectList = detail.ProjectList;
         db.T_ScheduleDetail.Attach(detail);
         db.Entry(detail).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #5
0
 internal static void DeleteDay(int tripID, int seq)
 {
     using (var db = new TravelEntities())
     {
         T_ScheduleDetail detail = new T_ScheduleDetail()
         {
             ScheduleID = tripID, Seq = seq
         };
         db.T_ScheduleDetail.Attach(detail);
         db.T_ScheduleDetail.Remove(detail);
         db.SaveChanges();
     }
 }
Example #6
0
 public static void AddNewDay(int tripID, string services, string desc)
 {
     if (services.Equals(string.Empty))
     {
         return;
     }
     using (var db = new TravelEntities())
     {
         var seq = db.T_ScheduleDetail.Where(a => a.ScheduleID == tripID).Select(q => q.Seq).DefaultIfEmpty();
         T_ScheduleDetail detail = new T_ScheduleDetail();
         detail.ScheduleID  = tripID;
         detail.Seq         = seq.Max() + 1;
         detail.ProjectList = services.Remove(services.Length - 1);
         detail.Description = desc;
         db.T_ScheduleDetail.Add(detail);
         db.SaveChanges();
     }
 }