Exemple #1
0
        private void setUserServices()
        {
            //Set user services
            try {
                bool canCancel = false;
                bool canManage = this.cboSchedule.SelectedItem.ToString() == "Today" || this.cboSchedule.SelectedItem.ToString() == "Advanced";
                bool canTender = false, canSchedule = false;
                try {
                    int id = Convert.ToInt32(this.grdSchedule.ActiveRow.Cells["ID"].Value);
                    DispatchDataset.LoadTenderLogTableRow entry = (DispatchDataset.LoadTenderLogTableRow) this.mSchedule.LoadTenderLogTable.Select("ID=" + id)[0];
                    canCancel   = true; // entry.IsPickupNumberNull();
                    canTender   = entry.IsLoadTenderNumberNull();
                    canSchedule = entry.IsPickupNumberNull();
                }
                catch { }

                this.cboSchedule.Enabled      = true;
                this.csNew.Enabled            = canManage && this.grdSchedule.Focused && (RoleServiceGateway.IsDispatchSupervisor || RoleServiceGateway.IsDispatchClerk || RoleServiceGateway.IsBBBClerk);
                this.csOpen.Enabled           = this.grdSchedule.Focused && this.grdSchedule.ActiveRow != null;
                this.csClone.Enabled          = canManage && this.grdSchedule.Focused && this.grdSchedule.ActiveRow != null && (RoleServiceGateway.IsDispatchSupervisor || RoleServiceGateway.IsDispatchClerk || RoleServiceGateway.IsBBBClerk);
                this.csSearch.Enabled         = true;
                this.csCancel.Enabled         = canManage && this.grdSchedule.Focused && canCancel && (RoleServiceGateway.IsDispatchSupervisor || RoleServiceGateway.IsDispatchClerk || RoleServiceGateway.IsBBBClerk);
                this.csTender.Enabled         = canTender;
                this.csViewTender.Enabled     = !canTender;
                this.csScheduleTrip.Enabled   = canSchedule;
                this.csSchedulePickup.Enabled = canSchedule;
                this.csRefresh.Enabled        = true;
            }
            catch (Exception ex) { App.ReportError(ex, false, LogLevel.Warning); }
            finally { Application.DoEvents(); if (this.ServiceStatesChanged != null)
                      {
                          this.ServiceStatesChanged(this, new EventArgs());
                      }
            }
        }
Exemple #2
0
 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); }
 }
Exemple #3
0
 //Interface
 public dlgLoadTender(DispatchDataset.LoadTenderLogTableRow entry, bool isTemplate = false)
 {
     try {
         InitializeComponent();
         this.wbAddress.Url = new Uri(global::Argix.Properties.Settings.Default.MapUrl);
         this.mEntry        = entry;
         if (this.mEntry.IsIDNull())
         {
             this.mEntry.ID = 0;
         }
     }
     catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
 }
Exemple #4
0
        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; }
        }