Exemplo n.º 1
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            //Event handler for form load event
            this.Cursor = Cursors.WaitCursor;
            try {
                //Get lists
                this.bsClients.DataSource = FreightGateway.GetClients();
                this.bsAgents.DataSource  = FreightGateway.GetAgents();

                //Load controls
                this.Text = "Pickup Request" + "(" + (this.mRequest.RequestID > 0 ? this.mRequest.RequestID.ToString() : "New") + (this.mIsTemplate ? " Template)" : ")");
                this.lblRequestID.Text     = this.mRequest.RequestID > 0 ? this.mRequest.RequestID.ToString("00000000") : "";
                this.dtpScheduleDate.Value = !this.mRequest.IsScheduleDateNull() ? this.mRequest.ScheduleDate : DateTime.Today;

                if (!this.mRequest.IsClientNumberNull())
                {
                    this.cboClient.SelectedValue = this.mRequest.ClientNumber;
                }
                else
                {
                    this.cboClient.SelectedIndex = -1;
                    this.cboClient.Text          = !this.mRequest.IsClientNull() ? this.mRequest.Client : "";
                }
                this.txtCaller.Text = !this.mRequest.IsCallerNameNull() ? this.mRequest.CallerName : "";

                if (!this.mRequest.IsShipperNumberNull() && this.mRequest.ShipperNumber.Trim().Length > 0)
                {
                    this.cboShipper.SelectedValue = this.mRequest.ShipperNumber;
                }
                else
                {
                    this.cboShipper.SelectedIndex = -1;
                    this.cboShipper.Text          = !this.mRequest.IsShipperNull() ? this.mRequest.Shipper : "";
                    this.txtShipperAddress.Text   = !this.mRequest.IsShipperAddressNull() ? this.mRequest.ShipperAddress : "";
                }
                OnShipperAddressChanged(null, EventArgs.Empty);
                this.txtShipperPhone.Text = !this.mRequest.IsShipperPhoneNull() ? this.mRequest.ShipperPhone : "";
                this.mtbOpen.Text         = !this.mRequest.IsWindowOpenNull() ? this.mRequest.WindowOpen.ToString().PadLeft(4, '0') : "";
                this.mtbClose.Text        = !this.mRequest.IsWindowCloseNull() ? this.mRequest.WindowClose.ToString().PadLeft(4, '0') : "";

                if (!this.mRequest.IsTerminalNumberNull())
                {
                    this.cboTerminal.SelectedValue = this.mRequest.TerminalNumber.Trim();
                }
                else
                {
                    this.cboTerminal.SelectedIndex = -1;
                    this.cboTerminal.Text          = !this.mRequest.IsTerminalNull() ? this.mRequest.Terminal : "";
                }
                OnTerminalSelectedIndexChanged(null, EventArgs.Empty);
                if (!this.mRequest.IsDriverNameNull())
                {
                    this.cboDriver.Text = this.mRequest.DriverName;
                }
                else
                {
                    this.cboDriver.SelectedIndex = -1;
                }
                this.dtpActual.Checked = !this.mRequest.IsActualPickupNull();
                if (this.dtpActual.Checked)
                {
                    this.dtpActual.Value = this.mRequest.ActualPickup;
                }
                this.dtpActual.Enabled          = true;
                this.cboOrderType.SelectedIndex = this.mRequest.OrderType == "B" ? 1 : 0;

                this.txtQuantity.Text = !this.mRequest.IsAmountNull() ? this.mRequest.Amount.ToString() : "0";
                if (!this.mRequest.IsAmountTypeNull())
                {
                    this.cboContainer.Text = this.mRequest.AmountType;
                }
                else
                {
                    this.cboContainer.SelectedIndex = 0;
                }
                this.cboFreightType.Text = !this.mRequest.IsFreightTypeNull() ? this.mRequest.FreightType : "Tsort";

                this.txtWeight.Text   = !this.mRequest.IsWeightNull() ? this.mRequest.Weight.ToString() : "0";
                this.txtComments.Text = !this.mRequest.IsCommentsNull() ? this.mRequest.Comments : "";

                this.cboClient.Focus();
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
            finally { OnValidateForm(null, null); this.Cursor = Cursors.Default; }
        }