private void bindControls()
        {
            if (q == null) { q = new BusinessObjects.Quote(); }

            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();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {//QuoteNo = "000111";

                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();
                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"];
                }
            }
        }
Beispiel #3
0
        private static BusinessObjects.Quote populateQuoteFromDataRow(DataRow row)
        {
            BusinessObjects.Quote q = new BusinessObjects.Quote();
                q.ID = int.Parse(row["ID"].ToString());
                q.QuoteNumber = row["REFERENCE_NO"].ToString();
                q.Customer = row["SHIPPER_NAME"].ToString().Trim();
                q.CustomerCode = row["SHIPPER"].ToString().Trim();
                q.CustomerContact = row["SHIPPER_CONTACT"].ToString();
                q.CustomerPhone = row["SHIPPER_PHONE"].ToString();
                q.CustomerFax = row["SHIPPER_FAX"].ToString();
                q.CustomerReferenceNo = row["P_O_NUMBER"].ToString();
                q.PickupCity = row["PLR"].ToString().Trim();
                q.CustomerState = row["SUPPLIER_STATE"].ToString().Trim();
                q.CustomerZip = row["SUPPLIER_ZIP_CODE"].ToString();
                q.PortOfLoad = row["POL"].ToString().Trim();
                q.PortOfDispatch = row["POD"].ToString().Trim();
                q.FinalDestination = row["FinalDestino"].ToString();
                q.DestinationZip = row["CONSIGNEE_ZIP_CODE"].ToString();
                q.DestinationCountry = row["CONSIGNEE_COUNTRY"].ToString().Trim();
                q.TypeOfMove = row["MOVE_TYPE"].ToString().Trim();
                q.Division = row["PAYMENT"].ToString().Trim();
                q.Businessline = row["BUS_LINE"].ToString().Trim();
                q.INCOTerms = row["Incoterms"].ToString();
                q.INCOTermsLocation = row["IncotermsLocation"].ToString();
                DateTime effdate;
                DateTime.TryParse(row["EFFECTIVE_DATE"].ToString(), out effdate);
                q.Effectivdate = effdate;
                DateTime expdate;
                DateTime.TryParse(row["EXPIRATION_DATE"].ToString(), out expdate);
                q.ExpirationDate = expdate;
                q.QuotedBy = row["QuotedBy"].ToString();
                q.SalesRep = row["CONTROLLER"].ToString();
                q.PreferredCarrier = row["CARRIER"].ToString();
                q.Voyage = row["Voyage"].ToString();
                q.Vessel = row["Vessel"].ToString();
                q.ContainerHandling = row["ContainerHandeling"].ToString();
                q.Containers = GetContainers(q.QuoteNumber);

                return q;
        }
 protected void lvContainers_ItemCanceling(object sender, ListViewCancelEventArgs e)
 {
     lvContainers.EditIndex = -1;
     lvContainers.InsertItemPosition = InsertItemPosition.None;
     q = (BusinessObjects.Quote) ViewState["BeforeEdit"];
     bindControls();
     ViewState["Quote"] = q;
 }
Beispiel #5
0
        public static BusinessObjects.Quote getQuote(string quoteno)
        {
            string sql = string.Empty;
            if (quoteno == null || quoteno == string.Empty)
            {
                sql = @"SELECT Top 0 ID, REFERENCE_NO, CONTROLLER, EFFECTIVE_DATE, EXPIRATION_DATE, SHIPPER, SHIPPER_NAME, SHIPPER_CONTACT, SHIPPER_PHONE,
                            SHIPPER_FAX, COMMODITY, MOVE_TYPE, PAYMENT, P_O_NUMBER, PLR, POL, POD, SUPPLIER_STATE, SUPPLIER_ZIP_CODE, CONSIGNEE_STATE,
                            CONSIGNEE_ZIP_CODE, CONSIGNEE_COUNTRY, CARRIER, BUS_LINE, IncotermsLocation, ContainerHandeling, Booking_UID
            ,Voyage,FinalDestino,QuotedBY
                            FROM QUOTES_DAT
                            order by effective_date desc";
            }
            else
            {
                sql = @"SELECT Top 1 ID, REFERENCE_NO, CONTROLLER, EFFECTIVE_DATE, EXPIRATION_DATE, SHIPPER, SHIPPER_NAME, SHIPPER_CONTACT, SHIPPER_PHONE,
                            SHIPPER_FAX, COMMODITY, MOVE_TYPE, PAYMENT, P_O_NUMBER, PLR, POL, POD, SUPPLIER_STATE, SUPPLIER_ZIP_CODE, CONSIGNEE_STATE,
                            CONSIGNEE_ZIP_CODE, CONSIGNEE_COUNTRY, CARRIER, BUS_LINE, Incoterms, IncotermsLocation, ContainerHandeling, Booking_UID
            ,Voyage,FinalDestino,QuotedBY,Vessel
                            FROM QUOTES_DAT where REFERENCE_NO=?
                            order by effective_date desc";
            }

            DataTable dt = new DataTable();
            using (OdbcDataAdapter adp = new OdbcDataAdapter(sql, Properties.Settings.Default.IESDBConn))
            {
                adp.SelectCommand.Parameters.Add(new OdbcParameter("@ID", quoteno));
                adp.Fill(dt);
            }

            BusinessObjects.Quote q = new BusinessObjects.Quote();
            if (dt.Rows.Count > 0)
            {
                q = populateQuoteFromDataRow(dt.Rows[0]);
                return q;
            }
            return null;
        }