Пример #1
0
		private bool unassignFreight() {
			//Unassign one or more station assignments
			bool bOK=true;
			this.Cursor = Cursors.WaitCursor;
			try {
				foreach(FreightAssignDS.StationFreightAssignmentTableRow row in this.mAssignmentsDS.StationFreightAssignmentTable.Rows) {
                    WorkstationDS.WorkstationTableRow ws = new WorkstationDS().WorkstationTable.NewWorkstationTableRow();
					ws.WorkStationID = row.WorkStationID;
					ws.Number = row.StationNumber;
                    Workstation station = new Workstation(ws);
                    InboundFreightDS.InboundFreightTableRow ibf = new InboundFreightDS().InboundFreightTable.NewInboundFreightTableRow();
                    ibf.FreightID = row.FreightID;
                    ibf.TDSNumber = row.TDSNumber;
                    ibf.ClientNumber = ibf.ClientName = row.Client;
                    IBShipment shipment = new IBShipment(ibf);
                    StationAssignment assignment = new StationAssignment(station,shipment,row.SortTypeID);
					bool deleted=false;
					try {
						deleted = FreightFactory.DeleteAssignment(assignment, "Unassigned");
					}
					catch(ApplicationException ex) { App.ReportError(ex, true, LogLevel.Error); }
					catch(Exception ex) { App.ReportError(new ApplicationException("Failed to unassign freight " + row.FreightID + " from station " + row.WorkStationID + " (sorttypeID= " + row.SortTypeID.ToString() + ").", ex), true, LogLevel.Error); }
					if(!deleted) bOK = false;
					row.Result = (!deleted) ? EX_RESULT_FAILED : EX_RESULT_OK;
					this.grdAssignments.Refresh();
					Application.DoEvents();
				}
			}
			catch(Exception ex) { App.ReportError(ex, true, LogLevel.Error); } 
			return bOK;
		}
