コード例 #1
0
 public void Add(Backend.Employee e)
 {
     DB.Add(e);
     DAL.Employee temp = Change.EmployeeBackendToDal(e);
     emartDataContext.Employees.InsertOnSubmit(temp);
     emartDataContext.SubmitChanges();
 }
コード例 #2
0
        [Test] // #15
        public void o()
        {      //@ Add a worker and check if he existing
            Employee_Data ed = new Employee_Data();

            Backend.Employee c = new Backend.Employee("14", "adam", "bon", "Man", "3434", 20000.0, "0", "Worker");
            ed.Add(c);
            Assert.IsTrue(ed.Contains("14"));
        }
コード例 #3
0
 //adds a new employee
 public bool Add(string id, string first, string last, string gender, string departmentID, string salary, string supervisorID, string type)
 {
     if (!exist(id))
     {
         Backend.Employee e = new Backend.Employee(id, first, last, gender, departmentID, double.Parse(salary), supervisorID, type);
         itsDAL.Add(e);
         return(true);
     }
     return(false);
 }
コード例 #4
0
 //Employee
 public Backend.Employee EmployeeConverterToBackend(Employee dataContextEmployee)
 {
     Backend.Employee currentEmployee = new Backend.Employee();
     currentEmployee.DepID         = dataContextEmployee.DepID;
     currentEmployee.FirstName     = dataContextEmployee.FirstName;
     currentEmployee.LastName      = dataContextEmployee.LastName;
     currentEmployee.Gender        = (Gender)dataContextEmployee.Gender;
     currentEmployee.Id            = dataContextEmployee.Id;
     currentEmployee.Rank          = (Rank)dataContextEmployee.Rank;
     currentEmployee.Salary        = dataContextEmployee.Salary;
     currentEmployee.SupervisiorID = dataContextEmployee.SupervisiorID;
     return(currentEmployee);
 }
コード例 #5
0
        public Employee EmployeeConverterToContext(Backend.Employee currentEmployee)
        {
            Employee dataContextEmployee = new Employee();

            dataContextEmployee.DepID         = currentEmployee.DepID;
            dataContextEmployee.FirstName     = currentEmployee.FirstName;
            dataContextEmployee.LastName      = currentEmployee.LastName;
            dataContextEmployee.Gender        = (int)currentEmployee.Gender;
            dataContextEmployee.Id            = currentEmployee.Id;
            dataContextEmployee.Rank          = (int)currentEmployee.Rank;
            dataContextEmployee.Salary        = currentEmployee.Salary;
            dataContextEmployee.SupervisiorID = currentEmployee.SupervisiorID;
            return(dataContextEmployee);
        }
コード例 #6
0
ファイル: DAL_Test.cs プロジェクト: tomerkeizler/E-Mart
        public void SQLEqualEmployee()
        {
            clear();
            List <object> depList = new List <object>();

            depList.Add(new Backend.Department("Dep1", 1));
            depList.Add(new Backend.Department("Dep2", 3));
            sql.WriteToFile(depList, new Backend.Department());
            list.Add(emp1);
            sql.WriteToFile(list, emp1);
            Backend.Employee emp = sql.ReadFromFile(Elements.Employee).Cast <Backend.Employee>().ToList().ElementAt(0);
            Assert.AreEqual(emp, emp1);
            clear();
        }
コード例 #7
0
        public static DAL.Employee EmployeeBackendToDal(Backend.Employee d)
        {
            DAL.Employee temp = new DAL.Employee();

            temp.departmentID = d.departmentID.ToString();
            temp.firstName    = d.firstName.ToString();
            temp.gender       = d.gender.ToString();
            temp.ID           = d.ID.ToString();
            temp.lastName     = d.lastName.ToString();
            temp.salary       = d.salary;
            temp.supervisorID = d.supervisorID.ToString();
            temp.type         = d.type.ToString();
            temp.visa         = d.visa.ToString();
            return(temp);
        }
コード例 #8
0
        ///////////////////////////////////////////////// EMPLOYEE CONVERSION
        public static List <Backend.Employee> EmployeeDalToBackendList(List <DAL.Employee> SqlDB)
        {
            List <Backend.Employee> list = new List <Backend.Employee>();

            Backend.Employee temp;
            foreach (DAL.Employee d in SqlDB)
            {
                temp = new Backend.Employee();
                temp.departmentID = d.departmentID;
                temp.firstName    = d.firstName;
                temp.gender       = d.gender;
                temp.ID           = d.ID;
                temp.lastName     = d.lastName;
                temp.salary       = d.salary;
                temp.supervisorID = d.supervisorID;
                temp.type         = d.type;
                temp.visa         = d.visa;
                list.Add(temp);
            }
            return(list);
        }
コード例 #9
0
 public Boolean Remove(string id)
 {
     Backend.Employee temp = new Backend.Employee();
     foreach (Backend.Employee e in DB)
     {
         if (e.ID == id)
         {
             temp = e;
         }
     }
     DB.Remove(temp);
     foreach (DAL.Employee e in emartDataContext.Employees)
     {
         if (e.ID == id)
         {
             emartDataContext.Employees.DeleteOnSubmit(e);
             emartDataContext.SubmitChanges();
             return(true);
         }
     }
     return(false);
 }
コード例 #10
0
ファイル: Employee_BL.cs プロジェクト: tomerkeizler/E-Mart
        public void Remove(object e, Boolean isEdit = false)
        {
            List <Backend.Employee> Allemps  = itsDAL.ReadFromFile(Elements.Employee).Cast <Backend.Employee>().ToList();
            List <Backend.User>     Allusers = itsDAL.ReadFromFile(Elements.User).Cast <Backend.User>().ToList();
            bool   hasMoreEmployees          = false;
            object temp = new Backend.Employee();

            Backend.User tempUser = new Backend.User();
            if (!Allemps.Any())
            {
                throw new NullReferenceException("No Employees to remove!");
            }
            if (!isEdit)
            {
                //check if this employee has workers under him
                foreach (Backend.Employee emp in Allemps)
                {
                    if (((Backend.Employee)e).Id == emp.SupervisiorID)
                    {
                        throw new Exception("this employee has worker under him!");
                    }
                }
            }
            foreach (Backend.User user in Allusers)
            {
                if (user.Person.Equals(e))
                {
                    Allusers.Remove(user);
                    break;
                }
            }
            foreach (Backend.Employee emp in Allemps)
            {
                if (emp.Equals(e))
                {
                    Allemps.Remove(emp);
                    break;
                }
            }
            foreach (Backend.Employee emp in Allemps)
            {
                if (((Backend.Employee)e).SupervisiorID == emp.SupervisiorID)
                {
                    hasMoreEmployees = true;
                }
                if (((Backend.Employee)e).SupervisiorID == emp.Id)
                {
                    temp     = emp;
                    tempUser = itsDAL.UserPersonQuery(temp).ElementAtOrDefault(0);
                }
            }
            if (!hasMoreEmployees && ((Backend.Employee)temp).SupervisiorID != 0 && ((Backend.Employee)temp).SupervisiorID != -1)
            {
                ((Backend.Employee)temp).Rank = Rank.Worker;
                Backend.User newUser = new Backend.User(tempUser);
                newUser.Person = temp;
                Allusers.Remove(tempUser);
                Allusers.Add(newUser);
            }

            itsDAL.WriteToFile(Allusers.Cast <object>().ToList(), new Backend.User());
            itsDAL.WriteToFile(Allemps.Cast <object>().ToList(), (Backend.Employee)e);
        }