コード例 #1
0
ファイル: Program.cs プロジェクト: spolnik/ndatabase
        static void Main()
        {
            const string dbName = "employees.ndb";

            Console.WriteLine("Cleaning old database");
            OdbFactory.Delete(dbName);

            Console.WriteLine("Done");
            Console.WriteLine("Preparing new data set");

            var employee1 = new Employee {Name = "Tom", City = "New York City", EmploymentDate = new DateTime(2001, 1, 1), Age = 23};
            var employee2 = new Employee { Name = "John", City = "Cansas", EmploymentDate = new DateTime(2007, 1, 1), Age = 25 };
            var employee3 = new Employee { Name = "Meggy", City = "San Francisco", EmploymentDate = new DateTime(2010, 1, 1), Age = 26 };

            using (var odb = OdbFactory.Open(dbName))
            {
                odb.Store(employee1);
                odb.Store(employee2);
                odb.Store(employee3);
            }

            Console.WriteLine("Data set prepared and stored in: " + dbName);
            Console.WriteLine("Finished");

            Console.WriteLine("Press <enter> to finish the work...");
            Console.ReadLine();
        }
コード例 #2
0
        public ActionResult Employee(Employee employee)
        {
            if (ModelState.IsValid == false)
            {
                return View(employee);
            }

            using (UnitOfWork unitwork = ServiceLocator.Current.GetInstance<UnitOfWork>())
            {
                var employeeRepository = ServiceLocator.Current.GetInstance<IRepository<Employee, long?>>();
                employeeRepository.SaveOrUpdate(employee);
                unitwork.SaveChanges();
            }

            return View(employee);
        }
コード例 #3
0
        public void EmployeeIsEntitledToPaidLeaves()
        {
            // arrange and act
            var employee = new Employee {
                Benefits = new List<Benefit> {
                    new Leave {
                        Type = LeaveType.Unpaid,
                        AvailableEntitlement = 15
                    }
                }
            };

            // Assert
            var paidLeave = employee.Benefits.OfType<Leave>().FirstOrDefault(l => l.Type == LeaveType.Unpaid);
            Assert.IsNotNull(paidLeave);
            Assert.That(paidLeave.AvailableEntitlement, Is.EqualTo(15));
        }
コード例 #4
0
ファイル: DBTest.cs プロジェクト: ephebe/HRMS.Practice
 public void CreateEmployee() 
 {
     using(HRMSDbContext hrmsDbContex = new HRMSDbContext())
     {
         Employee employee = new Employee()
         {
             CName = "巴洛克",
             FirstName = "Bach",
             LastName = "Chang",
             JobTitle = "工程師",
             JobLevel = 10,
             Sex = true,
             CheckInDate = new DateTime(2015,3,1),
             Tel = "04-22113366",
             EMail = "*****@*****.**"
         };
         hrmsDbContex.Employees.Add(employee);
        // hrmsDbContex.SaveChanges();
     }
 }
コード例 #5
0
ファイル: AddEmployee.aspx.cs プロジェクト: danfma/NDB
        protected void AddButton_Click(object sender, EventArgs e)
        {
            var dbPath = HttpContext.Current.Server.MapPath(DbPath);

            var name = Name.Text;
            var city = City.Text;
            var age = Convert.ToInt32(Age.Text);
            var employmentDate = EmploymentDate.SelectedDate;

            var newEmployee = new Employee { Name = name, City = city, Age = age, EmploymentDate = employmentDate };

            using (var odb = OdbFactory.Open(dbPath))
            {
                odb.Store(newEmployee);
            }

            Name.Text = string.Empty;
            City.Text = string.Empty;
            Age.Text = "-1";
            EmploymentDate.SelectedDate = DateTime.Now;
        }
