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; } } }
//Department public Backend.Department DepartmentConverterToBackend(Department dataContextDepartment) { Backend.Department currentDepartment = new Backend.Department(); currentDepartment.DepartmentID = dataContextDepartment.DepartmentID; currentDepartment.Name = dataContextDepartment.Name; return(currentDepartment); }
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; }
public void Add(Backend.Department d) { DB.Add(d); DAL.Department temp = Change.DepartmentBackendToDal(d); emartDataContext.Departments.InsertOnSubmit(temp); emartDataContext.SubmitChanges(); }
public static DAL.Department DepartmentBackendToDal(Backend.Department d) { DAL.Department ans = new DAL.Department(); ans.ID = d.ID; ans.name = d.name; return(ans); }
public Department DepartmentConverterToContext(Backend.Department currentDepartment) { Department dataContextDepartment = new Department(); dataContextDepartment.Name = currentDepartment.Name; dataContextDepartment.DepartmentID = currentDepartment.DepartmentID; return(dataContextDepartment); }
//adds a department public string Add(string name) { string id = generateID(); Backend.Department temp = new Backend.Department(name, id); itsDAL.Add(temp); return(id); }
[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)); }
//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); }
///////////////////////////////////////////////// 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); }
//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."); } }
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(); } } }
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); }