Beispiel #1
0
        private void AddEmployee()
        {
            //check null
            if (Name.Trim().Length == 0)
            {
                return;
            }
            if (CardID.Trim().Length < 9 || CardID.Trim().Length > 12)
            {
                return;
            }
            if (Phone.Trim().Length == 0)
            {
                return;
            }
            if (Shift.Trim().Length == 0)
            {
                return;
            }

            // create mode
            if (updateEmployee == null)
            {
                //add to database
                EmployeeModel employee = new EmployeeModel(EmployeeModel.GenerateID(), Name, Birthday, CardID, Phone, listPositionModel.List[SelectedIndexPosition].ID, StartDate, Shift);
                employee.SaveToDatabase();
            }
            else //update mode
            {
                EmployeeModel employee = new EmployeeModel(updateEmployee.ID, Name, Birthday, CardID, Phone, listPositionModel.List[SelectedIndexPosition].ID, StartDate, Shift);
                EmployeeModel.UpdateDatabase(employee);
            }

            Cancel();
        }
Beispiel #2
0
 public Card TrimValues()
 {
     CardID = CardID.Trim();
     UserID = UserID.Trim();
     Front  = Front.Trim();
     Back   = Back.Trim();
     return(this);
 }