Пример #2
0
		private bool freightStarted() {
			//Set freight status to started if applicable
			DialogResult res=DialogResult.None;
			bool bStarted=true;
			try {
                if(this.mShipment.Status==ShipmentStatusEnum.Unsorted) {
					//Before we can make assignment we need to make sure we can set the freight status to 
					//sorting (sort started); no exception is thrown if the status cannot be changed
					bStarted=false;
					res = MessageBox.Show(this, "The selected freight must be 'sorting' prior to assignment. Would you like to start sort for this freight?", App.Product, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
					if(res==DialogResult.Yes) {
						//Update a shipment as sorting
						//Double check result on exception: freight can be assigned if status is sorting
						try {
							bStarted = FreightFactory.StartSort(this.mShipment);
						}
                        catch(Exception) { bStarted = FreightFactory.IsSortStarted(this.mShipment); }
						if(!bStarted) 
							App.ReportError(new ApplicationException("Sorting could not be started for freight " + this.mShipment.FreightID + "(VendorKey=" + this.mShipment.VendorKey + "; Status=" + this.mShipment.Status + "). Please refresh and try again."), true, LogLevel.Error);
					}
				}
			}
			catch(Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
			return bStarted;
		}
Пример #3
0
		//Interface
		public dlgAssignmentDetail(DialogActionEnum eDialogAction, IBShipment shipment, string workstationID) {
			//Constructor
			try {
				//Required for Windows Form Designer support
				InitializeComponent();
				this.cmdCancel.Text = CMD_CANCEL;
				this.cmdBack.Text = CMD_BACK;
				this.cmdNext.Text = CMD_NEXT;
				this.mShipment = shipment;
				switch(this.mDialogAction = eDialogAction) {
					case DialogActionEnum.DialogActionAssign:		
						this.Text = "Assign Freight To Sort Stations"; 
						this.mAssignmentsDS.Clear();
						break;
					case DialogActionEnum.DialogActionUnassignAny:	
						this.Text = "Unassign Freight From Sort Stations"; 
						this.mAssignmentsDS.Merge(FreightFactory.GetAssignments(this.mShipment.FreightID, ""));
						break;
					case DialogActionEnum.DialogActionUnassign:		
						this.Text = "Unassign Freight From Sort Station"; 
						this.mAssignmentsDS.Merge(FreightFactory.GetAssignments(this.mShipment.FreightID, workstationID));
						break;
				}
			}
			catch(Exception ex) { throw new ApplicationException("Could not crate new Assignment Detail dialog.", ex); }
		}
Пример #4
0
		private void setDialogLayout() {
			try {
				this.grdFreightTypes.Visible = (this.mScreenID == 0);
				this.grdSortStations.Visible = (this.mScreenID == 1);
				this.grdAssignments.Visible = (this.mScreenID == 2);
				switch(this.mScreenID) {
					case 0: 
						//Setup for sort type selection
						this.lblInstructions.Text = INSTR_0;
						this.cmdBack.Enabled = false;
						this.cmdNext.Text = CMD_NEXT;
						this.cmdNext.Enabled = (this.grdFreightTypes.Selected.Rows.Count > 0);
						break;
					case 1: 
						//Setup for sort station selection
						this.lblInstructions.Text = INSTR_1;
						this.cmdBack.Enabled = ((this.mDialogAction == DialogActionEnum.DialogActionAssign) && (this.grdFreightTypes.Rows.Count > 1));
						this.cmdNext.Text = CMD_NEXT;
						this.cmdNext.Enabled = (this.grdSortStations.Selected.Rows.Count > 0);
						if(this.mSortStationsDS.WorkstationTable.Rows.Count == 0) {
							int iSortTypeID = Convert.ToInt32(this.grdFreightTypes.Selected.Rows[0].Cells["ID"].Value);
                            this.mSortStationsDS.Merge(FreightFactory.GetAssignableSortStations(this.mShipment.FreightID,iSortTypeID));
							if(this.grdSortStations.Rows.Count > 0) this.grdSortStations.Rows[0].Activate();
						}
						this.grdSortStations.ActiveRow = null;
						this.grdSortStations.Focus();
						break;
					case 2: 
						//Setup for assignments view
						switch(this.mDialogAction) {
							case DialogActionEnum.DialogActionAssign:		this.lblInstructions.Text = INSTR_21; break;
							case DialogActionEnum.DialogActionUnassignAny:	this.lblInstructions.Text = INSTR_22; break;
							case DialogActionEnum.DialogActionUnassign:		this.lblInstructions.Text = INSTR_23; break;
						}
						this.cmdBack.Enabled = (this.mDialogAction != DialogActionEnum.DialogActionUnassign);
						this.cmdNext.Text = CMD_FINISH;
						this.cmdNext.Enabled = true;
						
						//Create station freight assignments dataset for last grid view
						//Note: The single unassign assignment was merged into mAssignmentsDS in the constructor (DO NOT SET HERE)
						if(this.mDialogAction != DialogActionEnum.DialogActionUnassign) {
							this.mAssignmentsDS.Clear();
							for(int i=0; i<this.grdSortStations.Selected.Rows.Count; i++) {
								FreightAssignDS.StationFreightAssignmentTableRow row = this.mAssignmentsDS.StationFreightAssignmentTable.NewStationFreightAssignmentTableRow();
								row.WorkStationID = this.grdSortStations.Selected.Rows[i].Cells["WorkstationID"].Value.ToString();
								row.StationNumber = this.grdSortStations.Selected.Rows[i].Cells["Number"].Value.ToString();
								row.FreightID = this.mShipment.FreightID;
								row.TDSNumber = this.mShipment.TDSNumber;
                                row.Client = this.mShipment.ClientNumber;
								row.SortTypeID = (this.mDialogAction==DialogActionEnum.DialogActionAssign) ? Convert.ToInt32(this.grdFreightTypes.Selected.Rows[0].Cells["ID"].Value) : 0;
								this.mAssignmentsDS.StationFreightAssignmentTable.AddStationFreightAssignmentTableRow(row);
							}
                            this.mAssignmentsDS.AcceptChanges();
						}
						break;
				}
			} 
			catch(Exception ex) { App.ReportError(ex, false, LogLevel.Warning); } 
		}
Пример #5
0
        //Interface
        public dlgAssignment(WorkstationDS selectedStations)
        {
            //Constructor
            try {
                //Required for Windows Form Designer support
                InitializeComponent();
                #region Set command button identities (used for onclick handler)
                this.btnCancel.Text = CMD_CANCEL;
                this.btnOK.Text     = CMD_OK;
                #endregion

                //Set services
                this.mSelectedStations   = selectedStations;
                this.mUnassignedStations = FreightFactory.GetUnassignedStations();
            }
            catch (Exception ex) { throw ex; }
        }
Пример #6
0
		private void OnFormLoad(object sender, System.EventArgs e) {
			//Event handler for form load event
			this.Cursor = Cursors.WaitCursor;
			try {
				//Set initial conditions
				this.grdFreightTypes.DisplayLayout.Bands[0].Columns["ID"].SortIndicator = SortIndicator.Ascending;
				this.grdSortStations.DisplayLayout.Bands[0].Columns["Number"].SortIndicator = SortIndicator.Ascending;
				this.grdAssignments.DisplayLayout.Bands[0].Columns["StationNumber"].SortIndicator = SortIndicator.Ascending;
				switch(this.mDialogAction) {
					case DialogActionEnum.DialogActionAssign: 
						//Assignment- show freight sort types for selection.
						//Note: If only 1 sort type, select for user and go to next screen
						this.mScreenID = 0;
						this.mFreightSortTypesDS.Merge(FreightFactory.GetFreightSortTypes(this.mShipment.FreightID));
						if(this.grdFreightTypes.Rows.Count > 0) {
							this.grdFreightTypes.Rows[0].Selected = true;
							this.grdFreightTypes.Rows[0].Activate();
						}
						if(this.grdFreightTypes.Rows.Count == 1) this.mScreenID = 1;
						break;
					case DialogActionEnum.DialogActionUnassignAny: 
						//Delete one or more assignments (as selected by user)
						//Transfer assignments into sort stations for user selection
						this.mScreenID = 1;
						for(int i=0; i<this.mAssignmentsDS.StationFreightAssignmentTable.Rows.Count; i++) {
							WorkstationDS.WorkstationTableRow row = this.mSortStationsDS.WorkstationTable.NewWorkstationTableRow();
							row.WorkStationID = this.mAssignmentsDS.StationFreightAssignmentTable[i].WorkStationID;
							row.Number = (!this.mAssignmentsDS.StationFreightAssignmentTable[i].IsStationNumberNull()) ? this.mAssignmentsDS.StationFreightAssignmentTable[i].StationNumber : "?";
							row.Description = "";
							this.mSortStationsDS.WorkstationTable.AddWorkstationTableRow(row);
						}
						break;
					case DialogActionEnum.DialogActionUnassign: 
						//Delete a single assignment
						this.mScreenID = 2;
						break;
				}
				setDialogLayout();
			}
			catch(Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
			finally { this.Cursor = Cursors.Default; }
		}
Пример #7
0
		private bool assignFreight() {
			bool bOK=true;
			this.Cursor = Cursors.WaitCursor;
			try {
				//Create station freight assignments
				foreach(FreightAssignDS.StationFreightAssignmentTableRow row in this.mAssignmentsDS.StationFreightAssignmentTable.Rows) {
                    WorkstationDS.WorkstationTableRow ws = new WorkstationDS().WorkstationTable.NewWorkstationTableRow();	
                    ws.WorkStationID = row.WorkStationID;
					ws.Number = row.StationNumber;
                    Workstation station = new Workstation(ws);
                    bool created = false;
					try {
						created = (FreightFactory.CreateAssignment(station, this.mShipment, row.SortTypeID, "Assigned") != null);
					}
					catch(ApplicationException ex) { App.ReportError(ex, true, LogLevel.Error); }
					if(!created) bOK = false;
					row.Result = (!created) ? EX_RESULT_FAILED : EX_RESULT_OK;
					this.grdAssignments.Refresh();
					Application.DoEvents();
				}
			}
			catch(Exception ex) { App.ReportError(ex, true, LogLevel.Error); } 
			return bOK;
		}