private void OnDragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //Event handler for dropping onto the grid try { DataObject oData = (DataObject)e.Data; if (oData.GetDataPresent(DataFormats.StringFormat, true)) { for (int i = 0; i < this.mTemplates.ClientInboundScheduleTable.Rows.Count; i++) { if (this.mTemplates.ClientInboundScheduleTable[i].Selected == true) { DispatchDataset.ClientInboundScheduleTableRow appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow(); appointment.ItemArray = this.mTemplates.ClientInboundScheduleTable[i].ItemArray; appointment.CreateUserID = Environment.UserName; appointment.Created = DateTime.Now; switch (this.cboSchedule.SelectedItem.ToString()) { case "Today": appointment.ScheduleDate = DateTime.Today; break; case "Advanced": appointment.ScheduleDate = DateTime.Today.AddDays(1); break; } appointment.ScheduledArrival = appointment.ScheduleDate.Date + appointment.ScheduledArrival.TimeOfDay; appointment.IsTemplate = false; FreightGateway.AddClientInboundFreight(appointment); } } Refresh(); } } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Warning); } }
private void OnScheduleKeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter && this.grdSchedule.ActiveRow != null) { this.grdSchedule.ActiveRow.Update(); e.Handled = true; } else if (e.Control && e.KeyCode == Keys.C) { Cursor.Current = Cursors.WaitCursor; if (this.grdSchedule.ActiveRow != null) { int id = int.Parse(this.grdSchedule.ActiveRow.Cells["ID"].Value.ToString()); DataRow[] appointments = this.mSchedule.ClientInboundScheduleTable.Select("ID=" + id); Clipboard.SetData(DataFormats.Serializable, appointments[0].ItemArray); } } else if (e.Control && e.KeyCode == Keys.V) { if (this.cboSchedule.SelectedItem.ToString() == "Today" || this.cboSchedule.SelectedItem.ToString() == "Advanced") { Cursor.Current = Cursors.WaitCursor; object o = Clipboard.GetData(DataFormats.Serializable); if (o != null) { Cursor.Current = Cursors.WaitCursor; object[] os = (object[])o; DispatchDataset.ClientInboundScheduleTableRow appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow(); appointment.ItemArray = os; appointment.CreateUserID = Environment.UserName; appointment.Created = DateTime.Now; switch (this.cboSchedule.SelectedItem.ToString()) { case "Today": appointment.ScheduleDate = DateTime.Today; break; case "Advanced": appointment.ScheduleDate = DateTime.Today.AddDays(1); break; } appointment.ScheduledArrival = appointment.ScheduleDate.Date + appointment.ScheduledArrival.TimeOfDay; FreightGateway.AddClientInboundFreight(appointment); Refresh(); } } } else if (e.KeyCode == Keys.Delete) { if (this.csCancel.Enabled) { Cancel(); } } } catch (ArgumentException aex) { App.ReportError(new ApplicationException("Not a valid appointment.", aex), true); } catch (Exception ex) { App.ReportError(ex, false, LogLevel.Warning); } finally { Cursor.Current = Cursors.Default; } }
private void OnItemClick(object sender, System.EventArgs e) { dlgClientInboundFreight dlg = null; DispatchDataset.ClientInboundScheduleTableRow appointment = null; int id = 0; try { ToolStripItem item = (ToolStripItem)sender; switch (item.Name) { case "csNew": appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow(); switch (this.cboSchedule.SelectedItem.ToString()) { case "Today": appointment.ScheduleDate = DateTime.Today; break; case "Advanced": appointment.ScheduleDate = DateTime.Today.AddDays(1); break; } appointment.ConsigneeName = "ARGIX LOGISTICS NATIONAL"; appointment.CarrierName = "ARGIX"; appointment.IsTemplate = false; dlg = new dlgClientInboundFreight(appointment); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.AddClientInboundFreight(appointment); Refresh(); } break; case "csOpen": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); DispatchDataset.ClientInboundScheduleTableRow _freight = (DispatchDataset.ClientInboundScheduleTableRow) this.mSchedule.ClientInboundScheduleTable.Select("ID=" + id)[0]; appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow(); appointment.ItemArray = _freight.ItemArray; dlg = new dlgClientInboundFreight(appointment); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.ChangeClientInboundFreight(appointment); Refresh(); } break; case "csClone": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); appointment = (DispatchDataset.ClientInboundScheduleTableRow) this.mSchedule.ClientInboundScheduleTable.Select("ID=" + id)[0]; DispatchDataset.ClientInboundScheduleTableRow clone = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow(); switch (this.cboSchedule.SelectedItem.ToString()) { case "Today": clone.ScheduleDate = DateTime.Today; break; case "Advanced": clone.ScheduleDate = DateTime.Today.AddDays(1); break; } clone.VendorName = appointment.VendorName; clone.ConsigneeName = appointment.ConsigneeName; clone.ScheduledArrival = clone.ScheduleDate.Date + appointment.ScheduledArrival.TimeOfDay; if (!appointment.IsAmountNull()) { clone.Amount = appointment.Amount; } if (!appointment.IsAmountTypeNull()) { clone.AmountType = appointment.AmountType; } if (!appointment.IsFreightTypeNull()) { clone.FreightType = appointment.FreightType; } if (!appointment.IsCommentsNull()) { clone.Comments = appointment.Comments; } clone.IsTemplate = false; dlg = new dlgClientInboundFreight(clone); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.AddClientInboundFreight(clone); Refresh(); } break; case "csCancel": Cancel(); break; case "csRefresh": Refresh(); break; case "csTempNew": appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow(); appointment.ConsigneeName = "ARGIX LOGISTICS NATIONAL"; appointment.IsTemplate = true; dlg = new dlgClientInboundFreight(appointment, true); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.AddClientInboundFreight(appointment); Refresh(); } break; case "csTempOpen": id = Convert.ToInt32(this.grdTemplates.ActiveRow.Cells["ID"].Value); DispatchDataset.ClientInboundScheduleTableRow _template = (DispatchDataset.ClientInboundScheduleTableRow) this.mTemplates.ClientInboundScheduleTable.Select("ID=" + id)[0]; appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow(); appointment.ItemArray = _template.ItemArray; dlg = new dlgClientInboundFreight(appointment, true); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.ChangeClientInboundFreight(appointment); Refresh(); } break; case "csTempCancel": id = Convert.ToInt32(this.grdTemplates.ActiveRow.Cells["ID"].Value); if (MessageBox.Show(this, "Are you sure you want to cancel appointment template " + id.ToString() + "?", App.Product, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { FreightGateway.CancelClientInboundFreight(id, DateTime.Now, Environment.UserName); Refresh(); } break; case "csTempLoad": for (int i = 0; i < this.mTemplates.ClientInboundScheduleTable.Rows.Count; i++) { if (this.mTemplates.ClientInboundScheduleTable[i].Selected == true) { appointment = new DispatchDataset().ClientInboundScheduleTable.NewClientInboundScheduleTableRow(); appointment.ItemArray = this.mTemplates.ClientInboundScheduleTable[i].ItemArray; appointment.CreateUserID = Environment.UserName; appointment.Created = DateTime.Now; switch (this.cboSchedule.SelectedItem.ToString()) { case "Today": appointment.ScheduleDate = DateTime.Today; break; case "Advanced": appointment.ScheduleDate = DateTime.Today.AddDays(1); break; } appointment.ScheduledArrival = appointment.ScheduleDate.Date + appointment.ScheduledArrival.TimeOfDay; appointment.IsTemplate = false; FreightGateway.AddClientInboundFreight(appointment); } } Refresh(); break; case "csTempRefresh": Refresh(); break; } } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); } finally { setUserServices(); this.Cursor = Cursors.Default; } }