Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {//QuoteNo = "000111";
                QuoteNo = Request["q"] == null ? string.Empty : Request["q"].ToString();

                if (q != null && q.QuoteNumber != null && q.QuoteNumber != string.Empty) { lblQuoteNO.Text = q.QuoteNumber; }
                bindDropdowns("ddDivision");
                bindDropdowns("ddPreferredCarrier");

                if (ViewState["Quote"] != null) { q = (BusinessObjects.Quote)ViewState["Quote"]; }
                bindControls(); bindgrid();
                Session["Quote"] = null;
            }
            else
            {
                //I'm using the session state here because the Viewstate has not been holding the changes consistently
                if (Session["Quote"] != null)
                {
                    q = (BusinessObjects.Quote)Session["Quote"];
                    Session["Quote"] = null; ViewState["Quote"] = q;
                }
                else if (ViewState["Quote"] != null)
                {
                    q = (BusinessObjects.Quote)ViewState["Quote"];
                }
                else { q = new BusinessObjects.Quote(); ViewState["Quote"] = q; }
            }
        }
Пример #2
0
        private void bindControls()
        {
            if (q == null) { q = new BusinessObjects.Quote(); ViewState["Quote"] = q; }

            txtQuoteNo.Text = q.QuoteNumber;
            if (cbxCustomer.Items.Count < 2) { cbxCustomer.DataSource = Functions.DB.GetCustomers(q.Customer, 0, 1); cbxCustomer.DataBind(); }
            if (cbxCustomer.Items.Count(i => i.Text == q.Customer) > 0)
            {
                cbxCustomer.SelectedIndex = cbxCustomer.Items.IndexOf(cbxCustomer.Items.First(i => i.Text == q.Customer));
            }
            txtContact.Text = q.CustomerContact;
            txtTelephone.Text = q.CustomerPhone;
            txtFax.Text = q.CustomerFax;
            txtCustRef.Text = q.CustomerReferenceNo;
            if (ddPickupCity.Items.Count < 2) { ddPickupCity.DataSource = Functions.DB.GetPlaces(q.PickupCity, 0, 1); ddPickupCity.DataBind(); }
            if (ddPickupCity.Items.Count(i => i.Text == q.PickupCity) > 0)
            {
                ddPickupCity.SelectedIndex = ddPickupCity.Items.IndexOf(ddPickupCity.Items.First(i => i.Text == q.PickupCity));
            }
            if (ddcustState.Items.Count < 2) { ddcustState.DataBind(); }
            if (ddcustState.Items.Count(i => i.Text == q.CustomerState) > 0)
            {
                ddcustState.SelectedIndex = ddcustState.Items.IndexOf(ddcustState.Items.First(i => i.Text == q.CustomerState));
            }
            txtcustZip.Text = q.CustomerZip;
            if (ddPortofLoad.Items.Count < 2) { ddPortofLoad.DataSource = Functions.DB.GetPorts(q.PortOfLoad, 0, 1); ddPortofLoad.DataBind(); }
            if (ddPortofLoad.Items.Count(i => i.Text == q.PortOfLoad) > 0)
            {
                ddPortofLoad.SelectedIndex = ddPortofLoad.Items.IndexOf(ddPortofLoad.Items.First(i => i.Text == q.PortOfLoad));
            }
            if (ddPortOfDispatch.Items.Count < 2) { ddPortOfDispatch.DataSource = Functions.DB.GetPorts(q.PortOfDispatch, 0, 1); ddPortOfDispatch.DataBind(); }
            if (ddPortOfDispatch.Items.Count(i => i.Text == q.PortOfDispatch) > 0)
            {
                ddPortOfDispatch.SelectedIndex = ddPortOfDispatch.Items.IndexOf(ddPortOfDispatch.Items.First(i => i.Text == q.PortOfDispatch));
            }
            if (ddFinalDestination.Items.Count < 2) { ddFinalDestination.DataSource = Functions.DB.GetPlaces(q.FinalDestination, 0, 1); ddFinalDestination.DataBind(); }
            if (ddFinalDestination.Items.Count(i => i.Value == q.FinalDestination) > 0)
            {
                ddFinalDestination.SelectedIndex = ddFinalDestination.Items.IndexOf(ddFinalDestination.Items.First(i => i.Value == q.FinalDestination));
            }
            txtDestZip.Text = q.DestinationZip;
            if (ddDestCountry.Items.Count < 2) { ddDestCountry.DataBind(); }
            if (ddDestCountry.Items.Count(i => i.Text == q.DestinationCountry) > 0)
            {
                ddDestCountry.SelectedIndex = ddDestCountry.Items.IndexOf(ddDestCountry.Items.First(i => i.Text == q.DestinationCountry));
            }
            if (ddTypeOfMove.Items.Count < 2) { ddTypeOfMove.DataSource = Functions.DB.GetServiceTypes(q.TypeOfMove, 0, 1); ddTypeOfMove.DataBind(); }
            if (ddTypeOfMove.Items.Count(i => i.Text == q.TypeOfMove) > 0)
            {
                ddTypeOfMove.SelectedIndex = ddTypeOfMove.Items.IndexOf(ddTypeOfMove.Items.First(i => i.Text == q.TypeOfMove));
            }
            txtQuoteNo.Text = q.QuoteNumber;
            ddDivision.SelectedValue = ddDivision.Items.FindByValue(q.Division) != null ? q.Division : string.Empty;
            ddBusinessLine.SelectedValue = ddBusinessLine.Items.FindByValue(q.Businessline) != null ? q.Businessline : string.Empty;
            txtINCOTerms.Text = q.INCOTerms;
            txtINCOLocation.Text = q.INCOTermsLocation;
            txtEffextiveDate.Text = q.Effectivdate == DateTime.MinValue ? "" : q.Effectivdate.ToShortDateString();
            txtExpirationDate.Text = q.ExpirationDate == DateTime.MinValue ? "" : q.ExpirationDate.ToShortDateString();
            txtQuotedBy.Text = q.QuotedBy;
            if (ddSalesRep.Items.Count < 2) { ddSalesRep.DataBind(); }
            if (ddSalesRep.Items.Count(i => i.Value == q.SalesRep) > 0)
            {
                ddSalesRep.SelectedIndex = ddSalesRep.Items.IndexOf(ddSalesRep.Items.First(i => i.Value == q.SalesRep));
            }
            ddPreferredCarrier.SelectedValue = ddPreferredCarrier.Items.FindByText(q.PreferredCarrier) != null ? q.PreferredCarrier : string.Empty;
            txtVoyage.Text = q.Voyage;
            ddVessel.SelectedValue = ddVessel.Items.FindByText(q.Vessel) != null ? q.Vessel : string.Empty;
            ddContainerHandling.SelectedValue = ddContainerHandling.Items.FindByText(q.ContainerHandling) != null ? q.ContainerHandling : string.Empty;

             //           bindgrid();
        }
Пример #3
0
 protected void lvContainers_ItemCanceling(object sender, ListViewCancelEventArgs e)
 {
     lvContainers.EditItem.Controls.Clear();
     lvContainers.EditIndex = -1;
     lvContainers.InsertItemPosition = InsertItemPosition.None;
     q = (BusinessObjects.Quote)ViewState["BeforeEdit"];
     bindControls(); bindgrid();
     ViewState["Quote"] = q;
 }