Exemplo n.º 1
0
        public static Employee CreateRand()
        {
            Random r = new Random();
            Employee empl = new Employee();
            empl.Id = Generator.GenerateID();
            empl.BirthDate = DateTime.Now;
            empl.Salary = (float)(r.NextDouble() * 100.0);
            empl.Name = "Employee " + empl.Id;

            return empl;
        }
Exemplo n.º 2
0
 public static string UpdateEmployes(Employee empl)
 {
     string query = @"UPDATE Employes SET EmployeName='{0}',BirthDate='{1}',Salary='{2}',CountryID='{3}'"
         + " WHERE Id='{4}';";
     return string.Format(query, empl.Name, empl.BirthDate.ToShortDateString(), empl.Salary, empl.CountryID, empl.Id);
 }
Exemplo n.º 3
0
 public static string InsertEmployes(Employee empl)
 {
     string query = @"INSERT INTO Employes(Id,EmployeName,BirthDate,Salary,CountryID) VALUES('{0}', '{1}', '{2}', '{3}', '{4}');";
     return string.Format(query, empl.Id, empl.Name, empl.BirthDate.ToShortDateString(), empl.Salary, empl.CountryID);
 }
Exemplo n.º 4
0
 private bool UpdateEmploye(Employee employee)
 {
     string str = modSQL.UpdateEmployes(this);
     return CDatabase.Instance.ExecuteNonQuery(str);
 }
Exemplo n.º 5
0
 private bool DeleteEmploye(Employee employee)
 {
     string str = modSQL.DeleteEmployes(Id);
     return CDatabase.Instance.ExecuteNonQuery(str);
 }
Exemplo n.º 6
0
        public IEnumerable<Employee> LoadEmployes()
        {
            var list = new List<Employee>();

            var reader = CDatabase.Instance.Execute(modSQL.SelectEmployes());

            InitDatetime();

            Employee employee = null;
            try
            {
                while (reader.Read())
                {
                    employee = new Employee();
                    employee.Id = reader.GetString(0);
                    employee.Name = reader.GetString(1);
                    employee.BirthDate = ConvertDateTime(reader);
                    employee.Salary = (float)reader.GetDouble(3);
                    employee.CountryID = reader.GetString(4);
                    employee.Status = Common.Interfaces.Status.Normal;
                    list.Add(employee);
                }
                reader.Close();
            }
            catch(Exception ex)
            {
                if (reader != null)
                    reader.Close();
            }

            //#region can remove
            //if (list.Count == 0)
            //{
            //	for (int i = 0; i < 5; i++)
            //	{
            //		list.Add(Employee.CreateRand());
            //	}
            //}
            //#endregion

            return list;
        }