示例#1
0
        public Edit(BL_Manager BL_manager, Product p)
        {
            InitializeComponent();

            this.p          = p;
            this.BL_manager = BL_manager;
            nametxt.Text    = p.name;
            pricetxt.Text   = "" + p.price;
            stocktxt.Text   = "" + p.stockCount;
            List <Department> list = BL_manager.BL_department.getAllDepartments();

            departmentIDtxt.ItemsSource = list;
            for (int i = 0; i < list.Count(); i++)
            {
                Backend.Department temp = (Department)departmentIDtxt.Items[i];
                if ((temp.ID.CompareTo(p.departmentID) == 0))
                {
                    departmentIDtxt.SelectedIndex = i;
                }
            }
            typetxt.ItemsSource = Enum.GetValues(typeof(Product.Type));
            Array s = Enum.GetValues(typeof(Product.Type));

            for (int i = 0; i < s.Length; i++)
            {
                if (p.type.ToString().CompareTo(s.GetValue(i).ToString()) == 0)
                {
                    typetxt.SelectedIndex = i;
                }
            }
        }
示例#2
0
 //Department
 public Backend.Department DepartmentConverterToBackend(Department dataContextDepartment)
 {
     Backend.Department currentDepartment = new Backend.Department();
     currentDepartment.DepartmentID = dataContextDepartment.DepartmentID;
     currentDepartment.Name         = dataContextDepartment.Name;
     return(currentDepartment);
 }
示例#3
0
        public EditEmployee(BL_Manager BL_manager, Employee emp)
        {
            this.emp        = emp;
            this.BL_manager = BL_manager;
            InitializeComponent();
            firstNametxt.Text    = emp.firstName;
            lastNametxt.Text     = emp.lastName;
            supervisorIDtxt.Text = emp.supervisorID;
            if (emp.type.CompareTo("Worker") == 0)
            {
                typetxt.SelectedIndex = 0;
            }
            else
            {
                typetxt.SelectedIndex = 1;
            }
            List <Department> list = BL_manager.BL_department.getAllDepartments();

            departmentIDtxt.ItemsSource = list;
            for (int i = 0; i < list.Count(); i++)
            {
                Backend.Department temp = (Department)departmentIDtxt.Items[i];
                if ((temp.ID.CompareTo(emp.departmentID) == 0))
                {
                    departmentIDtxt.SelectedIndex = i;
                }
            }
            salarytxt.Text = "" + emp.salary;
        }
示例#4
0
 public void Add(Backend.Department d)
 {
     DB.Add(d);
     DAL.Department temp = Change.DepartmentBackendToDal(d);
     emartDataContext.Departments.InsertOnSubmit(temp);
     emartDataContext.SubmitChanges();
 }
示例#5
0
 public static DAL.Department DepartmentBackendToDal(Backend.Department d)
 {
     DAL.Department ans = new DAL.Department();
     ans.ID   = d.ID;
     ans.name = d.name;
     return(ans);
 }
示例#6
0
        public Department DepartmentConverterToContext(Backend.Department currentDepartment)
        {
            Department dataContextDepartment = new Department();

            dataContextDepartment.Name         = currentDepartment.Name;
            dataContextDepartment.DepartmentID = currentDepartment.DepartmentID;
            return(dataContextDepartment);
        }
示例#7
0
        //adds a department
        public string Add(string name)
        {
            string id = generateID();

            Backend.Department temp = new Backend.Department(name, id);
            itsDAL.Add(temp);
            return(id);
        }
示例#8
0
        [Test] // #2
        public void b()
        {      //@ Add a deparment and check if it existing
            Backend.Department dp = new Backend.Department("Games", "12341234");
            Department_Data    dt = new Department_Data();

            dt.Add(dp);
            Assert.IsTrue(dt.contains(dp.ID));
        }
示例#9
0
        //Department Name Changer
        public void DepartmentNameEdit(Backend.Department dep)
        {
            List <Backend.Department> allDepartment = ReadFromFile(Elements.Department).Cast <Backend.Department>().ToList();

            foreach (Backend.Department currentDep in allDepartment)
            {
                if (currentDep.DepartmentID == dep.DepartmentID)
                {
                    currentDep.Name = dep.Name;
                    break;
                }
            }
            WriteToFile(allDepartment.Cast <object>().ToList(), dep);
        }
示例#10
0
        /////////////////////////////////////////////////  DEPARTMENT CONVERSION
        public static List <Backend.Department> DepartmentDalToBackendList(List <DAL.Department> departmentSqlDB)
        {
            List <Backend.Department> list = new List <Backend.Department>();

            Backend.Department temp;
            foreach (DAL.Department d in departmentSqlDB)
            {
                temp      = new Backend.Department();
                temp.ID   = d.ID;
                temp.name = d.name;
                list.Add(temp);
            }
            return(list);
        }
示例#11
0
 //Department Name Changer
 public void DepartmentNameEdit(Backend.Department dep)
 {
     foreach (Department currentDep in db.Departments)
     {
         if (currentDep.DepartmentID == dep.DepartmentID)
         {
             currentDep.Name = dep.Name;
             break;
         }
     }
     try
     {
         db.SubmitChanges();
     }
     catch
     {
         throw new InvalidDataException("There is a conflict with the change. Operation aborted.");
     }
 }
示例#12
0
        public void RemoveByName(String name)
        {
            Backend.Department temp = new Backend.Department();

            foreach (Backend.Department d in DB)
            {
                if (d.name == name)
                {
                    temp = d;
                }
            }
            DB.Remove(temp);
            foreach (DAL.Department d in emartDataContext.Departments)
            {
                if (d.name == name)
                {
                    emartDataContext.Departments.DeleteOnSubmit(d);
                    emartDataContext.SubmitChanges();
                }
            }
        }
示例#13
0
 public Boolean Remove(string id)
 {
     Backend.Department temp = new Backend.Department();
     foreach (Backend.Department d in DB)
     {
         if (d.ID == id)
         {
             temp = d;
         }
     }
     DB.Remove(temp);
     foreach (DAL.Department d in emartDataContext.Departments)
     {
         if (d.ID == id)
         {
             emartDataContext.Departments.DeleteOnSubmit(d);
             emartDataContext.SubmitChanges();
             return(true);
         }
     }
     return(false);
 }