private void Button1_Click(object sender, EventArgs e) { switch (comboBox2.SelectedIndex) { case 0: EventsTable eventsTable = new EventsTable(); eventsTable.Show(); break; case 1: WorkersTable workersTable = new WorkersTable(); workersTable.Show(); break; case 2: DocsTable docsTable = new DocsTable(); docsTable.Show(); break; case 3: AppointmentsTable appointmentsTable = new AppointmentsTable(); appointmentsTable.Show(); break; case 4: CompaniesTable companiesTable = new CompaniesTable(); companiesTable.Show(); break; } }
public void BindGrid(string sortExpression = "", bool isSort = false) { using (var db = new AGRODataContext(Server.MapPath("\\"))) { IQueryable <WorkerAndPlace> query = db.Workers .Join(db.Places, w => w.Place, p => p.IdP, (w, p) => new WorkerAndPlace { Worker = w, Place = p }) .Join(db.Inventory, wp => wp.Worker.Inv, i => i.IdI, (wp, i) => new WorkerAndPlace { Worker = wp.Worker, Place = wp.Place, Inventory = i }); switch (sortExpression) { case "FName": query = GetSortExpression(query, wp => wp.Worker.FName, "FName", isSort); break; case "SName": query = GetSortExpression(query, wp => wp.Worker.SName, "SName", isSort); break; case "TName": query = GetSortExpression(query, wp => wp.Worker.TName, "TName", isSort); break; case "Wage": query = GetSortExpression(query, wp => wp.Worker.Wage, "Wage", isSort); break; case "Inv": query = GetSortExpression(query, wp => wp.Inventory.IName, "Inv", isSort); break; case "Place": query = GetSortExpression(query, wp => wp.Place.Pname, "Place", isSort); break; case "Login": query = GetSortExpression(query, wp => wp.Worker.Login, "Login", isSort); break; case "Password": query = GetSortExpression(query, wp => wp.Worker.Password, "Password", isSort); break; default: query = GetSortExpression(query, wp => wp.Worker.IdW, "IdW", isSort); break; } var source = query .Select(x => new { Idw = x.Worker.IdW, FName = x.Worker.FName, SName = x.Worker.SName, TName = x.Worker.TName, Wage = x.Worker.Wage, Inv = x.Inventory.IName, InvId = x.Inventory.IdI, Place = x.Place.Pname, PlaceId = x.Place.IdP, Login = x.Worker.Login, Password = x.Worker.Password }) .ToList(); WorkersTable.DataSource = source; WorkersTable.DataBind(); } }