public void Factory_Should_Return_HeavyDepartment_For_Parcel() { DepartmentFactory f = new DepartmentFactory(); var parcel = new Parcel(1, 11); Assert.Equal(typeof(HeavyDepartment), f.Get(parcel).GetType()); }
// GET: Security/Department public ActionResult Index() { var depatrments = _dbContext.Departments.ToList() .Select(g => DepartmentFactory.DepartmentEntityToViewModel(g)); return(View(depatrments)); }
private void loadList() { try { dept = DepartmentFactory.DepartmentCreateList(); cmbDepartmentModify.DataSource = dept; cmbDepartmentModify.DisplayMember = "DepartmentName"; cmbDepartmentModify.ValueMember = "DepartmentID"; job = JobFactory.JobsCreateList(); cmbJobAssignmentModify.DataSource = job; cmbJobAssignmentModify.DisplayMember = "jobTitle"; cmbJobAssignmentModify.ValueMember = "jobId"; cmbEmpStatusModify.DataSource = Enum.GetValues(typeof(EmpStatus)); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } }
public Department GetDepartmentById(int id) { MySqlConnection conn = Connect(); try { conn.Open(); string sql = "SELECT * FROM department WHERE DepartmentId = " + id; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader rdr = cmd.ExecuteReader(); /* * Create company(rdr[0 - 45]) * Create Product(rdr,45); * row[bound+1) */ Department department = DepartmentFactory.Create(rdr); return(department); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } finally { conn.Close(); } }
public void Factory_Should_Return_InsuranceDepartment_For_Parcel() { DepartmentFactory f = new DepartmentFactory(); var parcel = new Parcel(1001, 1); Assert.Equal(typeof(InsuranceDepartment), f.Get(parcel).GetType()); }
private static void Main(string[] args) { Console.Write("Choose a department [fi / hr]:"); string choice = Console.ReadLine(); DepartmentFactory factory = null; switch (choice) { case "fi": factory = new FinanceFactory(); break; case "hr": factory = new HumanResourcesFactory(); break; default: Console.WriteLine("No factory"); Environment.Exit(0); break; } var department = factory.GetDepartment(); Console.WriteLine(department.GetMessage()); }
private void RetrieveItems(int orderNumber) { try { ItemList.Clear(); ItemList = ItemFactory.RetrieveByOrderNumber(orderNumber); Employee tmpEmployee = EmployeeFactory.RetrieveByOrderNumber(orderNumber); tmpDepartment = DepartmentFactory.RetrieveByEmployeeId(tmpEmployee.Id); txtEmployee.Text = tmpEmployee.FirstName + " " + tmpEmployee.LastName; txtDepartment.Text = tmpDepartment.Title; txtSupervisor.Text = tmpDepartment.SupervisorName; Order = PurchaseOrderFactory.RetrieveByNumber(orderNumber, tmpEmployee.Id); grdItems.DataSource = ItemList; grdItems.DataBind(); txtPONumber.Text = Order.OrderNumber.ToString(); txtCreationDate.Text = Order.OrderDate.ToShortDateString(); txtStatus.Text = Order.Status; txtSubtotal.Text = String.Format("{0:C}", Order.Subtotal); txtTaxes.Text = String.Format("{0:C}", Order.Taxes); txtTotal.Text = String.Format("{0:C}", Order.Total); orderDetails.Attributes.Add("style", "display:block"); confirmation.Attributes.Add("style", "display:none"); lblMessage.Text = ""; } catch (Exception ex) { confirmation.Attributes.Add("style", "display:block"); lblMessage.Text = ex.Message + " " + ex.GetType().ToString(); } }
public void CanGetDepartmentById(int id) { DepartmentFactory departmentFactory = new DepartmentFactory(); var department = departmentFactory.get(id); Assert.NotNull(department); Assert.True(department.GetType() == typeof(Department)); Assert.True(department.DepartmentId.GetType() == typeof(int)); Assert.NotNull(department.Label); Assert.NotNull(department.DepartmentId); }
private void ddlDepartments_SelectedIndexChanged(object sender, EventArgs e) { try { txtSup.Text = DepartmentFactory.Retrieve(Convert.ToInt32(ddlDepartments.SelectedValue)).SupervisorName; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
protected void Page_Load(object sender, EventArgs e) { Login myLogin = new Login(); List <Employee> emp = EmployeeFactory.RetrieveEmployeesByID(Convert.ToInt32(Session["empID"])); List <Department> dep = DepartmentFactory.DepartmentCreateList(Convert.ToInt32(Session["empID"])); lblEmpName.InnerText = emp[0].FullName; lblDept.InnerText = dep[0].DepartmentName; lblSuper.InnerText = dep[0].Supervisor; lblDate.InnerText = DateTime.Now.ToLongDateString(); }
private void CreatePO_Load(object sender, EventArgs e) { Login myLogin = new Login(); emp = EmployeeFactory.RetrieveEmployeesByID(Main.empID); List <Department> dep = DepartmentFactory.DepartmentCreateList(Main.empID); lblEmpName.Text = emp[0].FullName; lblDept.Text = dep[0].DepartmentName; lblSuper.Text = dep[0].Supervisor; lblDate.Text = DateTime.Now.ToLongDateString(); }
private void loadList() { dept = DepartmentFactory.DepartmentCreateList(); cmbDepartment.DataSource = dept; cmbDepartment.DisplayMember = "DepartmentName"; cmbDepartment.ValueMember = "DepartmentID"; List <Job> job = JobFactory.JobsCreateList(); cmbJobAssignment.DataSource = job; cmbJobAssignment.DisplayMember = "jobTitle"; cmbJobAssignment.ValueMember = "jobId"; }
private void LoadEmployee() { string[] names = Session["EmployeeName"].ToString().Split(' '); string firstName = names[0]; string lastName = names[1]; tmpEmployee = EmployeeFactory.RetrieveByName(firstName, lastName); tmpDepartment = DepartmentFactory.RetrieveByEmployeeId(tmpEmployee.Id); txtEmployee.Text = tmpEmployee.FirstName + " " + tmpEmployee.LastName; txtDepartment.Text = tmpDepartment.Title; txtSupervisor.Text = tmpDepartment.SupervisorName; }
// Create Department public static DepartmentCreate.Response Handle(IRepository repository, DepartmentCreate.Request request) { // Validation now performed in the dispacther decorators (See AutoValidate<T> in the DomainBootstrapper class) var container = DepartmentFactory.Create(request.CommandModel); var validationDetails = repository.Save(container); var deptId = default(int?); if (!validationDetails.HasValidationIssues) { deptId = container.FindEntity <Department>().DepartmentID; } return(new DepartmentCreate.Response(validationDetails, deptId)); }
public void CanGetAllDepartments() { DepartmentFactory departmentFactory = new DepartmentFactory(); var departmentList = departmentFactory.getAll(); Assert.NotNull(departmentList); Assert.IsType <List <Department> >(departmentList); foreach (var department in departmentList) { Assert.NotNull(department); Assert.True(department.GetType() == typeof(Department)); Assert.True(department.DepartmentId.GetType() == typeof(int)); Assert.NotNull(department.Label); Assert.NotNull(department.DepartmentId); } }
public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Department department = await _dbContext.Departments.FindAsync(id); if (department == null) { return(HttpNotFound()); } DepartmentViewModel departmentViewModel = DepartmentFactory.DepartmentEntityToViewModel(department); return(PartialView("_Details", departmentViewModel)); }
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { //修改记录 string rmes_id = e.OldValues["RMES_ID"].ToString(); DepartmentEntity detEntity = DepartmentFactory.GetByKey(rmes_id); detEntity.DEPT_NAME = e.NewValues["DEPT_NAME"].ToString().Trim(); detEntity.PARENT_DEPT = e.NewValues["PARENT_DEPT"].ToString().Trim(); detEntity.DEPT_REMARK = e.NewValues["DEPT_REMARK"].ToString().Trim(); db.Update(detEntity); e.Cancel = true; ASPxGridView1.CancelEdit(); setCondition(); }
public async Task <ActionResult> Edit(DepartmentViewModel model) { if (ModelState.IsValid) { Department modeldepartment = DepartmentFactory.ViewModelToDepartmentEntity(model); _dbContext.Entry(modeldepartment).State = EntityState.Modified; await _dbContext.SaveChangesAsync(); Success("Department Updated Successfully", true); return(Json(new { success = true })); } return(PartialView("_Edit", model)); }
public static void Main(string[] args) { // LightTruck lt = new LightTruck("234JLKD234", 48000.00, 62000.00, 2019, // "Chevrolet", "Silverado", "Silver", // 10000L, 90000L, true, VehicleClassification.NEW); // if (lt.getIs4wd()) { // int gears = lt.xferCase.getNumGears(); // System.out.println("Number of Gears: " + gears); // } // lt.printVehicleType(); // Leaseable lease = new Car("52430899FD", 33000.00, 42000.00, 2019, // "Chevrolet", "Impala", "White", // VehicleClassification.NEW); // System.out.println("Number of months to lease: " + lease.getLeaseTerm()); // Instanciate new object for each Department // ServiceDepartment sd = new ServiceDepartment(); // FinanceDepartment fd = new FinanceDepartment(); // SalesDepartment sales = new SalesDepartment(); // Have Factory create new departments for us Department sd = DepartmentFactory.CreateDepartment(DepartmentNames.SERVICE); Department fd = DepartmentFactory.CreateDepartment(DepartmentNames.FINANCE); Department sales = DepartmentFactory.CreateDepartment(DepartmentNames.SALES); // Add our departments to a List IList <Department> depts = new List <Department>(); depts.Add(sd); depts.Add(fd); depts.Add(sales); Department.printIsOpen(depts, DateTime.Now); // Won't work, but example of calling on our Factory Leaseable l = LeaseVehicleFactory.getLeaseableVehicleByVin("234JK234"); }
private void loadList() { try { dept = DepartmentFactory.DepartmentCreateList(); cmbSCDepartment.DataSource = dept; cmbSCDepartment.DisplayMember = "DepartmentName"; cmbSCDepartment.ValueMember = "DepartmentID"; List <Job> job = JobFactory.JobsCreateList(); cmbSCJobAssignment.DataSource = job; cmbSCJobAssignment.DisplayMember = "jobTitle"; cmbSCJobAssignment.ValueMember = "jobId"; //cmbLenthOfDay.DataSource = Enum.GetValues(typeof(SickDayLength)); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } }
public async Task <ActionResult> Create(DepartmentViewModel model) { //Check the validity of the model if (ModelState.IsValid) { // call an instance of Driver Class var department = DepartmentFactory.ViewModelToDepartmentEntity(model); if (department != null) { _dbContext.Departments.Add(department); } await _dbContext.SaveChangesAsync(); Success("Department Creted Successfully", true); return(Json(new { success = true })); } return(PartialView("_Create", model));; }
private void setCondition() { //绑定表数据 ASPxGridView1.DataSource = DepartmentFactory.GetAll(); ASPxGridView1.DataBind(); }
/** * Purpose: Reads user input for new employee information * Return: * void */ public static void ReadInput() { Employee newEmployee = new Employee(); DepartmentFactory departmentFactory = new DepartmentFactory(); EmployeeFactory employeeFactory = new EmployeeFactory(); while (newEmployee.FirstName == null || newEmployee.FirstName.Length <= 0) { Console.WriteLine("Enter employee first name and hit return: "); newEmployee.FirstName = Console.ReadLine(); } while (newEmployee.LastName == null || newEmployee.LastName.Length <= 0) { Console.WriteLine("Enter employee last name and hit return: "); newEmployee.LastName = Console.ReadLine(); } List <Department> allDepartments = departmentFactory.getAll(); while (newEmployee.DepartmentId <= 0 || allDepartments.TrueForAll(d => d.DepartmentId != newEmployee.DepartmentId)) { Console.WriteLine("\nAll Departments:"); foreach (Department d in allDepartments) { Console.WriteLine(d.DepartmentId + ". " + d.Label); } Console.WriteLine("Enter department ID: "); try { newEmployee.DepartmentId = Convert.ToInt32(Console.ReadLine()); if (allDepartments.TrueForAll(d => d.DepartmentId != newEmployee.DepartmentId)) { Console.WriteLine("Error! Please enter a number corresponding to the employee's department ID: "); } } catch { Console.WriteLine("Error! Please enter a number corresponding to the employee's department ID: "); } } Console.WriteLine($"Is {newEmployee.FirstName} {newEmployee.LastName} an administrator? Enter YES or NO: "); string administratorInput = Console.ReadLine(); while (administratorInput.ToUpper() != "YES" && administratorInput.ToUpper() != "NO") { Console.WriteLine($"I'm sorry, I'm not sure I know what you mean by {administratorInput}. Try again. "); administratorInput = Console.ReadLine(); } if (administratorInput.ToUpper() == "YES") { newEmployee.Administrator = true; } else { newEmployee.Administrator = false; } newEmployee.save(); Employee newlySavedEmployee = employeeFactory.getAll().Last(); Console.WriteLine(newlySavedEmployee.ToString()); EmployeeFactory.Instance.ActiveEmployee = newlySavedEmployee; Console.WriteLine($"{newlySavedEmployee.FirstName} {newlySavedEmployee.LastName} added. Press any key to return to main menu."); Console.ReadLine(); }
private void btnSelect_Click(object sender, EventArgs e) { try { string Status = dgvOrders.CurrentRow.Cells["status"].Value.ToString(); selectedOrderIndex = dgvOrders.SelectedRows[0].Index; ItemList.Clear(); ItemList = ItemFactory.RetrieveByOrderNumber((int)dgvOrders.SelectedRows[0].Cells[0].Value); Employee OrderEmployee = EmployeeFactory.RetrieveByOrderNumber((int)dgvOrders.SelectedRows[0].Cells[0].Value); tmpDepartment = DepartmentFactory.RetrieveByEmployeeId(OrderEmployee.Id); txtEmployee.Text = OrderEmployee.FirstName + " " + OrderEmployee.LastName; txtDepartment.Text = tmpDepartment.Title; txtSupervisor.Text = tmpDepartment.SupervisorName; Order = PurchaseOrderFactory.RetrieveByNumber((int)dgvOrders.SelectedRows[0].Cells[0].Value, OrderEmployee.Id); dgvItems.DataSource = ItemList; foreach (Item item in ItemList) { if (!Order.Status.Equals("Closed")) { if (!item.Status.Equals("Pending")) { if (!item.Description.Equals("No longer needed")) { dgvItems.Rows[ItemList.IndexOf(item)].DefaultCellStyle.BackColor = Color.White; dgvItems.Rows[ItemList.IndexOf(item)].Cells["status"].Value = "Pending"; } else { dgvItems.Rows[ItemList.IndexOf(item)].DefaultCellStyle.BackColor = Color.Gray; } } btnAdd.Enabled = true; btnSelectItem.Enabled = true; } else { if (!item.Status.Equals("Pending")) { dgvItems.Rows[ItemList.IndexOf(item)].DefaultCellStyle.BackColor = Color.Gray; } btnSelectItem.Enabled = false; btnAdd.Enabled = false; } } txtPONumber.Text = Order.OrderNumber.ToString(); txtCreationDate.Text = Order.OrderDate.ToShortDateString(); txtStatus.Text = Order.Status; txtSubtotal.Text = String.Format("{0:C}", Order.Subtotal); txtTaxes.Text = String.Format("{0:C}", Order.Taxes); txtTotal.Text = String.Format("{0:C}", Order.Total); dgvItems.Visible = true; lblItems.Visible = true; btnSelectItem.Visible = true; ModifyItemDataGrid(); grpOrder.Visible = true; txtPONumber.Visible = true; lblPONumber.Visible = true; btnCancelItems.Visible = true; dgvOrders.Enabled = false; dgvOrders.DefaultCellStyle.BackColor = Color.Gray; dgvOrders.DefaultCellStyle.SelectionBackColor = Color.Gray; dgvOrders.DefaultCellStyle.SelectionForeColor = Color.Black; btnSelect.Enabled = false; btnCancelSearch.Enabled = false; btnAdd.Visible = true; if (!txtEmployee.Text.Equals(Settings.Default.EmployeeName)) { btnAdd.Enabled = false; } else { btnAdd.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "An error has occurred"); } }
public ActionResult SubscriptionPage(long departmentId) { var department = new DepartmentFactory().GetAppUserDepartmet(departmentId); return(View(department)); }
public ActionResult ViewDepartmentForFaculty(long id) { var departments = new DepartmentFactory().GetAllDepartmentsForAFaculty(id); return(View("FacultyDepartments", departments)); }
public void createOracletestRecords() { ModelContext.Current.config.DoCascadeDeletes = true; ModelContext.beginTrans(); ModelContext.Current.addGlobalModelValidator(typeof(Employee), typeof(EmployeeValidator)); try { Employee e = EmployeeFactory.Create(); e.PrDepartment = DepartmentFactory.Create(); e.PrDepartment.PrDepartmentName = "My New Dept"; e.PrDepartment.PrLocationId = LocationDataUtils.findList()[0].PrLocationId; e.PrFirstName = "test"; e.PrLastName = "Lastname"; e.PrSALARY = 100m; e.PrEMAIL = "*****@*****.**"; e.PrPhoneNumber = "1030045"; e.PrHireDate = new DateTime(DateTime.Now.Year, 1, 1); e.PrJobId = JobDataUtils.findList()[0].PrJobId; e.PrTrainingHistoryAdd(EmployeeTrainingHistoryFactory.Create()); EmployeeTrainingHistory emplProj = e.PrTrainingHistoryGetAt(0); emplProj.PrDateFrom = new DateTime(DateTime.Now.Year, 3, 1); emplProj.PrDateTo = new DateTime(DateTime.Now.Year, 6, 1); emplProj.PrTrainingCourse = TrainingCourseFactory.Create(); emplProj.PrTrainingCourse.PrCODE = "X1"; emplProj.PrTrainingCourse.PrDescrEn = "New Course"; emplProj.PrTrainingCourse.PrDescrGr = "Νέο"; Assert.IsTrue(e.isNew); Assert.IsTrue(e.isDirty); Assert.IsTrue(e.NeedsSave); // 3 ways to persist to database // method 1: use ModelContext.Current().save Assert.IsTrue(e.CreateDate == null, "Before save, created date is null"); Assert.IsTrue(e.UpdateDate == null, "Before save, UpdateDate is not null"); ModelContext.Current.saveModelObject(e); Assert.IsTrue(e.PrPhoneNumber == "12345XX", "12345XX value in PrPhoneNumber is Proof that validator was called"); Assert.IsTrue(e.CreateDate != null, "Before save, created date is not null"); Assert.IsTrue(e.UpdateDate != null, "Before save, UpdateDate is not null"); Assert.IsTrue(e.CreateUser != null, "Before save, CreateUser date is not null"); Assert.IsTrue(e.UpdateUser != null, "Before save, UpdateUser is not null"); //Assert.IsTrue(e.UpdateDate.Value.Ticks == e.CreateDate.Value.Ticks, "update date = create date after saving new"); Assert.IsTrue(e.UpdateUser == e.CreateUser, "update date = create date after saving new"); long x = e.PrEmployeeId; Assert.IsFalse(e.isNew, "After save, model object isNew property must return false"); Assert.IsFalse(e.isDirty, "After save to db, model object isDirty property must return false"); e = EmployeeDataUtils.findByKey(x); Assert.IsNotNull(e, "New employee not found"); Assert.IsFalse(e.isNew, "After load from db, model object isNew property returns false"); Assert.IsFalse(e.isDirty, "After load from db, model object isDirty property returns false"); Assert.AreEqual(e.PrDepartment.PrDepartmentName, "My New Dept"); Assert.AreEqual(e.PrSALARY, 100m); Assert.AreEqual(e.PrLastName, "Lastname"); Assert.AreEqual(e.PrPhoneNumber, "12345XX"); Assert.AreEqual(e.PrHireDate, new DateTime(2015, 1, 1)); Assert.AreEqual(e.PrTrainingHistory.ToList().Count, 1); Assert.AreEqual(e.PrTrainingHistoryGetAt(0).PrTrainingCourse.PrDescrEn, "New Course"); //change some values on child and parent objects e.PrTrainingHistoryGetAt(0).PrDateTo = new DateTime(DateTime.Now.Year, 6, 1); e.PrTrainingHistoryGetAt(0).PrTrainingCourse.PrDescrEn = "New Course Updated"; // here we are updating parent record of child object of employee! Assert.IsTrue(e.NeedsSave, "After changing parent or child obejcts values, e.NeedsSave must be true"); Assert.IsFalse(e.isDirty, "After changing parent or child obejcts values, e.isDirty must be false since we did not change anything on the Model Object"); // method 2: call [ModelObject]DataUtils.save EmployeeDataUtils.saveEmployee(e); //Assert.IsTrue(e.UpdateDate > e.CreateDate, "after update of record, update must be date > create date "); // note that above test cannot be sucess since save is happening too fast Assert.AreEqual(e.PrTrainingHistoryGetAt(0).PrDateTo, new DateTime(DateTime.Now.Year, 6, 1)); Assert.AreEqual(e.PrTrainingHistoryGetAt(0).PrTrainingCourse.PrDescrEn, "New Course Updated", "Expected to have parent record of child updated!"); e.PrPhoneNumber = "XXXXX"; Assert.IsTrue(e.NeedsSave, "After changing value, e.NeedsSave must be true"); Assert.IsTrue(e.isDirty, "After changing value e.isDirty must be true"); // method 3: call [ModelObject]dbMapper.save new EmployeeDBMapper().saveEmployee(e); e = EmployeeDataUtils.findByKey(x); Assert.AreEqual(e.PrPhoneNumber, "XXXXX"); Assert.AreEqual(e.PrTrainingHistoryGetAt(0).PrDateTo, new DateTime(DateTime.Now.Year, 6, 1)); Assert.AreEqual(e.PrTrainingHistoryGetAt(0).PrTrainingCourse.PrDescrEn, "New Course Updated", "Expected to have parent record of child updated!"); e.PrTrainingHistoryClear(); Assert.AreEqual(e.PrTrainingHistory.ToList().Count, 0, "Expected to have no Projects linked after call to clear"); EmployeeDataUtils.saveEmployee(e); e = EmployeeDataUtils.findByKey(x); Assert.AreEqual(e.PrTrainingHistory.ToList().Count, 0, "Expected to have no Projects linked, after reloading from db"); EmployeeDataUtils.deleteEmployee(e); e = EmployeeDataUtils.findByKey(x); Assert.IsNull(e, "New employee must have been deleted!"); // now let's test string primary key Country et = CountryFactory.Create(); et.PrCountryName = "A Description"; et.PrCountryId = "XX"; Country et1 = CountryFactory.Create(); et1.PrCountryName = "A Description 1"; et1.PrCountryId = "Y7"; Country et2 = CountryFactory.Create(); et2.PrCountryName = "A Description 2"; et2.PrCountryId = "H8"; CountryDataUtils.saveCountry(et, et1, et2); et2 = CountryDataUtils.findByKey("H8"); Assert.IsNotNull(et2, "New Country must have been created!"); et1 = CountryDataUtils.findByKey("Y7"); Assert.IsNotNull(et1, "New Country must have been created!"); } finally { ModelContext.rollbackTrans(); } }
public TestFixture() { IDepartmentFactory departmentFactory = new DepartmentFactory(); service = new ParcelService(departmentFactory); }