Example #1
0
        private void OnCommandClick(object sender, System.EventArgs e)
        {
            //Event handler for button selection
            this.Cursor = Cursors.WaitCursor;
            try {
                Button btn = (Button)sender;
                switch (btn.Name)
                {
                case "btnQuote":
                    this.Cursor = Cursors.WaitCursor;
                    showQuote(null);
                    LTLQuote2 quote = new LTLQuote2();
                    #region Create Quote
                    quote.ID                     = 0;
                    quote.Created                = DateTime.Now;
                    quote.ShipDate               = this.dtpShipDate.Value;
                    quote.ClientID               = int.Parse(this.cboClient.SelectedValue.ToString());
                    quote.OriginZip              = this.txtShipperZip.Text;
                    quote.DestinationZip         = this.txtConsigneeZip.Text;
                    quote.Pallet1Class           = quote.Pallet2Class = quote.Pallet3Class = quote.Pallet4Class = quote.Pallet5Class = "FAK";
                    quote.Pallet1Weight          = int.Parse(this.grdPallets.Rows[0].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint);
                    quote.Pallet1InsuranceValue  = decimal.Parse(this.grdPallets.Rows[0].Cells["InsuranceValue"].Value.ToString());
                    quote.Pallet2Weight          = this.grdPallets.Rows.Count > 1 ? int.Parse(this.grdPallets.Rows[1].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint) : 0;
                    quote.Pallet2InsuranceValue  = this.grdPallets.Rows.Count > 1 ? decimal.Parse(this.grdPallets.Rows[1].Cells["InsuranceValue"].Value.ToString()) : 0;
                    quote.Pallet3Weight          = this.grdPallets.Rows.Count > 2 ? int.Parse(this.grdPallets.Rows[2].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint) : 0;
                    quote.Pallet3InsuranceValue  = this.grdPallets.Rows.Count > 2 ? decimal.Parse(this.grdPallets.Rows[2].Cells["InsuranceValue"].Value.ToString()) : 0;
                    quote.Pallet4Weight          = this.grdPallets.Rows.Count > 3 ? int.Parse(this.grdPallets.Rows[3].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint) : 0;
                    quote.Pallet4InsuranceValue  = this.grdPallets.Rows.Count > 3 ? decimal.Parse(this.grdPallets.Rows[3].Cells["InsuranceValue"].Value.ToString()) : 0;
                    quote.Pallet5Weight          = this.grdPallets.Rows.Count > 4 ? int.Parse(this.grdPallets.Rows[4].Cells["Weight"].Value.ToString(), System.Globalization.NumberStyles.AllowDecimalPoint) : 0;
                    quote.Pallet5InsuranceValue  = this.grdPallets.Rows.Count > 4 ? decimal.Parse(this.grdPallets.Rows[4].Cells["InsuranceValue"].Value.ToString()) : 0;
                    quote.InsidePickup           = this.chkShipperInsidePickup.Checked;
                    quote.LiftGateOrigin         = this.chkShipperLiftGate.Checked;
                    quote.AppointmentOrigin      = this.chkShipperAppt.Checked;
                    quote.SameDayPickup          = this.chkShipperSameDay.Checked;
                    quote.InsideDelivery         = this.chkConsigneeInsideDelivery.Checked;
                    quote.LiftGateDestination    = this.chkConsigneeLiftGate.Checked;
                    quote.AppointmentDestination = this.chkConsigneeAppt.Checked;
                    quote.Pallets                = 0;
                    quote.Weight                 = quote.PalletRate = quote.FuelSurcharge = quote.AccessorialCharge = quote.InsuranceCharge = quote.TollCharge = quote.TotalCharge = 0.0M;
                    #endregion
                    quote = FreightGateway.CreateQuote(quote);
                    this.mQuotes.Add(quote);
                    this.grdQuotes.Refresh();
                    showQuote(quote);
                    break;

                case "btnClear":
                    this.txtShipperZip.Text       = this.txtConsigneeZip.Text = "";
                    this.chkShipperAppt.Checked   = this.chkShipperInsidePickup.Checked = this.chkShipperLiftGate.Checked = this.chkShipperSameDay.Checked = false;
                    this.chkConsigneeAppt.Checked = this.chkConsigneeInsideDelivery.Checked = this.chkConsigneeLiftGate.Checked = false;
                    this.mPallets.Clear();
                    this.lblEstimatedDeliveryDate.Text = "";
                    //this.txtPallets.Text = this.txtWeight.Text = "";
                    this.txtRate.Text = this.txtFSC.Text = this.txtAccessorials.Text = this.txtInsurance.Text = this.txtTSC.Text = this.txtTotal.Text = "";
                    break;
                }
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
            finally { this.Cursor = Cursors.Default; }
        }