private void dgvData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.ColumnIndex == ColumnImage.Index && e.RowIndex > -1) { AppointHistory item = bSource[e.RowIndex] as AppointHistory; if (item != null) { if (item.Expanded) { e.Value = Resources.Image.Expanded; dgvData[e.ColumnIndex, e.RowIndex].Tag = "-"; } else { e.Value = Resources.Image.Collapsed; dgvData[e.ColumnIndex, e.RowIndex].Tag = "+"; } } else { e.Value = Resources.Image.Item; dgvData[e.ColumnIndex, e.RowIndex].Tag = "."; } } }
private void FillDataTable(DataTable dataTable, DataGridView dgv) { foreach (DataGridViewRow row in dgv.Rows) { DataRow dataRow = dataTable.NewRow(); foreach (DataGridViewColumn column in dgv.Columns) { if (column == ColumnImage) { if (bSource[row.Index] is AppointHistory) { AppointHistory value = (AppointHistory)bSource[row.Index]; dataRow[column.Name] = (value.Expanded ? "-" : "+"); } continue; } if (column.Visible) { dataRow[column.Name] = dgv[column.Name, row.Index].Value; } } dataTable.Rows.Add(dataRow); } }
public static BindingList <IAppointHistory> LoadList(EPVDatabase database, int id, DateTime dateFrom, DateTime dateTo, string vehicleNum, int unitId, string cargo) { BindingList <IAppointHistory> list = new BindingList <IAppointHistory>(); AppointHistory currentAppoint = null; QueryParameters parameters = new QueryParameters("id", id); parameters.Add("dateFrom", dateFrom); parameters.Add("dateTo", dateTo); parameters.Add("vehicleNum", vehicleNum); parameters.Add("unitId", unitId); parameters.Add("cargo", cargo); string query = DispatcherService.Resources.Doc.Appoint.LoadHistoryGroup; using (DbDataReader reader = database.ExecuteReader(query, parameters)) { while (reader.Read()) { if (currentAppoint == null || currentAppoint.Id != (int)reader["appointId"]) { currentAppoint = new AppointHistory(reader); list.Add(currentAppoint); } currentAppoint.Add(new DispatcherService.AppointStateHistory(reader)); } reader.Close(); } return(list); }
private BindingList <IAppointHistory> LoadData(EPVDatabase dbase, bool grouped, DateTime dateFrom, DateTime dateTo, string vehicleNum, int unitId, string cargo) { if (grouped) { return(AppointHistory.LoadList(dbase, 0, dateFrom, dateTo, vehicleNum, unitId, cargo)); } else { return(AppointStateHistory.LoadList(dbase, 0, dateFrom, dateTo, vehicleNum, unitId, cargo)); } }
private void bwRefresh_DoWork(object sender, DoWorkEventArgs e) { LoadingParameters parameters = (LoadingParameters)e.Argument; LoadingResult result = new LoadingResult() { AppointHistory = AppointHistory.LoadList(parameters.Database, parameters.AppointId), AppointLog = AppointLog.LoadList(parameters.Database, parameters.AppointId) }; e.Result = result; }
private void bwRefresh_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { LoadingResult result = (LoadingResult)e.Result; AppointHistory appointHistory = result.AppointHistory; bsAppointHistory.DataSource = appointHistory; lblVehicle.Text = appointHistory.Vehicle; lblDriverName.Text = appointHistory.Driver; lblDriverPhone.Text = appointHistory.DriverPhone; lblCargo.Text = appointHistory.Cargo; lblWhereTo.Text = appointHistory.WhereTo; bsLog.DataSource = result.AppointLog; timerLoading.Stop(); pbarLoading.Height = 0; }
private void dgvData_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == ColumnImage.Index) { AppointHistory item = bSource[e.RowIndex] as AppointHistory; if (item != null) { if (item.Expanded) { item.Collapse(bSource); } else { item.Expand(bSource); } } dgvData.Refresh(); } }