コード例 #6
0
        public void MapsPrimitiveProperties()
        {
            const string emailAddress = "*****@*****.**";
            var employee = new Employee {
                EmployeeNumber = "562342",
                Firstname = "Hillary",
                Lastname = "Gamble",
                EmailAddress = emailAddress,
                DateOfBirth = new DateTime(1980, 4, 23)
            };
            object id = SaveEmployee(employee);
            m_session.Clear();

            using (var transaction = m_session.BeginTransaction()) {
                employee = m_session.Get<Employee>(id);
                Assert.That(employee.EmployeeNumber, Is.EqualTo("562342"));
                Assert.That(employee.Firstname, Is.EqualTo("Hillary"));
                Assert.That(employee.Lastname, Is.EqualTo("Gamble"));
                Assert.That(employee.EmailAddress, Is.EqualTo(emailAddress));
                transaction.Commit();
            }
        }
コード例 #7
0
 private object SaveEmployee(
         Employee employee)
 {
     object id;
     using (var transation = m_session.BeginTransaction()) {
         id = m_session.Save(employee);
         transation.Commit();
     }
     return id;
 }
コード例 #8
0
ファイル: UnitTest.cs プロジェクト: njmube/POSMicro
 public void editAccount()
 {
     int expectedPassword = 1111;
     Employee e = new Employee();
     e.CreateAccount(1234);
     e.EditAccount(expectedPassword);
     Assert.AreEqual(expectedPassword, e.UserAccount.Password);
 }
コード例 #9
0
 private static Employee CreateEmployeeWithBenefits()
 {
     var employeeToSave = new Employee {
         EmployeeNumber = "123456",
         Benefits = new HashSet<Benefit> {
             new SkillsEnhancementAllowance {
                 Entitlement = 1000,
                 RemainingEntitlement = 250
             },
             new SeasonTicketLoan {
                 Amount = 1416,
                 MonthlyInstalment = 118,
                 StartDate = new DateTime(2014, 4, 25),
                 EndDate = new DateTime(2015, 3, 25)
             },
             new Leave {
                 AvailableEntitlement = 30,
                 RemainingEntitlement = 15,
                 Type = LeaveType.Sick
             }
         }
     };
     return employeeToSave;
 }
コード例 #10
0
 private Employee CreateEmployeeWithCommunities()
 {
     var employee = new Employee {
         EmployeeNumber = "123",
         Communities = new HashSet<Community> {
             new Community {
                 Name = "Community 1"
             },
             new Community {
                 Name = "Community 2"
             }
         }
     };
     return employee;
 }
コード例 #11
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Employees EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEmployees(Employee employee)
 {
     base.AddObject("Employees", employee);
 }
コード例 #12
0
 private static Employee CreateEmployeeWithAddress()
 {
     var employee = new Employee {
         EmployeeNumber = "123",
         ResidentialAddress = new Address {
             AddressLine1 = "3901 Locust Walk",
             City = "Philadelphia",
             Postcode = "19104",
             Country = "US"
         }
     };
     return employee;
 }
コード例 #13
0
 public bool SaveEmployee(Employee e)
 {
     return(true);
 }
コード例 #14
0
 /// <summary>
 /// Create a new Employee object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="telephoneNumber">Initial value of the TelephoneNumber property.</param>
 /// <param name="street">Initial value of the Street property.</param>
 /// <param name="postCode">Initial value of the PostCode property.</param>
 /// <param name="apartmentNumber">Initial value of the ApartmentNumber property.</param>
 /// <param name="houseNumber">Initial value of the HouseNumber property.</param>
 /// <param name="town">Initial value of the Town property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 public static Employee CreateEmployee(global::System.Int32 id, global::System.String username, global::System.String firstName, global::System.String lastName, global::System.String telephoneNumber, global::System.String street, global::System.String postCode, global::System.String apartmentNumber, global::System.String houseNumber, global::System.String town, global::System.String email)
 {
     Employee employee = new Employee();
     employee.Id = id;
     employee.Username = username;
     employee.FirstName = firstName;
     employee.LastName = lastName;
     employee.TelephoneNumber = telephoneNumber;
     employee.Street = street;
     employee.PostCode = postCode;
     employee.ApartmentNumber = apartmentNumber;
     employee.HouseNumber = houseNumber;
     employee.Town = town;
     employee.Email = email;
     return employee;
 }
