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; }
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); }
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); }
private bool UpdateEmploye(Employee employee) { string str = modSQL.UpdateEmployes(this); return CDatabase.Instance.ExecuteNonQuery(str); }
private bool DeleteEmploye(Employee employee) { string str = modSQL.DeleteEmployes(Id); return CDatabase.Instance.ExecuteNonQuery(str); }
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; }