public void LeftWithExplicitParen() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); EmployeeQuery eq = new EmployeeQuery("eq"); CustomerQuery cq = new CustomerQuery("cq"); eq.Select(eq.EmployeeID, eq.LastName, cq.CustomerName); eq.LeftJoin(cq).On(eq.EmployeeID == cq.StaffAssigned); eq.Where(eq.Age == 20); eq.Where(new esComparison(esParenthesis.Open)); eq.es.DefaultConjunction = esConjunction.Or; for (int i = 0; i < 4; i++) { eq.Where( eq.Supervisor == i & eq.EmployeeID == i + 1); } eq.Where(new esComparison(esParenthesis.Close)); Assert.IsTrue(collection.Load(eq)); Assert.AreEqual(5, collection.Count); }
public void JoinFourTablesInnerLeft() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); switch (collection.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.MSAccessProvider": Assert.Ignore("Not supported."); break; default: EmployeeQuery emp = new EmployeeQuery("e"); EmployeeTerritoryQuery empTerr = new EmployeeTerritoryQuery("et"); TerritoryQuery terr = new TerritoryQuery("t"); TerritoryExQuery terrEx = new TerritoryExQuery("tx"); emp.Select(emp.FirstName, emp.LastName, terr.Description.As("Territory"), terrEx.Notes); emp.LeftJoin(empTerr).On(emp.EmployeeID == empTerr.EmpID); emp.InnerJoin(terr).On(empTerr.TerrID == terr.TerritoryID); emp.LeftJoin(terrEx).On(terr.TerritoryID == terrEx.TerritoryID); Assert.IsTrue(collection.Load(emp)); Assert.AreEqual(8, collection.Count); break; } }
public void CrossDbJoin() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); switch (collection.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.SqlClientProvider": // AggregateDb AggregateTestQuery aq = new AggregateTestQuery("a"); // ForeignKeyTest EmployeeQuery eq = new EmployeeQuery("e"); eq.Select(eq.LastName, eq.FirstName, aq.Age); eq.LeftJoin(aq).On( eq.LastName == aq.LastName & eq.FirstName == aq.FirstName); eq.OrderBy(eq.LastName.Ascending, eq.FirstName.Ascending); Assert.IsTrue(collection.Load(eq)); Assert.AreEqual(22, collection[2].GetColumn("Age")); break; default: Assert.Ignore("SQL Server only"); break; } }
public void RightWithWhereIn() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); switch (collection.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.SQLiteProvider": Assert.Ignore("RIGHT JOIN not supported."); break; default: List <string> custList = new List <string>(); custList.Add("01001"); custList.Add("40000"); custList.Add("XXXXX"); EmployeeQuery eq = new EmployeeQuery("eq"); CustomerQuery cq = new CustomerQuery("cq"); eq.Select(eq.EmployeeID, eq.LastName, cq.CustomerID, cq.CustomerName); eq.RightJoin(cq).On(eq.EmployeeID == cq.Manager); eq.Where(cq.CustomerID.In(custList)); EmployeeCollection coll = new EmployeeCollection(); coll.es.Connection.Name = "ForeignKeyTest"; Assert.IsTrue(coll.Load(eq)); Assert.AreEqual(14, coll.Count); break; } }
public void RightSimple() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); switch (collection.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.SQLiteProvider": Assert.Ignore("RIGHT JOIN not supported."); break; default: EmployeeQuery eq = new EmployeeQuery("eq"); CustomerQuery cq = new CustomerQuery("cq"); eq.Select(eq.EmployeeID, eq.LastName, cq.CustomerName); eq.RightJoin(cq).On(eq.EmployeeID == cq.StaffAssigned); Assert.IsTrue(collection.Load(eq)); Assert.AreEqual(56, collection.Count); break; } }
public void LeftWithContains() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); switch (collection.es.Connection.ProviderSignature.DataProviderName) { case "EntitySpaces.SqlClientProvider": string nameTerm = "acme NEAR company"; EmployeeQuery eq = new EmployeeQuery("eq"); CustomerQuery cq = new CustomerQuery("cq"); eq.Select(eq.EmployeeID, eq.LastName, cq.CustomerName); eq.LeftJoin(cq).On(eq.EmployeeID == cq.StaffAssigned); eq.Where(cq.CustomerName.Contains(nameTerm)); Assert.IsTrue(collection.Load(eq)); Assert.AreEqual(2, collection.Count); break; default: Assert.Ignore("Not supported"); break; } }
public void InnerJoinFourTables() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); EmployeeQuery emp = new EmployeeQuery("e"); EmployeeTerritoryQuery empTerr = new EmployeeTerritoryQuery("et"); TerritoryQuery terr = new TerritoryQuery("t"); TerritoryExQuery terrEx = new TerritoryExQuery("tx"); emp.Select(emp.FirstName, emp.LastName, terr.Description.As("Territory"), terrEx.Notes); emp.InnerJoin(empTerr).On(emp.EmployeeID == empTerr.EmpID); emp.InnerJoin(terr).On(terr.TerritoryID == empTerr.TerrID); emp.InnerJoin(terrEx).On(terrEx.TerritoryID == terr.TerritoryID); emp.Where(terrEx.Notes.IsNotNull()); Assert.IsTrue(collection.Load(emp)); Assert.AreEqual(2, collection.Count); string theName = collection[1].GetColumn("Territory") as string; Assert.AreEqual("North", theName); }
public static void AreNIFOk() { var employeeCollection = new EmployeeCollection() { new Employee() { NIF = "B213123123", TiendaAsociada = new Store(1) }, new Employee() { NIF = "B21348733", TiendaAsociada = new Store(1) }, }; ////Resultado no estático //foreach(var emp in employeeCollection) //{ // var res = emp.IsNIFOk(); //} //foreach (var emp in employeeCollection) //{ // var res = Employee.IsNIFOkStatic(emp.NIF); //} }
public void TwoAddStringsThenConcatenated() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); EmployeeQuery eq = new EmployeeQuery("eq"); eq.Select ( eq.EmployeeID, ( (eq.LastName.ToLower() + eq.FirstName.ToLower()).Trim() + " : " + (eq.LastName.ToUpper() + eq.FirstName.ToUpper()).Trim() ).Trim().As("SomeColumn") ); Assert.IsTrue(collection.Load(eq)); string theName = collection[0].GetColumn("SomeColumn") as string; Assert.AreEqual("smithjohn : SMITHJOHN", theName); }
private void SearchEmployee() { DAL dal = new DAL(); EmployeeCollection.Clear(); DataTable dt = dal.Read("Select * from bit_employee , bit_user_logon where bit_user_logon.account_Type='EMPLOYEE' AND bit_user_logon.account_Ref= bit_employee.employee_id and (STATUS='ACTIVE' OR STATUS IS NULL) and " + SelectedEmployeeCols + " like '%" + EmployeeSearchString + "%'"); int i = 0; int index = 0; Employee employeeFirstRecord = new Employee(); foreach (DataRow dr in dt.Rows) { index = i; if (index == 0) { employeeFirstRecord = new Employee(dr); } Employee employee = new Employee(dr); EmployeeCollection.Add(employee); i++; } SelectedEmployee = employeeFirstRecord; // System.Windows.MessageBox.Show(EmployeeCollection.Count.ToString()); // MessageBox.Show(SelectedClientCols + ClientSearchString); }
public void WhereInANDedTogetherOperator() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); EmployeeQuery eq1 = new EmployeeQuery("e1"); EmployeeQuery eq2 = new EmployeeQuery("e2"); EmployeeQuery eq3 = new EmployeeQuery("e3"); eq2.Select(eq2.EmployeeID); eq3.Select(eq3.EmployeeID); eq1.Where(eq1.EmployeeID.In(eq2) & eq1.EmployeeID.In(eq3)); Assert.IsTrue(collection.Load(eq1)); Assert.AreEqual(5, collection.Count); string lq = collection.Query.es.LastQuery; string[] one = lq.Split('1'); Assert.AreEqual(4, one.GetLength(0)); string[] two = lq.Split('2'); Assert.AreEqual(3, two.GetLength(0)); string[] three = lq.Split('3'); Assert.AreEqual(3, three.GetLength(0)); }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <EmployeeInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(EmployeeInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <EmployeeInfo>); } else { List <EmployeeInfo> list = new List <EmployeeInfo>(); EmployeeCollection collection = new EmployeeCollection(); Query qry = new Query(Employee.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (Employee employee in collection) { EmployeeInfo employeeInfo = new EmployeeInfo(); LoadFromDAL(employeeInfo, employee); list.Add(employeeInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(EmployeeInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
/// <summary> /// Get a collection of Employees. If no records to return, EmployeeCollection will be null. /// </summary> /// <returns></returns> public static EmployeeCollection GetCollection() { EmployeeCollection tempList = null; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_GetEmployee", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.HasRows) { tempList = new EmployeeCollection(); while (myReader.Read()) { tempList.Add(FillDataRecord(myReader)); } } myReader.Close(); } } } return(tempList); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <EmployeeInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <EmployeeInfo> list = new List <EmployeeInfo>(); Query q = Employee.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); EmployeeCollection collection = new EmployeeCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Employee employee in collection) { EmployeeInfo employeeInfo = new EmployeeInfo(); LoadFromDAL(employeeInfo, employee); list.Add(employeeInfo); } pRecordCount = q.GetRecordCount(); return(list); }
public void TestSerializeQuery() { EmployeeQuery query = new EmployeeQuery("e"); query.Where(query.EmployeeID.In(1, 2, 3, new List <object>() { 1, 2, 3 })); string qq = EmployeeQuery.SerializeHelper.ToXml(query); List <Type> types = new List <Type>(); types.Add(typeof(EmployeeQuery)); EmployeeQuery employeeQuery = EmployeeQuery.SerializeHelper.FromXml( qq, typeof(EmployeeQuery), types) as EmployeeQuery; EmployeeCollection c = new EmployeeCollection(); c.es.Connection.Name = "ForeignKeyTest"; c.Load(employeeQuery); Assert.IsTrue(c.Count == 3); }
public void LeftJoinFourTablesWithWhere() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); EmployeeQuery emp = new EmployeeQuery("e"); EmployeeTerritoryQuery empTerr = new EmployeeTerritoryQuery("et"); TerritoryQuery terr = new TerritoryQuery("t"); TerritoryExQuery terrEx = new TerritoryExQuery("tx"); emp .Select(emp.FirstName, emp.LastName, terr.Description.As("Territory"), terrEx.Notes) .LeftJoin(empTerr) .On(emp.EmployeeID == empTerr.EmpID) .LeftJoin(terr) .On(empTerr.TerrID == terr.TerritoryID) .LeftJoin(terrEx) .On(terr.TerritoryID == terrEx.TerritoryID) .Where(emp.FirstName.Trim().Like("J___")); Assert.IsTrue(collection.Load(emp)); Assert.AreEqual(7, collection.Count); }
public void WhereWithJoin() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); // SubQuery of Territories TerritoryQuery tq = new TerritoryQuery("t"); tq.Select(tq.TerritoryID); tq.Where(tq.Description == "North" | tq.Description == "West"); // EmployeeTerritory Query for Join EmployeeTerritoryQuery etq = new EmployeeTerritoryQuery("et"); // Employees matching those territories EmployeeQuery eq = new EmployeeQuery("e"); eq.es.Distinct = true; eq.Select(eq.EmployeeID, etq.TerrID); eq.LeftJoin(etq).On( eq.EmployeeID == etq.EmpID); eq.Where(etq.TerrID.In(tq)); eq.OrderBy(eq.EmployeeID.Ascending); Assert.IsTrue(collection.Load(eq)); Assert.AreEqual(3, collection.Count); }
public void WhereMixMultiWithParenNested() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.Name = "ForeignKeyTest"; collection.Query .Select(collection.Query.EmployeeID, collection.Query.Supervisor, collection.Query.Age) .Where(collection.Query.Age == 30) .Where(new esComparison(esParenthesis.Open)) .Where(new esComparison(esParenthesis.Open)); collection.Query.es.DefaultConjunction = esConjunction.Or; collection.Query .Where(collection.Query.EmployeeID == 1 & collection.Query.Supervisor.IsNull()) .Where(collection.Query.EmployeeID == 2 & collection.Query.Supervisor == 1) .Where(new esComparison(esParenthesis.Close)); collection.Query.es.DefaultConjunction = esConjunction.And; collection.Query.Where(new esComparison(esParenthesis.Open)); collection.Query.es.DefaultConjunction = esConjunction.Or; collection.Query .Where(collection.Query.LastName == "Smith" & collection.Query.Supervisor.IsNull()) .Where(collection.Query.LastName == "Jones" & collection.Query.Supervisor == 1); collection.Query.Where(new esComparison(esParenthesis.Close)); collection.Query.Where(new esComparison(esParenthesis.Close)); Assert.IsTrue(collection.Query.Load()); Assert.AreEqual(1, collection.Count); }
private void PopulateEmployee() { Employee emp = new Employee(); Employee selectNew = new Employee(); Cursor.Current = Cursors.WaitCursor; EmployeeCollection col = new EmployeeCollection(); try { selectNew.EmployeeID = 0; selectNew.FullName = "[Select One]"; col = emp.GetAllEmployeesCollection(); col.Insert(0, selectNew); cmbEmployee.DataSource = col; cmbEmployee.DisplayMember = "FullName"; cmbEmployee.ValueMember = "EmployeeID"; } catch (Exception ex) { MessageBox.Show(ex.Message, "User Setup", MessageBoxButtons.OK, MessageBoxIcon.Error); Cursor.Current = Cursors.Default; } finally { emp = null; } Cursor.Current = Cursors.Default; }
public Command GetCommand(string[] cmdArgs, EmployeeCollection employeeCollection, JobCollection jobCollection) { Command commandToReturn = null; object[] commandCtorObjects = new object[] { cmdArgs, employeeCollection, jobCollection }; Type[] types = Assembly .GetExecutingAssembly() .GetTypes(); foreach (var type in types) { CommandAttribute attr = type .GetCustomAttributes(false) .Select(atr => (CommandAttribute)atr) .FirstOrDefault(); if (attr != null && type.Name == cmdArgs[0]) { commandToReturn = (Command)Activator.CreateInstance(type, BindingFlags.Public | BindingFlags.Instance, null, commandCtorObjects, null); break; } } return(commandToReturn); }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { EmployeeItem item = new EmployeeItem(); item._employeeId = tbEmployeeId.Text; item._firstName = tbFirstName.Text; item._middleName = tbMiddleName.Text; item._lastName = tbLastName.Text; item._nationality = tbNationality.Text; item._eMail = tbEmail.Text; item._contactNum = tbContactNumber.Text; item._religion = tbReligion.Text; item._presentAddress = tbPresentAddress.Text; item._permanentAddress = tbPermanentAddress.Text; try { SaveEmpoyeeDetails(item); MessageBox.Show("New Employee added."); } catch (System.Exception) { MessageBox.Show("Error saving new employee."); } EmployeeCollection myEmpList = new EmployeeCollection(); myEmpList.RetreiveAllEmployee(); EmployeeManagement.mEmpTransitioner.SelectedIndex = 0; ClearInputFields(); }
public void CollectionCommitTest() { var col = new EmployeeCollection(); for (var i = 1; i <= 5; i++) { var e = CreateEmployee(); e.EmployeeNumber = i; col.Attach(e); } col.StartTrackingChanges(); var p = col.Items.First(_ => _.EmployeeNumber == Faker.RandomNumber.Next(2, 4)); Debug.WriteLine($"Employee No: {p.EmployeeNumber}"); p.StateStatus = EntityObjectState.Deleted; Assert.IsTrue(p.IsDirty, "Object Must be Dirty"); //Assert.IsTrue(col.IsDirty, "Collection must be Dirty"); col.RemoveDeletedItemsAndClearChanges(); Assert.IsFalse(col.IsDirty, "Collection Must NOT be dirty"); Assert.AreEqual(4, col.Items.Count()); }
public EmployeeCollection FetchAll() { EmployeeCollection coll = new EmployeeCollection(); Query qry = new Query(Employee.Schema); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public void WhereExistsFalse() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); // EmployeeID is required and will never be NULL EmployeeQuery sq = new EmployeeQuery("s"); sq.es.Distinct = true; sq .Select(sq.EmployeeID) .Where(sq.EmployeeID.IsNull()); // This should produce no results as the // inner query does not exist. EmployeeQuery eq = new EmployeeQuery("e"); eq .Select(eq.EmployeeID, eq.Supervisor) .Where(eq.Exists(sq)); Assert.IsFalse(collection.Load(eq)); }
public void TestProxiesDirtyRowsOnly() { EmployeeCollection coll = new EmployeeCollection(); Employee e = coll.AddNew(); e.EmployeeID = 1; e.FirstName = "unchanged"; e.LastName = "unchanged"; e = coll.AddNew(); e.EmployeeID = 2; e.FirstName = "unchanged"; e.LastName = "unchanged"; e = coll.AddNew(); e.EmployeeID = 3; e.FirstName = "deleted"; e.LastName = "deleted"; coll.AcceptChanges(); coll[2].MarkAsDeleted(); e = coll.AddNew(); e.EmployeeID = 4; e.FirstName = "Added"; e.LastName = "Added"; EmployeeCollectionProxyStub proxy = new EmployeeCollectionProxyStub(coll); string qq = esDataContractSerializer.ToXml(proxy); }
public void WhereExists() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); // SubQuery of Employees with a null Supervisor column. EmployeeQuery sq = new EmployeeQuery("s"); sq.es.Distinct = true; sq.Select(sq.EmployeeID); sq.Where(sq.Supervisor.IsNull()); // If even one employee has a null supervisor, // i.e., the above query has a result set, // then run a list of all employees. EmployeeQuery eq = new EmployeeQuery("e"); eq.Select(eq.EmployeeID, eq.Supervisor); eq.Where(eq.Exists(sq)); Assert.IsTrue(collection.Load(eq)); Assert.AreEqual(5, collection.Count); }
public void OnGet() { ListOfEmployee = new EmployeeCollection { EmployeeModels = Common.ListOfEmployeeModel }; }
/// <summary> /// Metoda přesune zaměstnance z EmployeeCollection do DeletedEmployeeCollection. /// </summary> /// <param name="employee">Zvolený zaměstnanec</param> public void DeleteEmployee(Employee employee) { EmployeeCollection.Remove(employee); DeletedEmployeeCollection.Add(new Employee(employee.Name, employee.Wages)); RefreshOverviewFactory(); Save(); }
public async Task <IActionResult> Index() { EmployeeCollection list = new EmployeeCollection(); using (HttpClient client = new HttpClient()) { //StringContent content = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json"); string endpoint = _apiBaseUrl;// + "/GetList"; using (var Response = await client.GetAsync(endpoint /*, content*/)) { if (Response.StatusCode == System.Net.HttpStatusCode.OK) { string apiResponse = await Response.Content.ReadAsStringAsync(); list.Employees = JsonConvert.DeserializeObject <List <EmployeeDto> >(apiResponse); return(View(list)); } else { ModelState.Clear(); ModelState.AddModelError(string.Empty, "Looks like an error on our side. Sorry!"); return(View()); } } } }
private void Export(string FileType, string FileName) { //设置回应状态 Response.Charset = "GB2312"; Response.ContentEncoding = Encoding.GetEncoding("GB2312"); Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8)); Response.ContentType = FileType; EnableViewState = false; //写入字节流 EmployeeCollection theEmployees = new EmployeeCollection(); theEmployees.DayAttendanceWeek1List = Session["TheEmployeeDayAttendanceWeek1List"] as List <Employee>; theEmployees.DayAttendanceWeek2List = Session["TheEmployeeDayAttendanceWeek2List"] as List <Employee>; theEmployees.DayAttendanceWeek3List = Session["TheEmployeeDayAttendanceWeek3List"] as List <Employee>; theEmployees.DayAttendanceWeek4List = Session["TheEmployeeDayAttendanceWeek4List"] as List <Employee>; theEmployees.DayAttendanceWeek5List = Session["TheEmployeeDayAttendanceWeek5List"] as List <Employee>; theEmployees.DayAttendanceWeek6List = Session["TheEmployeeDayAttendanceWeek6List"] as List <Employee>; theEmployees.Week1List = Session["TheEmployeeWeek1List"] as List <string>; theEmployees.Week2List = Session["TheEmployeeWeek2List"] as List <string>; theEmployees.Week3List = Session["TheEmployeeWeek3List"] as List <string>; theEmployees.Week4List = Session["TheEmployeeWeek4List"] as List <string>; theEmployees.Week5List = Session["TheEmployeeWeek5List"] as List <string>; theEmployees.Week6List = Session["TheEmployeeWeek6List"] as List <string>; StringWriter theExcel = theEmployees.ExportEmployeeDayAttendanceToExcel(); Response.Write(theExcel.ToString()); Response.End(); theExcel.Close(); }
/// <summary> /// Get collection of Games. If no records to return, GameCollection will be null. /// </summary> /// <returns></returns> public static EmployeeCollection GetCollection() { EmployeeCollection tempList = null; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_GetEmployee", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.HasRows) { tempList = new EmployeeCollection(); while (myReader.Read()) { tempList.Add(FillDataRecord(myReader)); } } myReader.Close(); } } } return tempList; }
// FillEmployeeList public static void FillEmployeeList(EmployeeCollection coll, SqlDataReader reader) { while (reader.Read()) { Employee emp = HelperMethods.GetEmployee(reader); coll.Add(emp); } }
public EmployeeCollection GetEmployees() { EmployeeCollection employees = new EmployeeCollection(); IDataReader dr = new EmployeeDataAdapter().GetEmployees(); while (dr.Read()) { employees.Add(PopulateReader(dr)); } return employees; }
private static void LessonDataAccess() { //Employee lessonEmployee = new Employee(); //lessonEmployee = EmployeeDAL.GetItem(2); //System.Console.WriteLine(lessonEmployee.GetFullName()); EmployeeCollection empCollection = new EmployeeCollection(); empCollection = EmployeeDAL.GetCollection(); foreach (EmployeeBO item in empCollection) { System.Console.WriteLine("ID: "+item.EmployeeId.ToString()+" - "+item.FirstName+" "+item.LastName); } }
static void Main(string[] args) { EmployeeCollection List = new EmployeeCollection(); List[0] = new Employee(48090, "naynish"); List[1] = new Employee(48091, "tripti"); List[2] = new Employee(48092, "purab"); foreach (Employee item in List) { Console.WriteLine(item.Id + " " + item.Name); } int i = 20; i.Display(); MyExtensionClass.Display(30); Console.ReadLine(); }
public MainWindowViewModel() { List<Employee> listEmployees = new List<Employee>(); listEmployees.Add(new Employee("Peter", 22)); listEmployees.Add(new Employee("George", 18)); listEmployees.Add(new Employee("Todor", 26)); listEmployees.Add(new Employee("Peter 1", 22)); listEmployees.Add(new Employee("George 1", 18)); listEmployees.Add(new Employee("Todor 1", 26)); listEmployees.Add(new Employee("Peter 2", 22)); listEmployees.Add(new Employee("George 2", 18)); listEmployees.Add(new Employee("Todor 2", 26)); listEmployees.Add(new Employee("Peter 3", 22)); listEmployees.Add(new Employee("George 3", 18)); listEmployees.Add(new Employee("Todor 3", 26)); this.employees = new EmployeeCollection(listEmployees); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<EmployeeInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< EmployeeInfo> list = new List< EmployeeInfo>(); Query q = Employee .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); EmployeeCollection collection=new EmployeeCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Employee employee in collection) { EmployeeInfo employeeInfo = new EmployeeInfo(); LoadFromDAL(employeeInfo, employee); list.Add(employeeInfo); } pRecordCount=q.GetRecordCount(); return list; }
public EmployeeCollection FetchByQuery(Query qry) { EmployeeCollection coll = new EmployeeCollection(); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public EmployeeCollection FetchByID(object EmployeeID) { EmployeeCollection coll = new EmployeeCollection().Where("EmployeeID", EmployeeID).Load(); return coll; }
private static void LessonCollections() { //Generic list List<Employee> myEmployeeList = new List<Employee>(); myEmployeeList.Add(new Employee { FirstName = "Jesse", LastName = "Peterson" }); myEmployeeList.Add(new Employee { FirstName = "Bob", LastName = "Thomas" }); myEmployeeList.Add(new Employee { FirstName = "Frank", LastName = "Vasco" }); myEmployeeList.Add(new Employee { FirstName = "Nick", LastName = "Johnson" }); myEmployeeList.Add(new Employee { FirstName = "Fred", LastName = "Domingo" }); //Uses the collections class EmployeeCollection myEmployeeCollection = new EmployeeCollection(); myEmployeeCollection.Add(new Employee { FirstName = "Jesse", LastName = "Peterson" }); myEmployeeCollection.Add(new Employee { FirstName = "Bob", LastName = "Thomas" }); myEmployeeCollection.Add(new Employee { FirstName = "Frank", LastName = "Vasco" }); myEmployeeCollection.Add(new Employee { FirstName = "Nick", LastName = "Johnson" }); myEmployeeCollection.Add(new Employee { FirstName = "Fred", LastName = "Domingo" }); WinningNumbersCollection myNumsCollection = new WinningNumbersCollection(); myNumsCollection.Add(new WinningNumbers { WinningNumbersId = 1, NumberValue = 7, BallTypeName = "Normal" }); myNumsCollection.Add(new WinningNumbers { WinningNumbersId = 1, NumberValue = 9, BallTypeName = "Normal" }); myNumsCollection.Add(new WinningNumbers { WinningNumbersId = 1, NumberValue = 17, BallTypeName = "Normal" }); myNumsCollection.Add(new WinningNumbers { WinningNumbersId = 1, NumberValue = 25, BallTypeName = "Normal" }); myNumsCollection.Add(new WinningNumbers { WinningNumbersId = 1, NumberValue = 35, BallTypeName = "Normal" }); myNumsCollection.Add(new WinningNumbers { WinningNumbersId = 1, NumberValue = 2, BallTypeName = "Normal" }); int i = 1; foreach (WinningNumbers item in myNumsCollection) { Console.WriteLine("Id: " + i + "\n" + "Value: " + item.NumberValue + "\n" + "Ball Type: " + item.BallTypeName); i++; } Console.Read(); }
private static void LessonCollections() { List<EmployeeBO> employeelist = new List<EmployeeBO>(); employeelist.Add(new EmployeeBO { FirstName = "Justin", LastName = "Bigham" }); employeelist.Add(new EmployeeBO { FirstName = "James", LastName = "McRoberts" }); employeelist.Add(new EmployeeBO { FirstName = "Adrian", LastName = "Ratnayake" }); foreach (EmployeeBO item in employeelist) { System.Console.WriteLine(item.FirstName); } EmployeeCollection employeecollection = new EmployeeCollection(); employeecollection.Add(new EmployeeBO { FirstName = "Justin C", LastName = "Bigham" }); employeecollection.Add(new EmployeeBO { FirstName = "James C", LastName = "McRoberts" }); employeecollection.Add(new EmployeeBO { FirstName = "Adrian C", LastName = "Ratnayake" }); foreach (EmployeeBO item in employeecollection) { System.Console.WriteLine(item.FirstName); } }
private EmployeeCollection GetEmployees() { EmployeeCollection employees = new EmployeeCollection(); employees.Add(new Employee("Margaret ", "Peacock", "Sales Representative", "USA", new Uri("../Images/Window/FirstLook/Image1.png", UriKind.Relative), "Seattle", "1020 J.George", "556-5677")); employees.Add(new Employee("Nancy ", "Davolio", "Sales Representative", "USA", new Uri("../Images/Window/FirstLook/Image4.png", UriKind.Relative), "New Jersey", "2800 Cann Ave", "421-9089")); employees.Add(new Employee("Andrew ", "Fuller", "Vice President, Sales", "USA", new Uri("../Images/Window/FirstLook/Image2.png", UriKind.Relative), "Philadelphia", "1134 Strand Ave", "334-5506")); employees.Add(new Employee("Robert ", "King", "Sales Representative", "UK", new Uri("../Images/Window/FirstLook/Image5.png", UriKind.Relative), "Phillipsburg", "2992 Johnston St", "541-2288")); employees.Add(new Employee("Dan ", "Brinke", "Sales Representative", "USA", new Uri("../Images/Window/FirstLook/Image6.png", UriKind.Relative), "New York", "54 Martin K. Ave", "262-6564")); employees.Add(new Employee("Steven ", "Buchanan", "Sales Representative", "UK", new Uri("../Images/Window/FirstLook/Image7.png", UriKind.Relative), "Ashville", "44 N West Murray", "322-3938")); employees.Add(new Employee("Janet ", "Levering", "Sales Representative", "USA", new Uri("../Images/Window/FirstLook/Image8.png", UriKind.Relative), "Jersey Shore", "445 North Ct.", "116-1918")); return employees; }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<EmployeeInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(EmployeeInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< EmployeeInfo>; } else { List< EmployeeInfo> list =new List< EmployeeInfo>(); EmployeeCollection collection=new EmployeeCollection(); Query qry = new Query(Employee.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(Employee employee in collection) { EmployeeInfo employeeInfo= new EmployeeInfo(); LoadFromDAL(employeeInfo,employee); list.Add(employeeInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(EmployeeInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< EmployeeInfo> pList, EmployeeCollection pCollection) { foreach (Employee employee in pCollection) { EmployeeInfo employeeInfo = new EmployeeInfo(); LoadFromDAL(employeeInfo, employee ); pList.Add(employeeInfo); } }
private EmployeeCollection GetLocalCollection(ParameterCollection ParameterCollection, ObjectPropertyDictionary PropertyValues, string StoredProcName) { List<Object> objGenericList = DataHelper.GetList<Employee>(ParameterCollection, PropertyValues, StoredProcName, base.GetConnectionString()); EmployeeCollection objCollection = new EmployeeCollection(); foreach (Object item in objGenericList) { Employee objItem = (Employee)item; //notes: get embedded properties this.GetEmbeddedProperties(ref objItem); objCollection.Add(objItem); } objCollection.StatusResult = new ResponseStatus("", "", ResponseStatusResult.Success); return objCollection; }
public void Collections_DeletedTest() { EmployeeCollection emps = new EmployeeCollection().Load(); Assert.IsTrue(emps.Count == 8, "Nope, it's " + emps.Count); }
public Manager() { _employee = new Employee(); _reports = new EmployeeCollection(); }