private void OnScheduleAfterRowUpdate(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e) { // try { this.grdSchedule.Update(); int id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); DispatchDataset.LoadTenderLogTableRow loadtender = (DispatchDataset.LoadTenderLogTableRow) this.mSchedule.LoadTenderLogTable.Select("ID=" + id)[0]; FreightGateway.UpdateLoadTenderEntry(loadtender); Refresh(); } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Warning); } }
private void OnItemClick(object sender, System.EventArgs e) { dlgLoadTender dlg = null; DispatchDataset.LoadTenderLogTableRow entry = null; int id = 0; try { ToolStripItem item = (ToolStripItem)sender; switch (item.Name) { case "csNew": entry = new DispatchDataset().LoadTenderLogTable.NewLoadTenderLogTableRow(); entry.ScheduleDate = DateTime.Today.AddDays(1); dlg = new dlgLoadTender(entry); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { //Validate that a similiar load tender doesn't exist //TODO: ScheduleDate, Vendor, Amount, Weight FreightGateway.CreateLoadTenderEntry(entry); } break; case "csOpen": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); DispatchDataset.LoadTenderLogTableRow _entry = (DispatchDataset.LoadTenderLogTableRow) this.mSchedule.LoadTenderLogTable.Select("ID=" + id)[0]; entry = new DispatchDataset().LoadTenderLogTable.NewLoadTenderLogTableRow(); entry.ItemArray = _entry.ItemArray; dlg = new dlgLoadTender(entry); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { FreightGateway.UpdateLoadTenderEntry(entry); Refresh(); } break; case "csClone": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); entry = (DispatchDataset.LoadTenderLogTableRow) this.mSchedule.LoadTenderLogTable.Select("ID=" + id)[0]; DispatchDataset.LoadTenderLogTableRow clone = new DispatchDataset().LoadTenderLogTable.NewLoadTenderLogTableRow(); clone.ScheduleDate = DateTime.Today.AddDays(1); break; if (!entry.IsClientNull()) { clone.Client = entry.Client; } if (!entry.IsClientNumberNull()) { clone.ClientNumber = entry.ClientNumber; } if (!entry.IsVendorNumberNull()) { clone.VendorNumber = entry.VendorNumber; } if (!entry.IsVendorNameNull()) { clone.VendorName = entry.VendorName; } if (!entry.IsVendorAddressLine1Null()) { clone.VendorAddressLine1 = entry.VendorAddressLine1; } if (!entry.IsVendorAddressLine2Null()) { clone.VendorAddressLine2 = entry.VendorAddressLine2; } if (!entry.IsVendorCityNull()) { clone.VendorCity = entry.VendorCity; } if (!entry.IsVendorStateNull()) { clone.VendorState = entry.VendorState; } if (!entry.IsVendorZipNull()) { clone.VendorZip = entry.VendorZip; } if (!entry.IsVendorZipNull()) { clone.VendorZip4 = entry.VendorZip4; } if (!entry.IsWindowOpenNull()) { clone.WindowOpen = entry.WindowOpen; } if (!entry.IsWindowCloseNull()) { clone.WindowClose = entry.WindowClose; } if (!entry.IsDescriptionNull()) { clone.Description = entry.Description; } if (!entry.IsAmountNull()) { clone.Amount = entry.Amount; } if (!entry.IsAmountTypeNull()) { clone.AmountType = entry.AmountType; } if (!entry.IsWeightNull()) { clone.Weight = entry.Weight; } if (!entry.IsCommentsNull()) { clone.Comments = entry.Comments; } dlg = new dlgLoadTender(clone); dlg.Font = this.Font; if (dlg.ShowDialog(this) == DialogResult.OK) { //TODO: ScheduleDate, Vendor, Amount, Weight //TODO FreightGateway.CreateLoadTenderEntry(entry); } break; case "csCancel": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); if (MessageBox.Show(this, "Are you sure you want to cancel load tender " + id.ToString() + "?", App.Product, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { FreightGateway.CancelLoadTenderEntry(id, DateTime.Now, Environment.UserName); Refresh(); } break; case "csTender": //Tender (attach image file) an existing load OpenFileDialog dlgOpen = new OpenFileDialog(); dlgOpen.AddExtension = true; dlgOpen.Filter = "All Files (*.*) | *.*"; dlgOpen.FilterIndex = 0; dlgOpen.Title = "Select Load Tender to Attach..."; dlgOpen.FileName = ""; if (dlgOpen.ShowDialog(this) == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; string fileName = new System.IO.FileInfo(dlgOpen.FileName).Name; FileStream fsa = null; BinaryReader reader = null; try { id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); LoadTender lt = new LoadTender(); lt.Filename = dlgOpen.SafeFileName; fsa = new FileStream(dlgOpen.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read); reader = new BinaryReader(fsa); lt.File = reader.ReadBytes((int)fsa.Length); bool tendered = FreightGateway.TenderLoadTenderEntry(id, lt); MessageBox.Show(this, "Load Tender entry " + id.ToString() + " was tendered.", App.Product, MessageBoxButtons.OK, MessageBoxIcon.Information); Refresh(); } finally { if (reader != null) { reader.Close(); } if (fsa != null) { fsa.Close(); } } } break; case "csViewTender": //Open the load tender for the selected quote int number = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["LoadTenderNumber"].Value); LoadTender loadTender = FreightGateway.GetLoadTender(number); string file = App.Config.TempFolder + loadTender.Filename; try { System.IO.File.Delete(file); } catch { } FileStream fso = null; BinaryWriter writer = null; try { fso = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write); writer = new BinaryWriter(fso); writer.Write(loadTender.File); writer.Flush(); } finally { if (writer != null) { writer.Close(); } if (fso != null) { fso.Close(); } } System.Diagnostics.Process.Start(file); break; case "csScheduleTrip": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); entry = (DispatchDataset.LoadTenderLogTableRow) this.mSchedule.LoadTenderLogTable.Select("ID=" + id)[0]; DispatchDataset.BBBScheduleTableRow trip = new DispatchDataset().BBBScheduleTable.NewBBBScheduleTableRow(); trip.Created = DateTime.Now; trip.CreateUserID = Environment.UserName; trip.ScheduleDate = entry.ScheduleDate; //trip.OriginLocationID = entry.VendorNumber; trip.Origin = entry.VendorName.Trim(); trip.OriginLocation = entry.VendorCity.Trim() + ", " + entry.VendorState.Trim(); trip.DestinationLocationID = 100000532000000053; trip.Destination = "ARGIX LOGISTICS NATIONAL"; trip.DestinationLocation = "JAMESBURG, NJ"; trip.CarrierName = "ARGIX"; trip.DriverName = ""; trip.Confirmed = false; trip.TrailerNumber = ""; trip.DropEmptyTrailerNumber = ""; trip.IsLiveUnload = !entry.IsFullTrailer; trip.Amount = entry.Amount; trip.AmountType = entry.AmountType; trip.FreightType = "PCS"; trip.TDSNumber = ""; trip.ScheduledDeparture = DateTime.MinValue.AddHours(11); trip.ScheduledArrival = DateTime.MinValue.AddHours(11); trip.Comments = entry.Comments; trip.IsTemplate = false; dlgBBBTrip dlgcif = new dlgBBBTrip(trip); dlgcif.Font = this.Font; if (dlgcif.ShowDialog(this) == DialogResult.OK) { FreightGateway.ScheduleLoadTenderEntry(id, trip); Refresh(); } break; case "csSchedulePickup": id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value); entry = (DispatchDataset.LoadTenderLogTableRow) this.mSchedule.LoadTenderLogTable.Select("ID=" + id)[0]; DispatchDataset.PickupLogTableRow request = new DispatchDataset().PickupLogTable.NewPickupLogTableRow(); request.Created = DateTime.Now; request.CreateUserID = Environment.UserName; request.ScheduleDate = entry.ScheduleDate; request.CallerName = "PCS Load Tender"; request.ClientNumber = entry.ClientNumber; request.Client = entry.Client; request.ShipperNumber = ""; //entry.VendorNumber Needs to be a Roadshow AccountID- let user select; request.Shipper = entry.VendorName; request.ShipperAddress = entry.VendorAddressLine1 + "\r\n" + entry.VendorAddressLine2 + "\r\n" + entry.VendorCity + ", " + entry.VendorState + " " + entry.VendorZip; request.ShipperPhone = entry.ContactPhone; request.WindowOpen = entry.WindowOpen; request.WindowClose = entry.WindowClose; request.Amount = entry.Amount; request.AmountType = entry.AmountType; request.FreightType = "PCS"; request.Weight = entry.Weight; request.OrderType = "R"; request.Comments = entry.Comments; request.TerminalNumber = "0001"; request.Terminal = "ARGIX LOGISTICS RIDGEFIELD"; request.IsTemplate = false; dlgPickupRequest dlgpr = new dlgPickupRequest(request); dlgpr.Font = this.Font; if (dlgpr.ShowDialog(this) == DialogResult.OK) { FreightGateway.ScheduleLoadTenderEntry(id, request); } break; case "csSearch": break; case "csRefresh": Refresh(); break; } } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); } finally { setUserServices(); this.Cursor = Cursors.Default; } }