public static IQueryable <DataLayer.Laboratory_examination> GetExaminations(DataLayer.Laboratory_examination searchCrit) { DataClasses1DataContext dc = new DataClasses1DataContext(); var res = from el in dc.Laboratory_examinations where ((searchCrit.order_date.CompareTo(DateTime.MinValue) == 0) || (el.order_date.Year == searchCrit.order_date.Year) && (el.order_date.Month == searchCrit.order_date.Month) && (el.order_date.Day == searchCrit.order_date.Day)) && (String.IsNullOrEmpty(searchCrit.state) || el.state.StartsWith(searchCrit.state)) select el; return(res); }
private void labManagerShowButton_Click(object sender, EventArgs e) { //this.Controls.Add(this.labMWDataGridView); DataLayer.Laboratory_examination searchCriteria; searchCriteria = new DataLayer.Laboratory_examination(); if (labMWDataTimePickerOrderDate.Checked) { searchCriteria.order_date = labMWDataTimePickerOrderDate.Value; } else { searchCriteria.order_date = DateTime.MinValue; } searchCriteria.state = labMWComboboxState.Text; labMWDataGridView.DataSource = BizzLayer.Facades.LaboratoryFacade.GetExaminations(searchCriteria); labMWDataGridView.Columns[0].Visible = false;//id examination labMWDataGridView.Columns[1].HeaderText = "Order date"; labMWDataGridView.Columns[2].HeaderText = "Execution date"; labMWDataGridView.Columns[3].HeaderText = "Approval date"; labMWDataGridView.Columns[4].Visible = false; labMWDataGridView.Columns[5].Visible = false; labMWDataGridView.Columns[6].Visible = false; labMWDataGridView.Columns[7].HeaderText = "State"; labMWDataGridView.Columns[8].Visible = false; labMWDataGridView.Columns[9].Visible = false; labMWDataGridView.Columns[10].Visible = false; labMWDataGridView.Columns[11].Visible = false; labMWDataGridView.Columns[12].Visible = false; labMWDataGridView.Columns[13].Visible = false; labMWDataGridView.Columns[14].Visible = false; labMWDataGridView.Columns[15].Visible = false; labMWDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; //force select first row if (labMWDataGridView.Rows.Count >= 1) { labMWDataGridView.CurrentCell = labMWDataGridView.Rows[0].Cells[1]; } }