Example #1
0
    //修改紀錄
    public static bool ModifyClockInOutRecord(int ciorID, int modifyID, string CIn, string COut)
    {
        bool             OK        = false;
        DBEntities       db        = new DBEntities();
        ClockInOutRecord OldRecord = db.ClockInOutRecords.SingleOrDefault(re => re.CIORID == ciorID);

        if (OldRecord != null)
        {
            ClockInOutRecord newRecord = new ClockInOutRecord()
            {
                EmployeeID   = OldRecord.EmployeeID,
                DepartmentID = OldRecord.DepartmentID,
                Date         = OldRecord.Date,
                ClockIn      = CIn,
                ClockOut     = COut,
                Passed       = "通過",
                ModifiedBy   = modifyID,
                Note1        = OldRecord.Date.Substring(0, 4),
                Note2        = OldRecord.Date.Substring(5, 2)
            };
            OldRecord.ModifiedBy      = modifyID;
            OldRecord.Passed          = "已修改";
            db.Entry(OldRecord).State = System.Data.Entity.EntityState.Modified;
            db.ClockInOutRecords.Add(newRecord);
            db.SaveChanges();
            OK = true;
        }
        return(OK);
    }
Example #2
0
    //打卡紀錄單筆審核
    public static void CIORSinglePassed(int ciorId)
    {
        DBEntities       db   = new DBEntities();
        ClockInOutRecord cior = db.ClockInOutRecords.SingleOrDefault(result => ciorId == result.CIORID);

        cior.Passed          = "通過";
        db.Entry(cior).State = System.Data.Entity.EntityState.Modified;
        db.SaveChanges();
    }
Example #3
0
    //讀取單項打卡紀錄
    public static ClockInOutRecord GetClockInOutRecordForModify(int ciorID)
    {
        DBEntities       db      = new DBEntities();
        ClockInOutRecord Record  = db.ClockInOutRecords.SingleOrDefault(re => re.CIORID == ciorID);
        Employee         e       = db.Employees.SingleOrDefault(emp => emp.EmployeeID == Record.EmployeeID);
        string           EmpName = e.LastName + e.FirstName;

        Record.Note1 = EmpName;

        return(Record);
    }
Example #4
0
    //下班打卡
    public static bool InsertClockOutRecord(ClockInOutRecord c)
    {
        bool             OK        = false;
        DBEntities       db        = new DBEntities();
        ClockInOutRecord HadRecord = db.ClockInOutRecords.SingleOrDefault(re => re.EmployeeID == c.EmployeeID && re.Date == c.Date);

        //檢查重複及有無上班紀錄
        if (HadRecord == null)
        {
            return(OK);
        }
        else if (HadRecord.ClockOut == null)
        {
            HadRecord.ClockOut        = c.ClockOut;
            db.Entry(HadRecord).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            OK = true;
        }
        return(OK);
    }
Example #5
0
    //上班打卡
    public static bool InsertClockInRecord(ClockInOutRecord c)
    {
        DBEntities       db        = new DBEntities();
        ClockInOutRecord HadRecord = db.ClockInOutRecords.SingleOrDefault(re => re.EmployeeID == c.EmployeeID && re.Date == c.Date);
        bool             OK        = false;

        //檢查重複
        if (HadRecord != null)
        {
            return(OK);
        }
        else
        {
            DBEntities db2 = new DBEntities();
            db2.ClockInOutRecords.Add(c);
            db2.SaveChanges();
            OK = true;
            return(OK);
        }
    }