private void setUserServices() { //Set user services try { bool canCancel = false; bool canManage = this.cboSchedule.SelectedItem.ToString() == "Yard Check"; try { int id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); DispatchDataset.TrailerLogTableRow entry = (DispatchDataset.TrailerLogTableRow) this.mSchedule.TrailerLogTable.Select("ID=" + id)[0]; canCancel = entry.IsOutboundDateNull(); } catch { } this.cboSchedule.Enabled = true; this.csNew.Enabled = canManage && this.grdSchedule.Focused && (RoleServiceGateway.IsDispatchSupervisor || RoleServiceGateway.IsSafetySupervisor || RoleServiceGateway.IsWindowClerk); this.csOpen.Enabled = this.grdSchedule.Focused && this.grdSchedule.ActiveRow != null; this.csClone.Enabled = this.grdSchedule.Focused && this.grdSchedule.ActiveRow != null && (RoleServiceGateway.IsDispatchSupervisor || RoleServiceGateway.IsSafetySupervisor || RoleServiceGateway.IsWindowClerk); this.csCancel.Enabled = this.grdSchedule.Focused && canCancel && RoleServiceGateway.IsDispatchSupervisor; this.csRefresh.Enabled = true; this.csTempNew.Enabled = this.csTempOpen.Enabled = this.csTempLoad.Enabled = this.csTempRefresh.Enabled = false; this.txtSearch.Visible = this.cboSchedule.SelectedItem.ToString() == "Search"; } catch (Exception ex) { App.ReportError(ex, false, LogLevel.Warning); } finally { Application.DoEvents(); if (this.ServiceStatesChanged != null) { this.ServiceStatesChanged(this, new EventArgs()); } } }
private void OnScheduleAfterRowUpdate(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e) { // this.grdSchedule.Update(); int id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); DispatchDataset.TrailerLogTableRow entry = (DispatchDataset.TrailerLogTableRow) this.mSchedule.TrailerLogTable.Select("ID=" + id)[0]; FreightGateway.ChangeTrailerEntry(entry); Refresh(); }
private void OnItemClick(object sender, System.EventArgs e) { dlgTrailerEntry dlg = null; DispatchDataset.TrailerLogTableRow entry = null; int id = 0; try { ToolStripItem item = (ToolStripItem)sender; switch (item.Name) { case "csNew": entry = new DispatchDataset().TrailerLogTable.NewTrailerLogTableRow(); entry.ScheduleDate = DateTime.Today; entry.InboundDate = DateTime.Now; entry.IsTemplate = false; dlg = new dlgTrailerEntry(entry); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.AddTrailerEntry(entry); Refresh(); } break; case "csOpen": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); DispatchDataset.TrailerLogTableRow _entry = (DispatchDataset.TrailerLogTableRow) this.mSchedule.TrailerLogTable.Select("ID=" + id)[0]; entry = new DispatchDataset().TrailerLogTable.NewTrailerLogTableRow(); entry.ItemArray = _entry.ItemArray; dlg = new dlgTrailerEntry(entry); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.ChangeTrailerEntry(entry); Refresh(); } break; case "csClone": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); entry = (DispatchDataset.TrailerLogTableRow) this.mSchedule.TrailerLogTable.Select("ID=" + id)[0]; DispatchDataset.TrailerLogTableRow clone = new DispatchDataset().TrailerLogTable.NewTrailerLogTableRow(); entry.ScheduleDate = DateTime.Today; entry.InboundDate = DateTime.Now; if (!entry.IsInboundCarrierNull()) { clone.InboundCarrier = entry.InboundCarrier; } if (!entry.IsInboundDriverNameNull()) { clone.InboundDriverName = entry.InboundDriverName; } if (!entry.IsCommentsNull()) { clone.Comments = entry.Comments; } dlg = new dlgTrailerEntry(clone); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.AddTrailerEntry(clone); Refresh(); } break; case "csCancel": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); FreightGateway.CancelTrailerEntry(id, DateTime.Now, Environment.UserName); Refresh(); break; case "csRefresh": Refresh(); break; case "csTempNew": break; case "csTempOpen": break; case "csTempLoad": break; case "csTempRefresh": break; } } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); } finally { setUserServices(); this.Cursor = Cursors.Default; } }