コード例 #15
0
        /// <summary>
        /// Handles the Click event of the AddButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.Form.FirstNameTextBox.Text) ||
                string.IsNullOrEmpty(this.Form.HouseNumberTextBox.Text) ||
                string.IsNullOrEmpty(this.Form.LastNameTextBox.Text) ||
                string.IsNullOrEmpty(this.Form.PostCodeTextBox.Text) ||
                string.IsNullOrEmpty(this.Form.StreetTextBox.Text) ||
                string.IsNullOrEmpty(this.Form.PhoneNumberTextBox.Text) ||
                string.IsNullOrEmpty(this.Form.TownTextBox.Text) ||
                string.IsNullOrEmpty(this.Form.LoginTextBox.Text))
            {
                MessageBox.Show(
                    "Należy wpisać wymagane dane.",
                    "Błąd",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1);

                return;
            }

            if (this.IsEditForm)
            {
                var employeeToModify = DataAccess.Instance.Employees.Single(emp => emp.Id == this.ItemToEditID);

                employeeToModify.ApartmentNumber = this.Form.ApartmentNumberTextBox.Text;
                employeeToModify.Email = this.Form.EmailTextBox.Text;
                employeeToModify.FirstName = this.Form.FirstNameTextBox.Text;
                employeeToModify.HouseNumber = this.Form.HouseNumberTextBox.Text;
                employeeToModify.LastName = this.Form.LastNameTextBox.Text;
                employeeToModify.Password = this.Form.PasswordTextBox.Text;
                employeeToModify.PostCode = this.Form.PostCodeTextBox.Text;
                employeeToModify.Street = this.Form.StreetTextBox.Text;
                employeeToModify.TelephoneNumber = this.Form.PhoneNumberTextBox.Text;
                employeeToModify.Town = this.Form.TownTextBox.Text;
                employeeToModify.Username = this.Form.LoginTextBox.Text;
                employeeToModify.RoleId = (int)this.Form.RoleComboBox.SelectedValue;
            }
            else
            {
                var newEmployee = new Employee
                {
                    ApartmentNumber = this.Form.ApartmentNumberTextBox.Text,
                    Email = this.Form.EmailTextBox.Text,
                    FirstName = this.Form.FirstNameTextBox.Text,
                    HouseNumber = this.Form.HouseNumberTextBox.Text,
                    LastName = this.Form.LastNameTextBox.Text,
                    Password = this.Form.PasswordTextBox.Text,
                    PostCode = this.Form.PostCodeTextBox.Text,
                    Street = this.Form.StreetTextBox.Text,
                    TelephoneNumber = this.Form.PhoneNumberTextBox.Text,
                    Town = this.Form.TownTextBox.Text,
                    Username = this.Form.LoginTextBox.Text,
                    RoleId = (int)this.Form.RoleComboBox.SelectedValue
                };

                DataAccess.Instance.Employees.Add(newEmployee);
            }

            DataAccess.Instance.UnitOfWork.Commit();

            this.Form.Close();
        }
コード例 #16
0
ファイル: UserAccount.cs プロジェクト: njmube/POSMicro
 public UserAccount(Employee employee, int password)
 {
     this.Employee = employee;
     this.Password = password;
     this.StateId = 1;
 }
コード例 #17
0
ファイル: Restaurant.cs プロジェクト: njmube/POSMicro
 public Person AddEmployee(string firstName, string lastName, string contactNumber, string email)
 {
     Person employee = new Employee(this, firstName, lastName, contactNumber, email);
     this.People.Add(employee);
     return employee;
 }