Exemple #1
0
        public void deleteTimeTrack(int timeTrackRowId)
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
            timeTrackRow          tr = db.timeTrackRow.FirstOrDefault(x => x.timeTrackRowID == timeTrackRowId);
            int timeTrackHeadId      = tr.timeTrackHeadID;

            db.timeTrackRow.Remove(tr);
            db.SaveChanges();
            int cnt = db.timeTrackRow.Where(x => x.timeTrackHeadID == timeTrackHeadId).Count();

            if (cnt == 0)
            {
                timeTrackHead th = db.timeTrackHead.FirstOrDefault(x => x.timeTrackHeadID == timeTrackHeadId);
                db.timeTrackHead.Remove(th);
                db.SaveChanges();
            }
        }
Exemple #2
0
        public void addTimeTrack(CTimeTrack tt, int userId)
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
            int timeTrackHeadId      = addTimeTrackHead(tt, userId);
            int ttRowId = db.timeTrackRow.Max(x => x.timeTrackRowID);

            ttRowId++;
            timeTrackRow ttr = new timeTrackRow();

            ttr.timeTrackRowID  = ttRowId;
            ttr.hours           = tt.hours;
            ttr.note            = tt.note;
            ttr.regDate         = System.DateTime.Now;
            ttr.subProjectID    = tt.subProjectID;
            ttr.timeTrackHeadID = timeTrackHeadId;
            db.timeTrackRow.Add(ttr);
            db.SaveChanges();
        }
Exemple #3
0
        public void editTimeTrack(CTimeTrack tt, int userId)
        {
            int timeTrackHeadId       = addTimeTrackHead(tt, userId);
            pdsTidRedLiveEntities db  = new pdsTidRedLiveEntities();
            timeTrackRow          ttr = db.timeTrackRow.FirstOrDefault(x => x.timeTrackRowID == tt.timeTrackRowID);

            if (ttr != null)
            {
                ttr.hours        = tt.hours;
                ttr.note         = tt.note;
                ttr.subProjectID = tt.subProjectID;
                int deleteTTH = 0;
                if (ttr.timeTrackHeadID != timeTrackHeadId)
                {
                    deleteTTH           = ttr.timeTrackHeadID;
                    ttr.timeTrackHeadID = timeTrackHeadId;
                }
                db.SaveChanges();
                if (deleteTTH != 0)
                {
                    deleteTimeTrackHead(deleteTTH);
                }
            }
        }