コード例 #1
0
        private int addTimeTrackHead(CTimeTrack tt, int userId)
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();

            if (tt.customerID == 0)
            {
                timeTrackHead tth2 = db.timeTrackHead.FirstOrDefault(x => x.timeTrackHeadID == tt.timeTrackHeadID);
                if (tth2 != null)
                {
                    tt.customerID = tth2.customerID;
                }
            }

            timeTrackHead tth = db.timeTrackHead.FirstOrDefault(x => x.customerID == tt.customerID &&
                                                                x.tDate == tt.tDate && x.userId == userId);

            if (tth != null)
            {
                return(tth.timeTrackHeadID);
            }
            int ttHeadId = db.timeTrackHead.Max(x => x.timeTrackHeadID);

            ttHeadId++;
            tth = new timeTrackHead();
            tth.timeTrackHeadID = ttHeadId;
            tth.customerID      = tt.customerID;
            tth.tDate           = tt.tDate;
            tth.userId          = userId;
            db.timeTrackHead.Add(tth);
            db.SaveChanges();
            return(tth.timeTrackHeadID);
        }
コード例 #2
0
        private void deleteTimeTrackHead(int timeTrackHeadId)
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
            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();
            }
        }