Пример #1
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; }
        }
Пример #2
0
        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; }
        }