示例#1
0
        protected void ContinuePayment(object sender, EventArgs e)
        {
            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();

            Customer cust = client.GetCustomer(Session["UserID"].ToString());

            try
            {
                if (Page.IsValid)
                {
                    //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                    //          DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    //          "info",
                    //          "---NDAL create client Begin------"));
                    //Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                    //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                    //         DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    //         "info",
                    //         "---NDAL create client End------"));

                    //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                    //         DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    //         "info",
                    //         "---GetCustomer() Begin------"));
                    //Customer cust = client.GetCustomer(Session["UserID"].ToString());
                    //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                    //         DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    //         "info",
                    //         "---GetCustomer() End------"));

                    bool continBill = true;
                    if (Session["UserID"] != null)
                    {
                        if (Session["PaymentCookie"] == null)
                        {

                            if (CreditCardPanel.Visible)
                            {
                                Session["PaymentCookie"] = "CreditCardPanel";
                            }
                            else
                            {
                                Session["PaymentCookie"] = "PurchaseOrderPanel";
                            }

                        }

                        if (Session["PaymentCookie"].ToString() == "CreditCardPanel")
                        {
                            if (CreditCardLabelTextBox.Text.Trim().Length > 4)
                            {

                                string expiration = ExpirationDateLabelMonthDropDown.SelectedItem.Value + "/" +
                                    ExpirationDateLabelYearDropDown.SelectedItem.Text;

                                if (DateTime.Parse(ExpirationDateLabelMonthDropDown.SelectedItem.Value + "/" +
                                    DateTime.DaysInMonth(int.Parse(ExpirationDateLabelYearDropDown.SelectedItem.Text),
                                    int.Parse(ExpirationDateLabelMonthDropDown.SelectedItem.Value)).ToString()
                                    + "/" +
                                    ExpirationDateLabelYearDropDown.SelectedItem.Text) >= DateTime.Now.Date)
                                {
                                    //First check whether a credit card already exists 1/13/2010

                             //       HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                             //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             //"info",
                             //"---Get customer cards Begin------"));
                                    List<CreditCard> cardCheck = cust.CreditCards;
                            //        HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                            //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            //"info",
                            //"---Get customer cards End------"));

                                    CardTypes thisCardType;

                                    switch (CreditCard2TypeDropDown.SelectedItem.Text)
                                    {
                                        case "Discover":
                                            thisCardType = CardTypes.Discover;
                                            break;
                                        case "Visa":
                                            thisCardType = CardTypes.Visa;
                                            break;
                                        case "MasterCard":
                                            thisCardType = CardTypes.MasterCard;
                                            break;
                                        default:
                                            thisCardType = CardTypes.MasterCard;
                                            break;
                                    }

                                    bool foundCard = false;

                                    string cardInternalID = "";

                                    CreditCard cardToUse = new CreditCard();

                                    foreach (CreditCard cardo in cardCheck)
                                    {

                                        if (cardo.CardType == thisCardType &&
                                            cardo.CardNumber == CreditCardLabelTextBox.Text.Trim().Substring(CreditCardLabelTextBox.Text.Trim().Length - 5, 4)
                                            && cardo.ExpirationDate == expiration &&
                                            cardo.CardholderName == CreditCardNameLabelTextBox.Text.Trim())
                                        {
                                            foundCard = true;
                                            cardInternalID = cardo.InternalID;
                                            cardToUse = cardo;
                                            Session["CardToUser"] = cardToUse.InternalID;
                                        }
                                    }

                                    if (!foundCard)
                                    {

                                        cardToUse = new CreditCard();

                                        cardToUse.CardholderName = CreditCardNameLabelTextBox.Text;
                                        cardToUse.CardNumber = CreditCardLabelTextBox.Text;

                                        switch (CreditCard2TypeDropDown.SelectedItem.Text)
                                        {
                                            case "Discover":
                                                cardToUse.CardType = CardTypes.Discover;
                                                break;
                                            case "Visa":
                                                cardToUse.CardType = CardTypes.Visa;
                                                break;
                                            case "MasterCard":
                                                cardToUse.CardType = CardTypes.MasterCard;
                                                break;
                                            default: break;
                                        }

                                        cardToUse.DefaultCreditCard = true;

                                        cardToUse.ExpirationDate = expiration;
                                    }

                                    object refAdrs = (object)cardToUse;
                                    SaveDynamicFields("5", ref refAdrs);
                                    cardToUse = (CreditCard)refAdrs;

                                    if (!foundCard)
                                    {
                                        if (cust.CreditCards == null)
                                        {
                                            List<CreditCard> cards = new List<CreditCard>();
                                            cards.Add(cardToUse);
                                            cust.CreditCards = cards;
                                        }
                                        else
                                        {
                                            cust.CreditCards.Add(cardToUse);
                                        }

                                        //continBill = false;
                            //            HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                            //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            //"info",
                            //"---UpdateCustomer Begin------"));
                                        client.UpdateCustomer(cust);
                            //            HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                            //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            //"info",
                            //"---UpdateCustomer End------"));

                                        //continBill = true;
                              //          HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                              //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              //"info",
                              //"---GetCustomer() Begin------"));

                                        //***************GETTING RID OF THIS LINE TO OPTIMIZE CODE **************************
                                        Customer custer = client.GetCustomer(Session["UserID"].ToString());

                              //          HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                              //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              //"info",
                              //"---GetCustomer() End------"));

                              //          HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                              //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              //"info",
                              //"---retrieve customer CreditCards Begin------"));
                                        List<CreditCard> cardsThis = custer.CreditCards;
                              //          HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}",
                              //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              //"info",
                              //"---retrieve customer CreditCards End------"));

                                        foreach (CreditCard c in cardsThis)
                                        {
                                            if (c.DefaultCreditCard.Value)
                                                Session["CardToUser"] = c.InternalID;
                                        }
                                    }

                                    CreditCardInfoPanel.Visible = true;
                                    POPanel.Visible = false;
                                    CreditCardExpirationLabel.Text = expiration;

                                    CreditCardNumberLabel.Text = "";
                                    if (CreditCardLabelTextBox.Text.Length > 4)
                                    {
                                        int count = 0;

                                        while (count < CreditCardLabelTextBox.Text.Length - 4)
                                        {
                                            CreditCardNumberLabel.Text += "x";
                                            count++;
                                        }
                                        CreditCardNumberLabel.Text += CreditCardLabelTextBox.Text.Substring(CreditCardLabelTextBox.Text.Length - 4, 4);
                                    }
                                    else
                                    {
                                        CreditCardNumberLabel.Text = CreditCardLabelTextBox.Text;
                                    }

                                    Session["CreditCardType"] = CreditCard2TypeDropDown.SelectedItem.Text;

                                    Session["CreditExpirationLabel"] = expiration;

                                    Session["CreditCardLabel"] = CreditCardLabelTextBox.Text;

                                    Session["CreditCSVLabel"] = CSVLabelTextBox.Text;

                                    Session["CreditName"] = CreditCardNameLabelTextBox.Text;

                                    Session["formpage"] = "6";
                                }
                                else
                                {
                                    continBill = false;
                                    Session["formpage"] = "5";
                                    Static5Message.Text = "Expiration date must be greater than today.";
                                }
                            }
                            else
                            {
                                Static5Message.Text = "The Credit Card number you have entered is invalid";
                            }
                        }
                        else
                        {

                            Session["formpage"] = "6";
                            CreditCardInfoPanel.Visible = false;
                            POPanel.Visible = true;
                            POTextBox.Text = PurchaseOrderLabelTextBox.Text;

                            Session["POExpirationLabel"] = PurchaseOrderLabelTextBox.Text;

                            //Session["PaymentCompanyLabel"] = CompanyLabel5TextBox.Text;

                            //Session["PaymentAttentionLabel"] = AttentionLabel5TextBox.Text;

                            //string state = "";
                            //if (StateLabel5RadComboBox.Visible)
                            //    state = StateLabel5RadComboBox.SelectedItem.Text;
                            //else
                            //    state = StateLabel5TextBox.Text;

                            //Session["PaymentStateLabel"] = state;

                            //Session["PaymentCityLabel"] = CityLabel5TextBox.Text;

                            //Session["PaymentPhoneLabel"] = PhoneLabel5TextBox.Text;
                            //Session["PaymentEx"] = ex4TextBox.Text;

                            //Session["PaymentAddressLabel"] = Address1Label5TextBox.Text;

                            //Session["PaymentAddress2Label"] = Address2Label5TextBox.Text;

                            //Session["PaymentZipLabel"] = ZipLabel5TextBox.Text;

                            //Session["PaymentCountryLabel"] = CountryLabel5RadComboBox.SelectedValue;

                        }
                        if (continBill)
                        {

                            //Session["FormClicked"] = true;
                            ContBilling(true, false, client, ref cust);
                            client.UpdateCustomer(cust);
                            Session["formpage"] = "6";
                            Session["RedrawForm"] = "True";
                            //Response.Redirect("Account+Creation.aspx");
                            GoToForm(6, 5);
                            BuildIt(client, cust);
                        }
                        else
                        {
                            Session["formpage"] = "5";
                            //Static5Message.Text = "somthing happened";
                            GoToForm(5, 6);
                            BuildIt(client, cust);
                        }
                    }
                    else
                    {
                        ErrorLabel.Text = "user is null";
                        Response.Redirect("UserLogin.aspx");
                    }
                }
                else
                {
                    Session["formpage"] = "5";
                    GoToForm(5, 6);
                    BuildIt(client, cust);
                }
            }
            catch (CommandErrorException ex)
            {
                if (ex.ToString().Contains("for the following field: ccnumber"))
                {
                    Static5Message.Text = "The Credit Card number you have entered is invalid";
                }
                else
                {
                    Static5Message.Text = ex.ToString();
                }

                Session["formpage"] = "5";
                GoToForm(5, 6);
                BuildIt(client, cust);
            }
            catch (Exception ex)
            {
                Static5Message.Text = ex.ToString();

                Session["formpage"] = "5";
                GoToForm(5, 6);
                BuildIt(client, cust);
            }
        }
示例#2
0
        protected void ContinueBilling(object sender, EventArgs e)
        {
            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();

            Customer cust = client.GetCustomer(Session["UserID"].ToString());
            ContBilling(false, true, client, ref cust);
        }
示例#3
0
        protected void ContinueDelivery(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Session["FormClicked"] = true;

                bool isStateValid = false;
                if (StateLabel4RadComboBox.Visible)
                {
                    if (StateLabel4RadComboBox.SelectedValue != "-1")
                        isStateValid = true;
                }
                else
                {
                    if (StateLabel4TextBox.Text.Trim() != "")
                        isStateValid = true;
                }

                if (isStateValid)
                {
                    if (Session["UserID"] != null)
                    {
                        Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                        Customer cust = client.GetCustomer(Session["UserID"].ToString());

                        Address adr = new Address();
                        adr.DefaultBilling = false;
                        adr.DefaultShipping = false;
                        adr.DefaultDelivery = true;
                        adr.DefaultAccount = false;

                        Session["formpage"] = "5";

                        Session["DeliveryNameLabel"] = CompanyLabel4TextBox.Text;
                        DeliveryNameLabel.Text = CompanyLabel4TextBox.Text;

                        Session["DeliveryCompanyLabel"] = AttentionLabel3TextBox.Text;
                        DeliveryCompanyLabel.Text = AttentionLabel3TextBox.Text;
                        adr.CompanyName = CompanyLabel4TextBox.Text;

                        DeliveryStateLabel.Text = CityLabel4TextBox.Text;
                        adr.City = CityLabel4TextBox.Text;
                        string state = "";
                        if (StateLabel4RadComboBox.Visible)
                            state = StateLabel4RadComboBox.SelectedItem.Text;
                        else
                            state = StateLabel4TextBox.Text;
                        DeliveryStateLabel.Text += ", " + state + " " + ZipLabel3TextBox.Text;
                        adr.State = state;

                        Session["DeliveryStateLabel"] = state;

                        Session["DeliveryPhoneLabel"] = PhoneLabel4TextBox.Text;
                        Session["DeliveryEx"] = ex4TextBox.Text;

                        DeliveryPhoneLabel.Text = PhoneLabel4TextBox.Text;
                        adr.Phone = PhoneLabel4TextBox.Text;

                        if (ex4TextBox.Text.Trim() != "")
                        {
                            DeliveryPhoneLabel.Text = DeliveryPhoneLabel.Text + " x" + ex4TextBox.Text;
                            adr.Phone = adr.Phone + " x" + ex4TextBox.Text;
                        }

                        Session["DeliveryCityLabel"] = CityLabel4TextBox.Text;

                        Session["DeliveryResidential"] = ResidentialCheckBox3.Checked;
                        adr.Residential = ResidentialCheckBox3.Checked;

                        Session["DeliveryAttentionLabel"] = AttentionLabel3TextBox.Text;
                        adr.Attention = AttentionLabel3TextBox.Text;

                        Session["DeliveryAddress2Label"] = Address2Label4TextBox.Text;
                        adr.Address2 = Address2Label4TextBox.Text;

                        Session["DeliveryAddressLabel"] = Address1Label4TextBox.Text;
                        adr.Address1 = Address1Label4TextBox.Text;

                        Session["DeliveryZipLabel"] = ZipLabel4TextBox.Text;
                        adr.Zip = ZipLabel4TextBox.Text;

                        Session["DeliveryCountryLabel"] = CountryLabel4RadComboBox.SelectedValue;
                        DataSet dsCount = doQuery("SELECT * FROM Countries WHERE country_name = '" +
                            CountryLabel4RadComboBox.SelectedItem.Text + "'");
                        adr.Country = dsCount.Tables[0].Rows[0]["country_2_code"].ToString();

                        object refAdrs = (object)adr;
                        SaveDynamicFields("4", ref refAdrs);
                        adr = (Address)refAdrs;

                        UpdateAddress(adr, ref cust, AddressTypes.Delivery);
                        client.UpdateCustomer(cust);
                        FillPayment();
                        if (Session["EditDeliveryClicked"] != null)
                            if (bool.Parse(Session["EditDeliveryClicked"].ToString()))
                            {
                                Session["formpage"] = "5";
                                GoToForm(6, 4);
                                SetBoxes();
                                BuildIt(client, cust);
                            }
                            else
                            {
                                //Session["PaymentCookie"] = "CreditCardPanel";

                                //CreditCardPanel.Visible = true;
                                //PurchaseOrderPanel.Visible = false;

                                GoToForm(5, 4);

                            }
                        else
                        {
                            //Session["PaymentCookie"] = "CreditCardPanel";

                            //CreditCardPanel.Visible = true;
                            //PurchaseOrderPanel.Visible = false;
                            GoToForm(5, 4);
                        }

                        //((Panel)FindControl(Session["PaymentCookie"].Value.ToString())).Visible = true;
                    }
                }
                else
                {
                    ErrorLabelDelivery.Text = "State is required";
                }
            }
            else
            {
                ErrorLabel.Text = "page is not valid";
               // Response.Redirect("UserLogin.aspx");
            }
        }
示例#4
0
        protected void SaveDynamicFields(string formID, ref object NSDataType)
        {
            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();

            DataSet dsFields = doQuery("SELECT * FROM FormPageFields FPF, FieldTypes FT WHERE FPF.FieldTypeID=FT.ID AND FPF.FormPageID=" +
                formID);

            DataView dvFields = new DataView(dsFields.Tables[0], "", "", DataViewRowState.CurrentRows);

            if(dvFields.Count > 0)
                for (int i = 0; i < dvFields.Count; i++)
                {
                    TextBox textbox = (TextBox)FindControl(dvFields[i]["FieldName"].ToString().Replace(" ", "") + formID + i.ToString());
                    string dataType = dvFields[i]["NetSuiteDataType"].ToString();

                    switch (dataType)
                    {
                        case "1":
                            Customer cust = (Customer)NSDataType;
                            System.Reflection.MemberInfo[] members = cust.GetType().GetMembers();
                            for (int j = 0; j < members.Length; j++)
                            {
                                if (members[j].MemberType == System.Reflection.MemberTypes.Property)
                                {
                                    if (members[j].Name == dvFields[i]["NetSuiteField"].ToString())
                                    {
                                        cust.GetType().GetProperty(members[j].Name).SetValue(cust, textbox.Text, null);
                                        //cust.GetType().GetField(members[j].Name).SetValue(cust, textbox.Text);
                                    }
                                }
                            }
                            break;
                        case "2":
                            Address adrs = (Address)NSDataType;
                            System.Reflection.MemberInfo[] members2 = adrs.GetType().GetMembers();
                            for (int j = 0; j < members2.Length; j++)
                            {
                                if (members2[j].MemberType == System.Reflection.MemberTypes.Property)
                                {
                                    if (members2[j].Name == dvFields[i]["NetSuiteField"].ToString())
                                    {
                                        adrs.GetType().GetProperty(members2[j].Name).SetValue(adrs, textbox.Text, null);
                                        //adrs.GetType().GetField(members2[j].Name).SetValue(adrs, textbox.Text);
                                    }
                                }
                            }
                            break;
                        case "3":
                            CreditCard card = (CreditCard)NSDataType;
                            System.Reflection.MemberInfo[] members3 = card.GetType().GetMembers();
                            for (int j = 0; j < members3.Length; j++)
                            {
                                if (members3[j].MemberType == System.Reflection.MemberTypes.Property)
                                {
                                    if (members3[j].Name == dvFields[i]["NetSuiteField"].ToString())
                                    {
                                        card.GetType().GetProperty(members3[j].Name).SetValue(card, textbox.Text, null);
                                        //card.GetType().GetField(members3[j].Name).SetValue(card, textbox.Text);
                                    }
                                }
                            }
                            break;
                        default: break;
                    }
                }
        }
示例#5
0
        protected void SubmitOrder(object sender, EventArgs e)
        {
            if (Session["HasOrderBeenClicked"] == null)
            {
                try
                {
                    if (TermsCheckBox.Checked)
                    {

                        HttpContext.Current.Trace.Warn("FormPage_SubmitOrder()", string.Format("{0},{1},{2},{3}",
                              DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              "info",
                              "SubmitLogin()",
                              "---SubmitOrder Begin------"));
                        Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                        client.MediatorLoggingLevel = Explore.NetSuite.JSONservice.MediatorLogLevels.Debug;
                        HttpContext.Current.Trace.Warn("FormPage_SubmitOrder()", string.Format("{0},{1},{2},{3}",
                              DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              "info",
                              "SubmitLogin()",
                              "---SubmitOrder End------"));
                        //if (Session["UserID"] == null)
                        //    CreateUser();

                        HttpContext.Current.Trace.Warn("FormPage_SubmitOrder()", string.Format("{0},{1},{2},{3}",
                              DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              "info",
                              "SubmitLogin()",
                              "---CreateOrder() Begin------"));
                        CreateOrder();
                        HttpContext.Current.Trace.Warn("FormPage_SubmitOrder()", string.Format("{0},{1},{2},{3}",
                              DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              "info",
                              "SubmitLogin()",
                              "---CreateOrder() End------"));
                        if (Session["OrderStatus"].ToString() == "A")
                        {

                            OrderLabel.Text = "Your order number is #" + Session["OrderNumber"].ToString();
                        }
                        else
                        {
                            OrderLabel.Text = "Your order was not submited!";
                        }
                        string thecartID = Session["yourcart"].ToString();
                        doQuery("DELETE FROM Cart WHERE CartSessionID='" + thecartID+"'");

                        Session["formpage"] = "6";

                        //Clear cart after submitting to NetSuite
                        Session["yourcart"] = null;
                        Session.Remove("yourcart");

                        Session["HasOrderBeenClicked"] = "true";

                        //Update Top Header
                        UpdateTopHeader();

                        if (Session["PaymentCookie"].ToString() == "CreditCardPanel")
                        {
                            GoToForm(8, 6);
                            Session["PaymentCookie"] = null;
                            Session["CreditCardLabel"] = null;
                            Session["CreditCSVLabel"] = null;
                            Session["CreditExpirationLabel"] = null;
                            Session["CreditCardType"] = null;
                            Session["CreditName"] = null;
                            Session["POExpirationLabel"] = null;

                            Session.Remove("PaymentCookie");
                            Session.Remove("CreditCardLabel");
                            Session.Remove("CreditCSVLabel");
                            Session.Remove("CreditExpirationLabel");
                            Session.Remove("CreditCardType");
                            Session.Remove("CreditName");
                            Session.Remove("POExpirationLabel");
                            Session["formpage"] = "8";
                            Response.Redirect("default.aspx?a=form&id=1");
                        }
                        else
                        {
                            GoToForm(7, 6);
                            Session["PaymentCookie"] = null;
                            Session["CreditCardLabel"] = null;
                            Session["CreditCSVLabel"] = null;
                            Session["CreditExpirationLabel"] = null;
                            Session["CreditCardType"] = null;
                            Session["CreditName"] = null;
                            Session["POExpirationLabel"] = null;

                            Session.Remove("PaymentCookie");
                            Session.Remove("CreditCardLabel");
                            Session.Remove("CreditCSVLabel");
                            Session.Remove("CreditExpirationLabel");
                            Session.Remove("CreditCardType");
                            Session.Remove("CreditName");
                            Session.Remove("POExpirationLabel");
                            Session["formpage"] = "7";

                            //Get the invoice
                            Array theTransactions = (Array)client.GetTransactions(Session["UserID"].ToString(), DateTime.Now.AddMinutes(double.Parse("-10.00")), DateTime.Now);

                            //code recommended by john ogle. refer to bug 1688 in OA bug tracking system.
                            Dictionary<string, IEnumerable<Transaction>> invoiceMap = new Dictionary<string, IEnumerable<Transaction>>();
                            List<Transaction> invoices;

                            foreach (Transaction t in theTransactions)
                            {
                                if (t.Type != "SalesOrd")
                                {
                                    invoices = new List<Transaction>();

                                    if (invoiceMap.ContainsKey(t.CreatedFrom))
                                    {
                                        invoices = (List<Transaction>)invoiceMap[t.CreatedFrom];
                                    }
                                    else
                                    {
                                        invoiceMap.Add(t.CreatedFrom, invoices);
                                    }

                                    invoices.Add(t);
                                }
                            }

                            foreach (Transaction oneTrans in theTransactions)
                            {
                                if (oneTrans.Type == "SalesOrd" && oneTrans.OrderNumber == Session["OrderNumber"].ToString())
                                {
                                    SalesOrderHyperLink.NavigateUrl = oneTrans.PrintoutURL;
                                }
                            }

                            Response.Redirect("default.aspx?a=form&id=1");

                        }

                    }
                    else
                    {
                        Static6Messages.Text = "Must agree to terms and conditions.";
                    }
                }
                catch (CommandErrorException ex)
                {
                    if (ex.ToString().Contains("An error occurred while processing your credit card"))
                    {
                        Static6Messages.Text = "There was an error processing your credit card. Please contact the merchant for further assistance.";
                    }
                    else
                    {
                        Static6Messages.Text = ex.ToString();
                    }
                }
                catch (Exception ex)
                {
                    ErrorLabel.Text += ex.ToString();
                }

            }
            else
            {
                //Clear cart after submitting to NetSuite

                UpdateTopHeader();

                if (Session["PaymentCookie"].ToString() == "CreditCardPanel")
                {
                    GoToForm(8, 6);
                    Session["formpage"] = "8";
                    Response.Redirect("default.aspx?a=form&id=1");
                }
                else
                {
                    GoToForm(7, 6);
                    Session["formpage"] = "7";
                    Response.Redirect("default.aspx?a=form&id=1");
                }
            }
        }
示例#6
0
        protected void Page_Init(object sender, EventArgs e)
        {
            SamesAsCheckBox3.Checked = false;
            SamesAsCheckBox32.Checked = false;
            SameAsLabel4CheckBox.Checked = false;
            SameAsBillingLabel4CheckBox.Checked = false;
            SameAsShippingLabel4CheckBox.Checked = false;

               StaticFieldsPanel1.Visible = false;
            StaticFieldsPanel2.Visible = false;
            StaticFieldsPanel3.Visible = false;
            StaticFieldsPanel4.Visible = false;
            StaticFieldsPanel5.Visible = false;
            StaticFieldsPanel6.Visible = false;
            StaticFieldsPanel7.Visible = false;
            StaticFieldsPanel8.Visible = false;
            StaticFieldsPanel9.Visible = false;

            if(Session["AccountCreateType"] == null)
                Session["AccountCreateType"] = "Create";

            bool isCreate = false;

            if (Session["AccountCreateType"] == "Create")
                isCreate = true;

            string message = "";

            try
            {
                if (Session["formpage"] == null)
                {
                    Session["formpage"] = "1";
                }

                bool drawForm = false;
                if (Session["RedrawForm"] == null)
                {
                    drawForm = true;
                }
                else
                {
                    if (bool.Parse(Session["RedrawForm"].ToString()))
                        drawForm = true;
                    else
                        drawForm = false;
                }

                if (!IsPostBack)
                {
                    drawForm = true;
                }
                //ErrorLabel.Text = "got here2";
                DataSet dsAll = doQuery("SELECT * FROM FormStaticPageFields");
                if (drawForm)
                {

                    string formID = Session["formpage"].ToString();

                    if (int.Parse(formID) < 7)
                    {

                        if (!isCreate)
                        {
                            Image theImage = (Image)FindControl("Image" + formID);
                            theImage.Visible = true;
                        }

                        DataSet ds = doQuery("SELECT NavTitle FROM FormPages WHERE ID=" + formID);
                        DataSet dsForm = doQuery("SELECT * FROM FormStaticPageFields WHERE FormPageID=" + formID);

                        DataSet dsCount = doQuery("SELECT DISTINCT FormPageID FROM FormStaticPageFields");

                        if (int.Parse(formID) < 6)
                        {
                            //ErrorLabel.Text = "got here";
                            ProductName.Text = ds.Tables[0].Rows[0]["NavTitle"].ToString();

                            if (formID == "2")
                            {
                                AllMoneyPanel.DefaultButton = "Button1";

                            }
                            else if(formID == "5")
                            {
                                AllMoneyPanel.DefaultButton = "Button5";
                                StaticFieldsPanel2.DefaultButton = "Button5";

                                BillingHidePanel.DefaultButton = "Button5";
                            }
                        }
                        else if(formID == "6")
                        {
                            ProductName.Text = "Review Order Information";
                        }
                        else if (formID == "7")
                        {
                            ProductName.Visible = false;

                            //Get the invoice
                            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                            Array theTransactions = (Array)client.GetTransactions(Session["UserID"].ToString(), DateTime.Now.AddMinutes(double.Parse("-10.00")), DateTime.Now);

                            //code recommended by john ogle. refer to bug 1688 in OA bug tracking system.
                            Dictionary<string, IEnumerable<Transaction>> invoiceMap = new Dictionary<string, IEnumerable<Transaction>>();
                            List<Transaction> invoices;

                            foreach (Transaction t in theTransactions)
                            {
                                if (t.Type != "SalesOrd")
                                {
                                    invoices = new List<Transaction>();

                                    if (invoiceMap.ContainsKey(t.CreatedFrom))
                                    {
                                        invoices = (List<Transaction>)invoiceMap[t.CreatedFrom];
                                    }
                                    else
                                    {
                                        invoiceMap.Add(t.CreatedFrom, invoices);
                                    }

                                    invoices.Add(t);
                                }
                            }

                            foreach (Transaction oneTrans in theTransactions)
                            {
                                if (oneTrans.Type == "SalesOrd" && oneTrans.OrderNumber == Session["OrderNumber"].ToString())
                                {
                                    SalesOrderHyperLink.NavigateUrl = oneTrans.PrintoutURL;
                                }
                            }
                        }
                        else if (formID == "8")
                        {
                            ProductName.Visible = false;
                        }

                        if (formID == "6")
                        {
                            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();

                            BuildIt(client, client.GetCustomer(Session["UserID"].ToString()));

                        }

                        Panel staticPanel = (Panel)FindControl("StaticFieldsPanel" + formID);
                        staticPanel.Visible = true;

                        if (dsAll.Tables.Count > 0)
                        {
                            for (int i = 0; i < dsAll.Tables[0].Rows.Count; i++)
                            {
                                Label theLabel = (Label)FindControl(dsAll.Tables[0].Rows[i]["LabelFormName"].ToString());
                                message += dsAll.Tables[0].Rows[i]["LabelFormName"].ToString();
                                theLabel.Text = dsAll.Tables[0].Rows[i]["LabelName"].ToString();
                            }
                        }

                        RadComboBoxItem item;

                        RadComboBox countryDrop = new RadComboBox();
                        RadComboBox stateDrop = new RadComboBox();
                        TextBox stateTextB = new TextBox();

                        for (int i = 0; i < dsCount.Tables[0].Rows.Count; i++)
                        {

                            countryDrop = (RadComboBox)FindControl("CountryLabel" + (i + 1).ToString() + "RadComboBox");
                            stateTextB = (TextBox)FindControl("StateLabel" + (i + 1).ToString() + "TextBox");
                            stateDrop = (RadComboBox)FindControl("StateLabel" + (i + 1).ToString() + "RadComboBox");

                            if (countryDrop != null)
                            {
                                message += "fin got here";
                                DataSet dsCountry = doQuery("SELECT * FROM Countries ORDER BY country_2_code asc");
                                countryDrop.Items.Clear();
                                countryDrop.DataSource = dsCountry;
                                countryDrop.DataTextField = "country_name";
                                countryDrop.DataValueField = "country_id";
                                countryDrop.DataBind();
                                //for (int n = 0; n < dsCountry.Tables["table"].Rows.Count; n++)
                                //{
                                //    item = new RadComboBoxItem(dsCountry.Tables["table"].Rows[n]["country_2_code"].ToString(),
                                //        dsCountry.Tables["table"].Rows[n]["country_id"].ToString());
                                //    countryDrop.Items.Add(item);
                                //}
                                dsCountry = doQuery("SELECT * FROM countries where country_name='" + ConfigurationManager.AppSettings.Get("defaultcountry") + "'");
                                countryDrop.SelectedValue = dsCountry.Tables["table"].Rows[0]["country_id"].ToString();

                                DataSet dsState = doQuery("SELECT * FROM states WHERE country_id=" + countryDrop.SelectedValue + " ORDER BY state_name ASC");

                                if (dsState.Tables["table"].Rows.Count > 0)
                                {
                                    stateDrop.Items.Clear();
                                    for (int n = 0; n < dsState.Tables["table"].Rows.Count; n++)
                                    {
                                        item = new RadComboBoxItem(dsState.Tables["table"].Rows[n]["state_name"].ToString(), dsState.Tables["table"].Rows[n]["state_code"].ToString());
                                        stateDrop.Items.Add(item);
                                    }
                                    stateTextB.Visible = false;
                                    stateDrop.Visible = true;
                                    stateDrop.Items.Insert(0, new RadComboBoxItem("Please Select...", "-1"));

                                }
                                else
                                {
                                    stateTextB.Visible = true;
                                    stateDrop.Visible = false;
                                }
                            }
                        }

                    }
                    else
                    {
                        GoToForm(int.Parse(formID), 1);
                    }

                }

                DataView dvHelp = new DataView(dsAll.Tables[0], "hasHelp='True'", "", DataViewRowState.CurrentRows);

                for (int j = 0; j < dvHelp.Count; j++)
                {
                    Panel helpPanel = (Panel)FindControl(dvHelp[j]["LabelFormName"].ToString() + "HelpPanel");
                    CreateHelp(dvHelp[j]["HelpText"].ToString(), j.ToString(), ref helpPanel);
                }

                SetBoxes();
                AddFields();

                if (drawForm)
                {
                    switch (Session["formpage"].ToString())
                    {
                        //case "1":
                        //    FillAccount();
                        //    break;
                        case "1":
                            RoleDropDown.Items.Clear();
                            DataSet ds = doQuery("SELECT * FROM ROLES ORDER BY ID ASC");
                            RadComboBoxItem item = new RadComboBoxItem();
                            item.Text = "Please Select...";
                            item.Value = "-1";
                            RoleDropDown.Items.Add(item);
                            for (int i = 0; i < ds.Tables["table"].Rows.Count; i++)
                            {
                                item = new RadComboBoxItem(ds.Tables["table"].Rows[i]["NAME"].ToString(),
                                    ds.Tables["table"].Rows[i]["NetSuiteID"].ToString());
                                RoleDropDown.Items.Add(item);
                            }

                            ds = new DataSet();
                            AccountDropDown.Items.Clear();
                            ds = doQuery("SELECT * FROM AccountType");
                            item = new RadComboBoxItem();
                            item.Text = "Please Select...";
                            item.Value = "-1";
                            AccountDropDown.Items.Add(item);
                            AccountDropDown.Width = 240;
                            for (int i = 0; i < ds.Tables["table"].Rows.Count; i++)
                            {
                                item = new RadComboBoxItem(ds.Tables["table"].Rows[i]["AccountType"].ToString(),
                                    ds.Tables["table"].Rows[i]["NetSuiteID"].ToString());
                                AccountDropDown.Items.Add(item);
                            }
                            break;
                        case "2":
                            StaticFieldsPanel2.DefaultButton = "Button1";
                            BillingHidePanel.DefaultButton = "Button1";
                            FillBilling();
                            break;
                        case "3":
                            FillShipping();
                            break;
                        case "4":
                            FillDelivery();
                            break;
                        case "5":
                            StaticFieldsPanel2.DefaultButton = "Button5";
                            BillingHidePanel.DefaultButton = "Button5";
                            GoToForm(5, 4);
                            //SetBoxes();
                            //BuildIt();
                            FillPayment();
                            break;
                        case "6":
                            GoToForm(6, 5);
                            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();

                            BuildIt(client, client.GetCustomer(Session["UserID"].ToString()));
                            FillPayment();
                            SetBoxes();
                            break;
                        default: break;
                    }
                }

            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString() + message;
            }

            if (Session["formpage"] == "2")
            {
                if (Session["InShopping"] != null)
                {
                    Button9.Visible = false;
                }
            }
        }
示例#7
0
        protected void SameAs(string copyTo, string copyFrom, bool check)
        {
            string message = "";
            try
            {
                Session["RedrawForm"] = false;

                string prefix = "";
                string temp = copyTo;
                if (temp == "1")
                    temp = "";
                TextBox theEx = (TextBox)FindControl("ex" + temp + "TextBox");

                switch (copyFrom)
                {
                    case "1":
                        prefix = "Account";
                        break;
                    case "2":
                        prefix = "Billing";
                        break;
                    case "3":
                        prefix = "Shipping";
                        break;
                    case "4":
                        prefix = "Delivery";
                        break;
                    default: break;
                }

                if (check)
                {
                    Address address = new Address();
                    if (Session["UserID"] != null)
                    {
                        Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                        Customer cust = client.GetCustomer(Session["UserID"].ToString());

                        for (int i = 0; i < cust.Addresses.Count; i++)
                        {
                            if (copyFrom == "1")
                            {
                                if (cust.Addresses[i].DefaultAccount.Value)
                                {
                                    address = cust.Addresses[i];
                                    break;
                                }
                            }
                            else if (copyFrom == "2")
                            {
                                if (cust.Addresses[i].DefaultBilling.Value)
                                {
                                    address = cust.Addresses[i];
                                    break;
                                }
                                prefix = "Billing";
                            }
                            else if (copyFrom == "3")
                            {
                                if (cust.Addresses[i].DefaultShipping.Value)
                                {
                                    address = cust.Addresses[i];
                                    break;
                                }
                                prefix = "Shipping";
                            }
                            else if (copyFrom == "4")
                            {
                                if (cust.Addresses[i].DefaultDelivery.Value)
                                {
                                    address = cust.Addresses[i];
                                    break;
                                }
                                prefix = "Delivery";
                            }
                        }

                    }

                    if (address != null)
                    {

                        message += "address: " + address.Address1;
                        DataSet dsCopyTo = doQuery("SELECT * FROM FormStaticPageFields WHERE FormPageID=" + copyTo);
                        DataView dvCopyTo = new DataView(dsCopyTo.Tables[0], "", "", DataViewRowState.CurrentRows);

                        //Company
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Company%'";

                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = address.CompanyName;

                        //Attention
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Attention%'";

                            ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text =
                                address.Attention;

                        //Address 1
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Address1%'";
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = address.Address1;

                        //Address 2
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Address2%'";
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = address.Address2;

                        //City
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%City%'";
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = address.City;

                        //Country
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Country%'";
                        DataSet dsCountries = doQuery("SELECT * FROM countries");
                        RadComboBox b = (RadComboBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBox");
                        b.DataSource = dsCountries;
                        b.DataTextField = "country_name";
                        b.DataValueField = "country_id";
                        b.DataBind();

                        message += " Country: ";
                        string str = address.Country + ", " + address.State;
                        message += "country: " + str;
                        DataSet dsC = doQuery("SELECT * FROM Countries WHERE country_2_code = '" + address.Country.ToUpper().Trim() + "'");
                        if (b != null)
                            b.Items.FindItemByText(dsC.Tables[0].Rows[0]["country_name"].ToString()).Selected = true;

                        //State
                        DataSet dsStates = doQuery("SELECT * FROM States S, Countries C WHERE C.country_2_code='" +
                            address.Country + "' AND C.country_id=S.country_id");

                        if (address.Country != "US")
                        {
                            ((Panel)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBoxInternational")).Visible = true;
                            ((Panel)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBoxLocal")).Visible = false;
                            ((Panel)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBoxLocal2")).Visible = false;
                        }
                        else
                        {
                            ((Panel)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBoxInternational")).Visible = false;
                            ((Panel)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBoxLocal")).Visible = true;
                            ((Panel)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBoxLocal2")).Visible = true;
                        }

                        DataView dvStates = new DataView(dsStates.Tables[0], "", "", DataViewRowState.CurrentRows);

                        dvCopyTo.RowFilter = "LabelFormName LIKE '%State%'";

                        RadComboBox theBox = ((RadComboBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBox"));

                        if (dvStates.Count > 0)
                        {
                            theBox.Visible = true;
                            theBox.DataSource = dvStates;
                            theBox.DataTextField = "state_name";
                            theBox.DataValueField = "state_id";
                            theBox.DataBind();

                            theBox.Items.FindItemByText(address.State.Trim()).Selected = true;
                            //((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Visible = false;
                        }
                        else
                        {
                            theBox.Visible = false;
                            ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Visible = true;
                            ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = address.State;
                        }

                        //Zip
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Zip%'";
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = address.Zip;

                        //Phone
                        char[] delim = { 'x' };
                        string[] toks = address.Phone.Split(delim);

                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Phone%'";

                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = address.Phone;

                        if (toks.Length > 0)
                        {
                            if (toks.Length >= 2)
                            {
                                theEx.Text = toks[1];
                            }

                            if (toks.Length >= 1)
                                ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = toks[0];
                        }

                        dvCopyTo.RowFilter = "LabelFormName LIKE '%CompanyLabel%'";
                        CheckBox theCheck = ((CheckBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "CheckBox"));
                        if (theCheck != null)
                        {

                            theCheck.Checked = address.Residential.Value;
                        }

                    }
                    else
                    {
                        DataSet dsCopyFrom = doQuery("SELECT * FROM FormStaticPageFields WHERE FormPageID=" + copyFrom);
                        DataView dvCopyFrom = new DataView(dsCopyFrom.Tables[0], "", "", DataViewRowState.CurrentRows);

                        DataSet dsCopyTo = doQuery("SELECT * FROM FormStaticPageFields WHERE FormPageID=" + copyTo);
                        DataView dvCopyTo = new DataView(dsCopyTo.Tables[0], "", "", DataViewRowState.CurrentRows);

                        //Company
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%Company%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Company%'";

                        TextBox textAddress2 = (TextBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "TextBox");
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = textAddress2.Text;

                        //Attention
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%Attention%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Attention%'";
                        if (dvCopyFrom.Count > 0 && dvCopyTo.Count > 0)
                        {
                            TextBox textAddress12 = (TextBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "TextBox");
                            if (textAddress12 != null)
                                ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = textAddress12.Text;
                        }

                        //Address 1
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%Address1%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Address1%'";
                        TextBox textAddress = (TextBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "TextBox");
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = textAddress.Text;

                        //Address 2
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%Address2%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Address2%'";
                        TextBox textAddress3 = (TextBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "TextBox");
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = textAddress3.Text;

                        //City
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%City%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%City%'";
                        TextBox textAddress4 = (TextBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "TextBox");
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = textAddress4.Text;

                        //State
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%State%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%State%'";
                        TextBox textAddress7 = (TextBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "TextBox");
                        if (textAddress7.Visible)
                            ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = textAddress7.Text;
                        else
                        {
                            RadComboBox textAddress9 = (RadComboBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "RadComboBox");
                            ((RadComboBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBox")).SelectedValue = textAddress9.SelectedValue;
                        }

                        //Country
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%Country%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Country%'";
                        RadComboBox textAddress8 = (RadComboBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "RadComboBox");
                        ((RadComboBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBox")).SelectedValue = textAddress8.SelectedValue;

                        //Zip
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%Zip%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Zip%'";
                        TextBox textAddress5 = (TextBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "TextBox");
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = textAddress5.Text;

                        //Phone
                        dvCopyFrom.RowFilter = "LabelFormName LIKE '%Phone%'";
                        dvCopyTo.RowFilter = "LabelFormName LIKE '%Phone%'";
                        TextBox textAddress6 = (TextBox)FindControl(dvCopyFrom[0]["LabelFormName"].ToString() + "TextBox");
                        ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = textAddress6.Text;
                    }
                }
                else
                {
                    DataSet dsCopyTo = doQuery("SELECT * FROM FormStaticPageFields WHERE FormPageID=" + copyTo);
                    DataView dvCopyTo = new DataView(dsCopyTo.Tables[0], "", "", DataViewRowState.CurrentRows);

                    //Company
                    dvCopyTo.RowFilter = "LabelFormName LIKE '%Company%'";
                    ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = "";

                    //Address 1
                    dvCopyTo.RowFilter = "LabelFormName LIKE '%Address1%'";
                    ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = "";

                    //Address 2
                    dvCopyTo.RowFilter = "LabelFormName LIKE '%Address2%'";
                    ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = "";

                    //City
                    dvCopyTo.RowFilter = "LabelFormName LIKE '%City%'";
                    ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = "";

                    //State
                    dvCopyTo.RowFilter = "LabelFormName LIKE '%State%'";
                    ((RadComboBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBox")).SelectedIndex = -1;

                    //Country
                    dvCopyTo.RowFilter = "LabelFormName LIKE '%Country%'";
                    ((RadComboBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "RadComboBox")).SelectedValue = "223";

                    //Zip
                    dvCopyTo.RowFilter = "LabelFormName LIKE '%Zip%'";
                    ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = "";

                    //Phone
                    dvCopyTo.RowFilter = "LabelFormName LIKE '%Phone%'";
                    ((TextBox)FindControl(dvCopyTo[0]["LabelFormName"].ToString() + "TextBox")).Text = "";
                }
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = message + ex.ToString();
            }
        }
示例#8
0
        protected void GoToForm(int formID, int disappearID)
        {
            SamesAsCheckBox32.Checked = false;
            SameAsLabel4CheckBox.Checked = false;
            SameAsBillingLabel4CheckBox.Checked = false;
            SameAsShippingLabel4CheckBox.Checked = false;

            SamesAsCheckBox3.Checked = false;
            SamesAsCheckBox32.Checked = false;
            SameAsLabel4CheckBox.Checked = false;
            SameAsBillingLabel4CheckBox.Checked = false;
            SameAsShippingLabel4CheckBox.Checked = false;

            if (Session["UserID"] != null)
            {
                if (IsUserInternational())
                {
                    formID = 9;
                }
                else
                {
                    Panel staticPanel3 = (Panel)FindControl("StaticFieldsPanel9");
                    staticPanel3.Visible = false;
                }

                    Panel staticPanel = (Panel)FindControl("StaticFieldsPanel" + disappearID.ToString());
                    staticPanel.Visible = false;

                    Panel staticPanel2 = (Panel)FindControl("StaticFieldsPanel" + (formID).ToString());
                    staticPanel2.Visible = true;

                    Image1.Visible = false;
                    Image2.Visible = false;
                    Image3.Visible = false;
                    Image4.Visible = false;
                    Image5.Visible = false;
                    Image6.Visible = false;

                    if (formID < 7)
                    {
                        Image theImage = (Image)FindControl("Image" + formID);
                        theImage.Visible = true;

                    }

                    if (formID == 5)
                    {
                        StaticFieldsPanel2.Visible = true;
                        BillingForPaymentPanel.Visible = true;
                        BillingHidePanel.Visible = false;
                        BillingHidePanel2.Visible = false;

                        PaymentButtonsPanel.Visible = true;

                        AllMoneyPanel.DefaultButton = "Button5";

                    }
                    else if (formID == 1)
                    {
                        RoleDropDown.Items.Clear();
                        DataSet ds3 = doQuery("SELECT * FROM ROLES ORDER BY ID ASC");
                        RadComboBoxItem item = new RadComboBoxItem();
                        item.Text = "Please Select...";
                        item.Value = "-1";
                        RoleDropDown.Items.Add(item);
                        for (int i = 0; i < ds3.Tables["table"].Rows.Count; i++)
                        {
                            item = new RadComboBoxItem(ds3.Tables["table"].Rows[i]["NAME"].ToString(),
                                ds3.Tables["table"].Rows[i]["NetSuiteID"].ToString());
                            RoleDropDown.Items.Add(item);
                        }

                        ds3 = new DataSet();
                        AccountDropDown.Items.Clear();
                        ds3 = doQuery("SELECT * FROM AccountType");
                        item = new RadComboBoxItem();
                        item.Text = "Please Select...";
                        item.Value = "-1";
                        AccountDropDown.Items.Add(item);
                        AccountDropDown.Width = 240;
                        for (int i = 0; i < ds3.Tables["table"].Rows.Count; i++)
                        {
                            item = new RadComboBoxItem(ds3.Tables["table"].Rows[i]["AccountType"].ToString(),
                                ds3.Tables["table"].Rows[i]["NetSuiteID"].ToString());
                            AccountDropDown.Items.Add(item);
                        }
                    }
                    else if (formID == 7)
                    {
                        ProductName.Visible = false;

                        HttpContext.Current.Trace.Warn("FormPage_DrawForm()", string.Format("{0},{1},{2}",
                              DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              "info",
                              "---Draw Review get transactions for invoice Begin------"));
                        //Get the invoice
                        Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                        Array theTransactions = (Array)client.GetTransactions(Session["UserID"].ToString(), DateTime.Now.AddMinutes(double.Parse("-10.00")), DateTime.Now);

                        //code recommended by john ogle. refer to bug 1688 in OA bug tracking system.
                        Dictionary<string, IEnumerable<Transaction>> invoiceMap = new Dictionary<string, IEnumerable<Transaction>>();
                        List<Transaction> invoices;

                        foreach (Transaction t in theTransactions)
                        {
                            if (t.Type != "SalesOrd")
                            {
                                invoices = new List<Transaction>();

                                if (invoiceMap.ContainsKey(t.CreatedFrom))
                                {
                                    invoices = (List<Transaction>)invoiceMap[t.CreatedFrom];
                                }
                                else
                                {
                                    invoiceMap.Add(t.CreatedFrom, invoices);
                                }

                                invoices.Add(t);
                            }
                        }

                        foreach (Transaction oneTrans in theTransactions)
                        {
                            if (oneTrans.Type == "SalesOrd" && oneTrans.OrderNumber == Session["OrderNumber"].ToString())
                            {
                                SalesOrderHyperLink.NavigateUrl = oneTrans.PrintoutURL;
                            }
                        }

                        HttpContext.Current.Trace.Warn("FormPage_DrawForm()", string.Format("{0},{1},{2}",
                              DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              "info",
                              "---Draw Review get transactions for invoice End------"));
                    }
                    else if (formID == 8)
                    {
                        ProductName.Visible = false;
                    }
                    else if (formID == 2)
                    {
                        StaticFieldsPanel2.Visible = true;
                        BillingForPaymentPanel.Visible = true;
                        BillingHidePanel.Visible = true;
                        BillingHidePanel2.Visible = true;

                        PaymentButtonsPanel.Visible = false;

                        AllMoneyPanel.DefaultButton = "Button1";

                    }
                    else
                    {
                        StaticFieldsPanel2.Visible = false;
                        BillingForPaymentPanel.Visible = false;
                        BillingHidePanel.Visible = true;
                        BillingHidePanel2.Visible = true;

                        PaymentButtonsPanel.Visible = false;
                    }

                    DataSet ds = doQuery("SELECT NavTitle FROM FormPages WHERE ID=" + formID.ToString());

                    Session["formpage"] = formID.ToString();

                    if (ds.Tables.Count > 0)
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            ProductName.Text = ds.Tables[0].Rows[0]["NavTitle"].ToString();

                        }
                        else
                        {
                            if (formID == 6)
                                ProductName.Text = "Review Order Information";
                            else if (formID == 7)
                                ProductName.Visible = false;
                            else if (formID == 8)
                            {
                                ProductName.Visible = false;
                            }
                        }
                    else
                    {
                        if (formID == 6)
                            ProductName.Text = "Review Order Information";
                        else if (formID == 7)
                            ProductName.Visible = false;
                        else if (formID == 8)
                        {
                            ProductName.Visible = false;
                        }
                    }

            }
            else
            {
                Response.Redirect("~/UserLogin.aspx");
            }
        }
示例#9
0
        protected void NextClick(object sender, EventArgs e)
        {
            if (Session["AccountCreateType"] == null)
                Session["AccountCreateType"] = "Create";

            bool isCreate = false;
            bool isShoppingCreate = false;

            if (Session["AccountCreateType"] == "Create")
                isCreate = true;

            if (Session["ShoppingCreate"] != null)
                isShoppingCreate = bool.Parse(Session["ShoppingCreate"].ToString());
            Encryption encrypt = new Encryption();
            bool openMessage = false;
            string boxMessage = "";
            bool success = false;
            if (Session["HasUserBeenClicked"] == null)
            {

                try
                {

                    Session["RedrawForm"] = false;
                    string state = "";
                    bool isStateValid = false;

                    if (StateLabel1RadComboBox.Visible)
                    {
                        if (StateLabel1RadComboBox.SelectedValue != "-1")
                            isStateValid = true;
                    }
                    else if (StateLabel1TextBox.Text.Trim() != "")
                        isStateValid = true;

                    if (isStateValid)
                    {
                        if (Page.IsValid && RoleDropDown.SelectedValue != "-1" &&
                            AccountDropDown.SelectedValue != "-1")
                        {

                            Session["FormClicked"] = true;
                            Session["formpage"] = "2";
                            bool hasState = false;

                            if (StateLabel1RadComboBox.Visible)
                            {
                                if (StateLabel1RadComboBox.SelectedValue != "-1")
                                    hasState = true;
                            }
                            else if (StateLabel1TextBox.Text.Trim() != "")
                                hasState = true;

                            string isPassValid = IsPasswordValid();

                            if (hasState)
                            {
                                if (isPassValid == "success")
                                {
                                    Session["AccountTypeLabel"] = AccountDropDown.SelectedItem.Value;

                                    Session["AccountFirstNameLabel"] = FirstNameTextBox.Text;

                                    Session["AccountLastNameLabel"] = LastNameTextBox.Text;

                                    Session["AccountRoleLabel"] = RoleDropDown.SelectedItem.Text;

                                    Session["AccountTitleLabel"] = TitleTextBox.Text;

                                    Session["AccountCompanyLabel"] = CompanyLabelTextBox.Text;

                                    Session["AccountResidentialLabel"] = ResidentialCheckBox.Checked;

                                    if (StateLabel1RadComboBox.Visible)
                                        state = StateLabel1RadComboBox.SelectedItem.Text;
                                    else
                                        state = StateLabel1TextBox.Text;

                                    Session["AccountStateLabel"] = state;

                                    Session["AccountCityLabel"] = CityLabelTextBox.Text;

                                    Session["AccountPhoneLabel"] = PhoneLabelTextBox.Text;

                                    if (exTextBox.Text.Trim() != "")
                                    {
                                        Session["AccountEx"] = exTextBox.Text;
                                    }

                                    Session["AccountAddressLabel"] = Address1LabelTextBox.Text;

                                    Session["AccountAddress2Label"] = Address2LabelTextBox.Text;

                                    Session["AccountZipLabel"] = ZipLabelTextBox.Text;

                                    Session["AccountCountryLabel"] = CountryLabel1RadComboBox.SelectedValue;

                                    Session["AccountEmailLabel"] = EmailTextBox.Text;

                                    Session["AccountPasswordLabel"] = PasswordTextBox.Text;

                                    Session["AccountNewsletterLabel"] = SignUpCheckBox.Checked;

                                    if (isCreate)
                                    {
                                        bool isError = false;
                                        try
                                        {
                                            success = CreateUser();

                                            if (success)
                                            {
                                                string redir ="/MyAccount.aspx";
                                                if (Request.QueryString["page"] != null && Request.QueryString["page"].Length > 0)
                                                {
                                                    //lblMessage.Text = "Got here 1";
                                                    redir = "../"+Request.QueryString["page"].Replace("%20", "+").Replace(" ", "+");
                                                }

                                                boxMessage = "Your account has been created. " +
                                                    "<br/><br/><button onclick=\"Search('" + redir + "');\" >OK</button><br/>";
                                                openMessage = true;

                                                JobRoles rolesJob = GetJobRole(RoleDropDown.SelectedItem.Text);

                                                if (rolesJob == JobRoles.Reseller_Contractor_Integrator)
                                                {
                                                    boxMessage = "Your account has been created. Since your account type is 'Reseller', please remember that you can contact your representative for better pricing." +
                                                        "<br/><br/><button onclick=\"Search('" + redir + "');\" >OK</button><br/>";
                                                    openMessage = true;
                                                }

                                                Session["HasUserBeenClicked"] = "true";
                                            }
                                        }
                                        catch (CommandErrorException ex)
                                        {
                                            isError = true;
                                            if (ex.ErrorCode.ToString().ToLower() == "invalid_duplicatecustomer")
                                            {
                                                Static1Messages.Text = "A user already exists for this email address. Please choose a different email.";
                                            }
                                            else
                                            {
                                                Static1Messages.Text = ex.ToString();
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            isError = true;
                                            Static1Messages.Text = ex.ToString();
                                        }

                                    }
                                    else
                                    {
                                        try
                                        {
                                            if (isShoppingCreate)
                                            {

                                                success = CreateUser();

                                                //string redir = "/MyAccount.aspx";
                                                //if (Request.QueryString["page"] != null && Request.QueryString["page"].Length > 0)
                                                //{
                                                //    //lblMessage.Text = "Got here 1";
                                                //    redir = Request.QueryString["page"].Replace("%20", "+").Replace(" ", "+");
                                                //}
                                                if (success && Session["AccountBackClicked"] == null)
                                                {
                                                    Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                                                    Customer cust = client.GetCustomer(Session["UserID"].ToString());

                                                    boxMessage = "Your account has been created. " +
                                                            "<br/><br/><button onclick=\"Search('/default.aspx?a=form&ID=2');\" >OK</button><br/>";
                                                    openMessage = true;

                                                    if (IsUserInternational())
                                                    {
                                                        boxMessage = "Your account has been created. At this time we do not provide international sales. To purchase a product, please contact your representative." +
                                                            "<br/><br/><button onclick=\"Search('/MyAccount.aspx');\" >OK</button><br/>";
                                                        openMessage = true;
                                                    }

                                                    JobRoles rolesJob = GetJobRole(RoleDropDown.SelectedItem.Text);

                                                    if (rolesJob == JobRoles.Reseller_Contractor_Integrator)
                                                    {
                                                        boxMessage = "Your account has been created. Since your account type is 'Reseller', please remember that you can contact your representative for better pricing." +
                                                            "<br/><br/><button onclick=\"Search('/default.aspx?a=form&ID=2');\" >OK</button><br/>";
                                                        openMessage = true;
                                                    }

                                                }
                                                else
                                                {
                                                    openMessage = false;
                                                }
                                            }

                                            if (!openMessage && success)
                                            {
                                                if (CountryLabel1RadComboBox.SelectedItem.Value != "223")
                                                {
                                                    Session["RedrawForm"] = true;
                                                    Session["formpage"] = "9";
                                                    GoToForm(9, 1);
                                                }
                                                else
                                                {
                                                    Session["RedrawForm"] = true;
                                                    GoToForm(2, 1);

                                                    Session["formpage"] = "2";
                                                }

                                            }
                                        }
                                        catch (CommandErrorException ex)
                                        {
                                            Session["formpage"] = "1";
                                            if (ex.ErrorCode.ToString().ToLower() == "invalid_duplicatecustomer")
                                            {
                                                Static1Messages.Text = "A user already exists for this email address. Please choose a different email.";
                                            }
                                            else
                                            {
                                                Static1Messages.Text = ex.ToString();
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            Session["formpage"] = "1";
                                            Static1Messages.Text = ex.ToString();
                                        }
                                    }

                                    if (openMessage && success)
                                    {
                                        MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt(boxMessage);
                                        MessageRadWindow.Visible = true;
                                        MessageRadWindowManager.VisibleOnPageLoad = true;
                                    }

                                }
                                else
                                {
                                    Static1Messages.Text = isPassValid;
                                }
                            }
                            else
                            {
                                Static1Messages.Text = "State is required";
                            }
                        }
                        else
                        {
                            Static1Messages.Text = "Both Role and Account Type are required.";
                        }
                    }
                    else
                    {
                        Static1Messages.Text = "State is required";
                    }
                }
                catch (CommandErrorException ex)
                {
                    if (ex.ToString().Contains("for the following field:"))
                    {
                        ErrorLabel.Text = " The Phone is invalid.";
                    }
                    else
                    {
                        ErrorLabel.Text = ex.Message.ToString();
                    }
                }
                catch (Exception ex)
                {
                    Session["formpage"] = "1";
                    ErrorLabel.Text = ex.ToString();
                }
            }
            else
            {
                if (isCreate)
                {

                    string redir = "/MyAccount.aspx";
                    if (Request.QueryString["page"] != null && Request.QueryString["page"].Length > 0)
                    {
                        //lblMessage.Text = "Got here 1";
                        redir = "../"+Request.QueryString["page"].Replace("%20", "+").Replace(" ", "+");
                    }

                    boxMessage = "Your account has been created. " +
                        "<br/><br/><button onclick=\"Search('" + redir + "');\" >OK</button><br/>";
                    openMessage = true;

                    if (AccountDropDown.SelectedValue == "4")
                    {
                        boxMessage = "Your account has been created. Since your account type is 'Reseller', please remember that you can contact your representative for better pricing." +
                            "<br/><br/><button onclick=\"Search('" + redir + "');\" >OK</button><br/>";
                        openMessage = true;
                    }
                }
                else
                {
                    if (isShoppingCreate)
                    {

                        //string redir = "/MyAccount.aspx";
                        //if (Request.QueryString["page"] != null && Request.QueryString["page"].Length > 0)
                        //{
                        //    //lblMessage.Text = "Got here 1";
                        //    redir = Request.QueryString["page"].Replace("%20", "+").Replace(" ", "+");
                        //}
                        if (Session["AccountBackClicked"] == null)
                        {
                            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                            Customer cust = client.GetCustomer(Session["UserID"].ToString());

                            boxMessage = "Your account has been created. " + cust.SalesRepID +
                                    "<br/><br/><button onclick=\"Search('/default.aspx?a=form&ID=2');\" >OK</button><br/>";
                            openMessage = true;

                            if (IsUserInternational())
                            {
                                boxMessage = "Your account has been created. At this time we do not provide international sales. To purchase a product, please contact your representative." +
                                    "<br/><br/><button onclick=\"Search('/MyAccount.aspx');\" >OK</button><br/>";
                                openMessage = true;
                            }

                            if (AccountDropDown.SelectedValue == "4")
                            {
                                boxMessage = "Your account has been created. Since your account type is 'Reseller', please remember that you can contact your representative for better pricing." +
                                    "<br/><br/><button onclick=\"Search('/default.aspx?a=form&ID=2');\" >OK</button><br/>";
                                openMessage = true;
                            }

                        }
                    }
                    if (!openMessage)
                    {
                        if (CountryLabel1RadComboBox.SelectedItem.Value != "223")
                        {
                            Session["RedrawForm"] = true;
                            Session["formpage"] = "9";
                            GoToForm(9, 1);
                        }
                        else
                        {
                            Session["RedrawForm"] = true;
                            GoToForm(2, 1);

                            Session["formpage"] = "2";
                        }

                        Session["HasUserBeenClicked"] = "true";

                    }

                }

                if (openMessage)
                {
                    MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt(boxMessage);
                    MessageRadWindow.Visible = true;
                    MessageRadWindowManager.VisibleOnPageLoad = true;
                }
            }
        }
示例#10
0
        protected void FillCheckOutBilling(Customer cust)
        {
            if (Session["UserID"] != null)
            {
                HttpContext.Current.Trace.Warn("FormPage_FillCheckOutBilling()", string.Format("{0},{1},{2}",
                              DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              "info",
                              "---Check out Begin------"));
                Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();

                List<Address> addresses = cust.Addresses;

                Address address = new Address();

                for (int i = 0; i < addresses.Count; i++)
                {
                    if (addresses[i].DefaultBilling.Value)
                    {
                        address = addresses[i];
                    }
                }

                BillingAddressLabel.Text = address.Address1;
                BillingAddress2Label.Text = address.Address2;
                BillingNameLabel.Text = address.Attention;

                BillingCompanyLabel.Text = address.CompanyName;

                BillingStateLabel.Text = address.City + ", " + address.State + " " + address.Zip;

                BillingPhoneLabel.Text = address.Phone;

            }
        }
示例#11
0
        protected void FillShipping()
        {
            SamesAsCheckBox3.Checked = false;
            SamesAsCheckBox32.Checked = false;

            if (Session["UserID"] != null)
            {
                Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                Customer cust = client.GetCustomer(Session["UserID"].ToString());

                List<Address> addresses = cust.Addresses;

                Address billingAddress = new Address();

                bool addressFound = false;

                for (int i = 0; i < addresses.Count; i++)
                {
                    if (addresses[i].DefaultShipping.Value)
                    {
                        billingAddress = addresses[i];
                        addressFound = true;
                        break;
                    }
                }

                if (addressFound)
                {
                    CompanyLabel3TextBox.Text = billingAddress.CompanyName;
                    DataSet dsCount = doQuery("SELECT * FROM Countries WHERE country_2_code = '" +
                        billingAddress.Country + "'");
                    CountryLabel3RadComboBox.Items.FindItemByText(dsCount.Tables[0].Rows[0]["country_name"].ToString()).Selected = true;

                    DataSet dsStates = doQuery("SELECT * FROM States WHERE country_id=" + CountryLabel3RadComboBox.SelectedValue);

                    bool isTextState = true;
                    if (dsStates.Tables.Count > 0)
                        if (dsStates.Tables[0].Rows.Count > 0)
                        {
                            StateLabel3RadComboBox.Items.Clear();
                            isTextState = false;
                            StateLabel3RadComboBox.DataSource = dsStates;
                            StateLabel3RadComboBox.DataTextField = "state_name";
                            StateLabel3RadComboBox.DataValueField = "state_id";
                            StateLabel3RadComboBox.DataBind();

                            StateLabel3RadComboBox.Items.FindItemByText(
                                    billingAddress.State).Selected = true;
                        }

                    if (isTextState)
                    {
                        StateLabel3TextBox.Text = billingAddress.State;
                    }

                    CityLabel3TextBox.Text = billingAddress.City;

                    char[] delim = { 'x' };
                    string[] tokensP = billingAddress.Phone.Split(delim);

                    if (tokensP.Length > 0)
                    {

                        if (tokensP.Length >= 1)
                        {
                            PhoneLabel3TextBox.Text = tokensP[0].Trim();
                        }

                        if (tokensP.Length >= 2)
                        {
                            ex3TextBox.Text = tokensP[1];
                        }
                    }

                    AttentionLabel2TextBox.Text = billingAddress.Attention;

                    Address1Label3TextBox.Text = billingAddress.Address1;

                    Address2Label3TextBox.Text = billingAddress.Address2;

                    ZipLabel3TextBox.Text = billingAddress.Zip;

                }
                else
                {
                    //if (Session["ShippingCompanyLabel"] != null)
                    CompanyLabel3TextBox.Text = "";

                    //if (Session["ShippingResidentialLabel"] != null)
                    ResidentialCheckBox3.Checked = false;

                    //if (Session["ShippingCountryLabel"] != null)
                    CountryLabel3RadComboBox.SelectedValue = "";

                    DataSet dsStates = doQuery("SELECT * FROM States WHERE country_id=" + CountryLabel3RadComboBox.SelectedValue);

                    bool isTextState = true;
                    if (dsStates.Tables.Count > 0)
                        if (dsStates.Tables[0].Rows.Count > 0)
                        {
                            StateLabel3RadComboBox.Items.Clear();
                            isTextState = false;
                            StateLabel3RadComboBox.DataSource = dsStates;
                            StateLabel3RadComboBox.DataTextField = "state_name";
                            StateLabel3RadComboBox.DataValueField = "state_id";
                            StateLabel3RadComboBox.DataBind();

                            if (Session["ShippingStateLabel"] != null)
                                StateLabel3RadComboBox.Items.FindItemByText(Session["ShippingStateLabel"].ToString()).Selected = true;
                        }

                    if (isTextState)
                    {
                        //if (Session["ShippingStateLabel"] != null)
                        StateLabel3TextBox.Text = "";
                    }

                    //if (Session["ShippingCityLabel"] != null)
                    CityLabel3TextBox.Text = "";

                    //if (Session["ShippingPhoneLabel"] != null)
                    PhoneLabel3TextBox.Text = "";

                    //if (Session["ShippingEx"] != null)
                    ex3TextBox.Text = "";

                    //if (Session["ShippingAttentionLabel"] != null)
                    AttentionLabel2TextBox.Text = "";

                    //if (Session["ShippingAddress2Label"] != null)
                    Address2Label3TextBox.Text = "";

                    //if (Session["ShippingZipLabel"] != null)
                    ZipLabel3TextBox.Text = "";

                    //if (Session["ShippingAddressLabel"] != null)
                    Address1Label3TextBox.Text = "";
                }
            }
            else
            {
               //if (Session["ShippingCompanyLabel"] != null)
                    CompanyLabel3TextBox.Text = "";

                //if (Session["ShippingResidentialLabel"] != null)
                    ResidentialCheckBox3.Checked = false;

                //if (Session["ShippingCountryLabel"] != null)
                    CountryLabel3RadComboBox.SelectedValue = "";

                DataSet dsStates = doQuery("SELECT * FROM States WHERE country_id=" + CountryLabel3RadComboBox.SelectedValue);

                bool isTextState = true;
                if (dsStates.Tables.Count > 0)
                    if (dsStates.Tables[0].Rows.Count > 0)
                    {
                        StateLabel3RadComboBox.Items.Clear();
                        isTextState = false;
                        StateLabel3RadComboBox.DataSource = dsStates;
                        StateLabel3RadComboBox.DataTextField = "state_name";
                        StateLabel3RadComboBox.DataValueField = "state_id";
                        StateLabel3RadComboBox.DataBind();

                        if (Session["ShippingStateLabel"] != null)
                            StateLabel3RadComboBox.Items.FindItemByText(Session["ShippingStateLabel"].ToString()).Selected = true;
                    }

                if (isTextState)
                {
                    //if (Session["ShippingStateLabel"] != null)
                        StateLabel3TextBox.Text = "";
                }

                //if (Session["ShippingCityLabel"] != null)
                    CityLabel3TextBox.Text = "";

                //if (Session["ShippingPhoneLabel"] != null)
                    PhoneLabel3TextBox.Text = "";

                //if (Session["ShippingEx"] != null)
                    ex3TextBox.Text = "";

                //if (Session["ShippingAttentionLabel"] != null)
                    AttentionLabel2TextBox.Text = "";

                //if (Session["ShippingAddress2Label"] != null)
                    Address2Label3TextBox.Text = "";

                //if (Session["ShippingZipLabel"] != null)
                    ZipLabel3TextBox.Text = "";

                //if (Session["ShippingAddressLabel"] != null)
                    Address1Label3TextBox.Text = "";

            }

            SetDynamicFields("3");
        }
示例#12
0
        protected void FillBilling()
        {
            string message ="";
            try
            {
                if (Session["UserID"] != null)
                {
                    Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                    Customer cust = client.GetCustomer(Session["UserID"].ToString());

                    List<Address> addresses = cust.Addresses;

                    Address billingAddress = new Address();

                    bool billingFound = false;

                    for (int i = 0; i < addresses.Count; i++)
                    {
                        if (addresses[i].DefaultBilling.Value)
                        {
                            billingAddress = addresses[i];
                            billingFound = true;
                            break;
                        }
                    }

                    if (billingFound)
                    {
                        CompanyLabel2TextBox.Text = billingAddress.CompanyName;
                        message += billingAddress.Country;

                        DataSet dsCount = doQuery("SELECT * FROM Countries WHERE country_2_code = '" +
                            billingAddress.Country + "'");
                        CountryLabel2RadComboBox.Items.FindItemByText(dsCount.Tables[0].Rows[0]["country_name"].ToString()).Selected = true;

                        DataSet dsStates = doQuery("SELECT * FROM States WHERE country_id=" +
                            CountryLabel2RadComboBox.SelectedValue);

                        bool isTextState = true;
                        if (dsStates.Tables.Count > 0)
                            if (dsStates.Tables[0].Rows.Count > 0)
                            {
                                StateLabel2RadComboBox.Items.Clear();
                                isTextState = false;
                                StateLabel2RadComboBox.DataSource = dsStates;
                                StateLabel2RadComboBox.DataTextField = "state_name";
                                StateLabel2RadComboBox.DataValueField = "state_id";
                                StateLabel2RadComboBox.DataBind();

                                StateLabel2RadComboBox.Items.FindItemByText(
                                        billingAddress.State).Selected = true;
                            }

                        if (isTextState)
                        {
                            StateLabel2TextBox.Text = billingAddress.State;
                        }

                        CityLabel2TextBox.Text = billingAddress.City;

                        char[] delim = { 'x' };
                        string[] tokensP = billingAddress.Phone.Split(delim);

                        if (tokensP.Length > 0)
                        {

                            if (tokensP.Length >= 1)
                            {
                                PhoneLabel2TextBox.Text = tokensP[0].Trim();
                            }

                            if (tokensP.Length >= 2)
                            {
                                ex2TextBox.Text = tokensP[1];
                            }

                        }

                        AttentionLabel1TextBox.Text = billingAddress.Attention;

                        Address1Label2TextBox.Text = billingAddress.Address1;

                        Address2Label2TextBox.Text = billingAddress.Address2;

                        ZipLabel2TextBox.Text = billingAddress.Zip;

                    }
                }
                else
                {
                    if (Session["BillingNameLabel"] != null)
                        CreditCardNameLabelTextBox.Text = Session["BillingNameLabel"].ToString();

                    if (Session["BillingCompanyLabel"] != null)
                        CompanyLabel2TextBox.Text = Session["BillingCompanyLabel"].ToString();

                    if (Session["BillingCountryLabel"] != null)
                        CountryLabel2RadComboBox.SelectedValue = Session["BillingCountryLabel"].ToString();

                    DataSet dsStates = doQuery("SELECT * FROM States WHERE country_id=" + CountryLabel2RadComboBox.SelectedValue);

                    bool isTextState = true;
                    if (dsStates.Tables.Count > 0)
                        if (dsStates.Tables[0].Rows.Count > 0)
                        {
                            StateLabel2RadComboBox.Items.Clear();
                            isTextState = false;
                            StateLabel2RadComboBox.DataSource = dsStates;
                            StateLabel2RadComboBox.DataTextField = "state_name";
                            StateLabel2RadComboBox.DataValueField = "state_id";
                            StateLabel2RadComboBox.DataBind();

                            if (Session["BillingStateLabel"] != null)
                                StateLabel2RadComboBox.Items.FindItemByText(Session["BillingStateLabel"].ToString()).Selected = true;
                        }

                    if (isTextState)
                    {
                        if (Session["BillingStateLabel"] != null)
                            StateLabel2TextBox.Text = Session["BillingStateLabel"].ToString();
                    }

                    if (Session["BillingCityLabel"] != null)
                        CityLabel2TextBox.Text = Session["BillingCityLabel"].ToString();

                    if (Session["BillingPhoneLabel"] != null)
                        PhoneLabel2TextBox.Text = Session["BillingPhoneLabel"].ToString();

                    if (Session["BillingEx"] != null)
                        ex2TextBox.Text = Session["BillingEx"].ToString();

                    if (Session["BillingAttentionLabel"] != null)
                        AttentionLabel1TextBox.Text = Session["BillingAttentionLabel"].ToString();

                    if (Session["BillingAddressLabel"] != null)
                        Address1Label2TextBox.Text = Session["BillingAddressLabel"].ToString();

                    if (Session["BillingAddress2Label"] != null)
                        Address2Label2TextBox.Text = Session["BillingAddress2Label"].ToString();

                    if (Session["BillingZipLabel"] != null)
                        ZipLabel2TextBox.Text = Session["BillingZipLabel"].ToString();
                }

                SetDynamicFields("2");
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString() + message;
            }
        }
示例#13
0
        protected void FillAccount()
        {
            try
            {
                DataSet ds;

                if (Session["UserID"] != null)
                {
                    Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                    Customer cust = client.GetCustomer(Session["UserID"].ToString());

                        FirstNameTextBox.Text = cust.FirstName;

                        LastNameTextBox.Text = cust.LastName;

                        AccountDropDown.Items.FindItemByText(GetPriceLevelText(cust.CustomerType)).Selected = true;

                        RoleDropDown.Items.FindItemByText(GetJobRoleText(cust.JobRole)).Selected = true;

                        TitleTextBox.Text = cust.Title;

                        CompanyLabelTextBox.Text = cust.CompanyName;

                        Address address = new Address();

                        foreach (Address adr in cust.Addresses)
                        {
                            if (adr.DefaultAccount.Value)
                            {
                                address = adr;
                            }
                        }

                        ResidentialCheckBox.Checked = address.Residential.Value;

                        string country_id = doQuery("SELECT * FROM Countries WHERE country_2_code='" + address.Country + "'").Tables[0].Rows[0]["country_id"].ToString();

                        DataSet dsStates = doQuery("SELECT * FROM States WHERE country_id='" + country_id + "'");

                    bool isTextState = true;
                    if (dsStates.Tables.Count > 0)
                        if (dsStates.Tables[0].Rows.Count > 0)
                        {
                            StateLabel1RadComboBox.Items.Clear();
                            isTextState = false;
                            StateLabel1RadComboBox.DataSource = dsStates;
                            StateLabel1RadComboBox.DataTextField = "state_name";
                            StateLabel1RadComboBox.DataValueField = "state_id";
                            StateLabel1RadComboBox.DataBind();

                            if (Session["AccountStateLabel"] != null)
                                StateLabel1RadComboBox.Items.FindItemByText(address.State).Selected = true;
                        }

                    if (isTextState)
                    {
                            StateLabel1TextBox.Text = address.State;
                    }

                    CityLabelTextBox.Text = address.City;

                    char[] delim = { 'x' };
                    string[] tokens = cust.Phone.Split(delim);
                    PhoneLabelTextBox.Text = tokens[0];

                    if (tokens.Length > 1)
                        exTextBox.Text = tokens[1];

                    Address1LabelTextBox.Text = address.Address1;

                    Address2LabelTextBox.Text = address.Address2;

                    ZipLabelTextBox.Text = address.Zip;

                    EmailTextBox.Text = cust.Email;

                    PasswordTextBox.Text = cust.Password;
                    cPasswordTextBox.Text = cust.Password;

                    SetDynamicFields("1");
                }
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }
        }
示例#14
0
        protected bool CreateUser()
        {
            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();

                //AccountDropDown.SelectedItem.Value;
                string company = CompanyLabelTextBox.Text;
                if (company == "")
                    company = null;

                PriceLevels thelevel = PriceLevels.Educational;
                switch (AccountDropDown.SelectedItem.Value)
                {
                    case "1":
                        thelevel = PriceLevels.MSRP;
                        break;
                    case "2":
                        thelevel = PriceLevels.Educational;
                        break;
                    case "3":
                        thelevel = PriceLevels.State;
                        break;
                    default: break;
                }
                try
                {
                    CreateCustomerResult newCustomer = new CreateCustomerResult();
                    if (Session["UserID"] == null)
                        newCustomer = client.CreateCustomer(company, PhoneLabelTextBox.Text, EmailTextBox.Text
                        , FirstNameTextBox.Text, LastNameTextBox.Text, thelevel, TitleTextBox.Text, null);

                    bool EmailChanged = false;

                    if (newCustomer != null || Session["UserID"] != null)
                    {

                        // retrive the newly created customer so we can update it with an address and password

                        string customerID = "";

                        if (Session["UserID"] != null)
                            customerID = Session["UserID"].ToString();
                        else
                            customerID = newCustomer.CustomerInternalID;

                        Customer customer = client.GetCustomer(customerID);

                        if (Session["UserID"] != null)
                        {
                            if(customer.Email != EmailTextBox.Text)
                                EmailChanged = true;
                            customer.Email = EmailTextBox.Text;
                            customer.CompanyName = company;
                            customer.Phone = PhoneLabelTextBox.Text;
                            customer.FirstName = FirstNameTextBox.Text;
                            customer.LastName = LastNameTextBox.Text;
                            customer.CustomerType = thelevel;
                            customer.Title = TitleTextBox.Text;
                        }

                        customer.JobRole = GetJobRole(RoleDropDown.SelectedItem.Text);

                        // assign at least one address
                        string state = "";
                        if (StateLabel1RadComboBox.Visible)
                            state = StateLabel1RadComboBox.SelectedItem.Text;
                        else
                            state = StateLabel1TextBox.Text;

                        //create primary address: this is no loger being done by Andrew/John request: bug 2387
                        //Address addr = new Address();
                        //addr.Attention = CompanyLabelTextBox.Text;
                        //addr.CompanyName = CompanyLabelTextBox.Text;
                        //addr.Address1 = Address1LabelTextBox.Text;
                        //addr.Address2 = Address2LabelTextBox.Text;
                        //addr.City = CityLabelTextBox.Text;
                        //addr.State = state;
                        //addr.Zip = ZipLabelTextBox.Text;
                        //addr.DefaultBilling = false;
                        //addr.DefaultShipping = true;
                        //addr.DefaultAccount = false;
                        //addr.DefaultDelivery = false;
                        //DataSet dsCount = doQuery("SELECT * FROM Countries WHERE country_name = '" +
                        //    CountryLabel1RadComboBox.SelectedItem.Text + "'");
                        //addr.Country = dsCount.Tables[0].Rows[0]["country_2_code"].ToString();
                        //addr.Residential = ResidentialCheckBox.Checked;
                        //addr.Phone = PhoneLabelTextBox.Text;

                        //if (exTextBox.Text.Trim() != "")
                        //{
                        //    addr.Phone = PhoneLabelTextBox.Text + " x" + exTextBox.Text.Trim();
                        //}

                        Address addr2 = new Address();
                        addr2.Attention = FirstNameTextBox.Text + " " + LastNameTextBox.Text;
                        addr2.CompanyName = CompanyLabelTextBox.Text;
                        addr2.Address1 = Address1LabelTextBox.Text;
                        addr2.Address2 = Address2LabelTextBox.Text;
                        addr2.City = CityLabelTextBox.Text;
                        addr2.State = state;
                        addr2.Zip = ZipLabelTextBox.Text;
                        addr2.DefaultBilling = false;
                        addr2.DefaultShipping = false;
                        addr2.DefaultAccount = true;
                        addr2.DefaultDelivery = false;

                        DataSet dsCount = doQuery("SELECT * FROM Countries WHERE country_name = '" +
                            CountryLabel1RadComboBox.SelectedItem.Text + "'");
                        addr2.Country = dsCount.Tables[0].Rows[0]["country_2_code"].ToString();
                        addr2.Residential = ResidentialCheckBox.Checked;
                        addr2.Phone = PhoneLabelTextBox.Text;

                        if (exTextBox.Text.Trim() != "")
                        {
                            addr2.Phone = PhoneLabelTextBox.Text + " x" + exTextBox.Text.Trim();
                        }

                        List<NDAL.DataTypes.Address> addresses = new List<NDAL.DataTypes.Address>();
                        //addresses.Add(addr);
                        addresses.Add(addr2);

                        if (Session["UserID"] == null)
                        {
                            customer.Addresses = addresses;
                        }
                        else
                        {
                            for(int j=0;j<customer.Addresses.Count;j++)
                            {
                                if (customer.Addresses[j].DefaultAccount.Value)
                                {
                                    customer.Addresses[j] = addr2;
                                }
                            }
                        }

                        // set a password for this customer
                        customer.Password = PasswordTextBox.Text;

                        // save dynamic fields
                        object refCust = customer;
                        SaveDynamicFields("1", ref refCust);
                        customer = (Customer)refCust;
                        // perform the update, sending back the complete customer object
                        client.UpdateCustomer(customer);
                        Session["HasUserBeenClicked"] = "true";
                        // get the customer again to verify password was set
                        Customer getCustomer = client.GetCustomer(customerID);

                        string custID = "";

                        //Sign the new user in
                        bool isAuth = false;
                        if (Session["UserID"] == null)
                            isAuth = client.Authenticate(EmailTextBox.Text, PasswordTextBox.Text, out custID);
                        else
                        {
                            if (EmailChanged)
                            {
                                isAuth = client.Authenticate(EmailTextBox.Text, PasswordTextBox.Text, out custID);
                            }
                            else
                            {
                                custID = Session["UserID"].ToString();
                            }
                        }

                        Session["UserID"] = custID;
                        Session["UserType"] = getCustomer.CustomerType;
                        Session["User"] = getCustomer.FirstName;
                        Session["UserSalesRep"] = getCustomer.SalesRepID;

                        string groups = "";
                        groups = "1";
                        UserTracking();
                        FormsAuthenticationTicket authTicket =
                                        new FormsAuthenticationTicket(1, EmailTextBox.Text.Trim(),
                                                      DateTime.Now,
                                                      DateTime.Now.AddMinutes(60),
                                                      false, groups);

                        // Now encrypt the ticket.
                        string encryptedTicket =
                          FormsAuthentication.Encrypt(authTicket);
                        // Create a cookie and add the encrypted ticket to the
                        // cookie as data.
                        HttpCookie authCookie =
                                     new HttpCookie(FormsAuthentication.FormsCookieName,
                                                    encryptedTicket);
                        // Add the cookie to the outgoing cookies collection.
                        Response.Cookies.Add(authCookie);
                        //}
                        //catch (CommandErrorException ex)
                        //{
                        //    Console.WriteLine("Oh No! Code: {0} Message: {1}", ex.ErrorCode, ex.Message);

                        //}
                        //catch (TimeoutException ex)
                        //{
                        //    Console.WriteLine("WCF client network request timed out, message: {0}", ex.Message);

                        //}
                        //catch (CommunicationException ex)
                        //{
                        //    Console.WriteLine("WCF communication exception, message: {0}", ex.Message);

                        //}
                        Static1Messages.Text = "";
                        return true;

                    }
                    else
                    {

                        Static1Messages.Text = "A customer with this email address already exists.";
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    if (ex.ToString().Contains("Existing Customer"))
                    {
                        Static1Messages.Text = "A customer with this email address already exists.";
                    }
                    else
                    {
                        ErrorLabel.Text = ex.ToString();
                    }
                    return false;
                }
        }
示例#15
0
        protected void CreateOrder()
        {
            string sku = "";
            try
            {

                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                              DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                              "info",
                              "SubmitLogin()",
                              "---Create NDAL client object Begin------"));
                Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                client.MediatorLoggingLevel = Explore.NetSuite.JSONservice.MediatorLogLevels.Debug;

                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---Create NDAL client object End------"));

                string userID = Session["UserID"].ToString();
                SalesOrder order = new SalesOrder();
                order.Customer = userID;

                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---GetCustomer() Begin------"));
                Customer cust = client.GetCustomer(userID);
                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---GetCustomer() End------"));

                //What are these? How do we know what to set these to?

                //order.BillTo = "375300";
                //order.CreditCardSelect = "11";
                //order.CSC = "319";

                order.Date = DateTime.Now.ToShortDateString();
                order.DontReceiveBefore = DateTime.Today.AddDays(5).ToShortDateString();
                order.GetAuthorization = true;

                //how would we know this? there's no place to set this in the wireframes.
                order.IncludesInstallation = false;

                order.InstallAddress = null;

                List<Address> addresses = cust.Addresses;

                Address shipToAddress = new Address();

                for (int i = 0; i < addresses.Count; i++)
                {
                    if (addresses[i].DefaultBilling.Value)
                        order.BillTo = addresses[i].InternalID;
                    if (addresses[i].DefaultShipping.Value)
                    {
                        order.ShipTo = addresses[i].InternalID;
                        shipToAddress = addresses[i];
                    }
                    if (addresses[i].DefaultDelivery.Value)
                        order.DeliverTo = addresses[i].InternalID;
                    //if (addresses[i].DefaultAccount.Value)
                    //{

                    //}
                }

                //how do we know this?  ** LST - This should default to the Tualatin Warehouse, denotes where the inventory will be deducted from.
                order.Location = Locations.TualatinWarehouse;

                //what do we do in case of PO? there's no choice for this.
                if (POPanel.Visible)
                {
                    order.Terms = Terms.Net30;
                    order.PurchaseOrder = PurchaseOrderLabelTextBox.Text.Trim();
                }
                else
                {
                    switch (CreditCard2TypeDropDown.SelectedItem.Value)
                    {
                        case "0":
                            order.PaymentMethod = PaymentMethods.Discover;
                            break;
                        case "1":
                            order.PaymentMethod = PaymentMethods.MasterCard;
                            break;
                        case "2":
                            order.PaymentMethod = PaymentMethods.VISA;
                            break;
                        default:
                            order.PaymentMethod = PaymentMethods.VISA;
                            break;
                    }

                    order.CreditCardSelect = Session["CardToUser"].ToString();

                    //for (int i = 0; i < cust.CreditCards.Count; i++)
                    //{
                    //    if (cust.CreditCards[i].DefaultCreditCard.Value)
                    //    {
                    //        order.CreditCardSelect = cust.CreditCards[0].InternalID;
                    //        break;
                    //    }
                    //}
                }

                string thecartID = Session["yourcart"].ToString();

                //DataSet dsPromo = doQuery("SELECT * FROM CartPromos CP, NetSuitePromos NSP WHERE " +
                //    "CP.CodeID=NSP.NetSuiteID AND CP.CartSession='" + thecartID + "'");

                //if (dsPromo.Tables.Count > 0)
                //    if (dsPromo.Tables[0].Rows.Count > 0)
                //    {
                //        order.PromotionCode = TheDiscountPercent.Text = dsPromo.Tables[0].Rows[0]["NetSuiteID"].ToString();
                //    }

                order.GetAuthorization = false;

                order.Phone = cust.Phone;

                order.SalesRep = cust.SalesRepID;

                order.SchoolDistrict = userID;
                order.ShippingCost = ShippingUPSLabel.Text.Replace("$", "").Replace(",", "");
                order.ShipVia = ShippingMethods.UPSGround;
                order.Type = SalesOrderType.Regular;

                //Don't pass in a taxrate as NetSuite code should be doing this.
                //Website code just displays the tax information.
                decimal taxableAmount = 0.00M;
                decimal taxAmount = 0.00M;

                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---GetTax Begin------"));
                order.TaxRate = GetTax(shipToAddress, false, ref taxableAmount, ref taxAmount).ToString();
                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---GetTax End------"));

                //Take care of the tax following bug 2180 in OA bug tracking system

                string state = doQuery("SELECT * FROM States WHERE state_name='" + shipToAddress.State + "'").Tables[0].Rows[0]["state_code"].ToString();
                DataSet dsTax = doQuery("SELECT * FROM Taxables WHERE State='" + state + "'");

                bool taxeable = false;
                string taxcode = "";
                if (dsTax.Tables[0].Rows.Count > 0)
                {
                    taxeable = bool.Parse(dsTax.Tables[0].Rows[0]["Taxable"].ToString());
                    taxcode = dsTax.Tables[0].Rows[0]["Taxcode"].ToString();

                    order.Taxable = taxeable;
                    order.TaxItem = TaxItems.AVATAX;
                }
                else
                {
                    order.Taxable = false;
                    order.TaxItem = TaxItems.NotTaxable;
                }

                //*****************Old transaction code***************************************
                //create transaction items for each item in the cart
                ////test transaction
                //List<TransactionLineItem> transList = new List<TransactionLineItem>();

                //decimal eduPrice = decimal.Parse("1119");
                //TransactionLineItem transLine = new TransactionLineItem();
                //transLine.Amount = (eduPrice * decimal.Parse("2")).ToString(); //or dvParents[0]["Price"].ToString()
                //transLine.Description = "Online order";
                //transLine.DiscountPercent = "0%";//==================================TAKE CARE OF IT FROM DISCOUNT INFO
                //transLine.ItemID = "511";//=================================TAKE CARE OF IT WHEN PUSH SERVICE IS DONE
                //transLine.PriceLevel = PriceLevels.MSRP; //==============TAKE CARE OF IT WHEN KNOW THE ENUMERATION MAPPING
                //transLine.CommissionClass = Classes.Classroom; //need this to make it work: per bug 1504
                ////how do we know the item type?
                //transLine.ItemType = "noninventoryitem"; //=======================CHANGE THIS TO GRAB FROM THE MemberItem table when get these synced up.

                ////will this always be only 'Standard' or 'Educational'?
                //transLine.Quantity = "2";
                //transLine.Rate = "1119";
                //transLine.Tax = "4.44";//=============================================TAKE CARE OF FROM AVATAX
                //transLine.UnitPrice = "1119";

                ////how do we know the shippment location? ** LST - This should default to the Tualatin Warehouse, denotes where the inventory will be deducted from.
                //transLine.Location = Locations.TualatinWarehouse;

                //transList.Add(transLine);
                //*****************END OLD CODE************************************************

                DataSet dsCartParent = doQuery("SELECT * FROM Cart C, NetSuiteProducts NSP WHERE " +
                    "C.NID=NSP.NID AND isParent = 'True' AND CartSessionID='" + thecartID + "'");

                DataSet dsProduct1 = doQuery("SELECT * FROM NetSuiteProducts WHERE NID='" +
                    dsCartParent.Tables[0].Rows[0]["NID"].ToString().Trim().ToUpper()+"'");

                DataSet dsCart = doQuery("SELECT * FROM Cart C WHERE C.CartSessionID='" +
                    thecartID + "'");

                DataSet dsCartNotParent = doQuery("SELECT * FROM Cart C, NetSuiteBoxes NSB WHERE " +
                    "NSB.NID=C.SubProductID AND C.isParent='False' AND C.CartSessionID='" +
                    thecartID + "' ORDER BY C.BoxID");

                DataView dvParents = new DataView(doQuery("SELECT * FROM NetSuiteProducts").Tables[0], "", "",
                    DataViewRowState.CurrentRows);

                DataSet dsProdCount = doQuery("SELECT DISTINCT ID, NID, Quantity, isParent, SubProductID, " +
                    "ParentID FROM Cart WHERE CartSessionID='" + thecartID + "' AND isParent ='True'");

                DataView dv = new DataView(dsCart.Tables[0], "", "", DataViewRowState.CurrentRows);
                DataView dvSub = new DataView(dsCartNotParent.Tables[0], "", "", DataViewRowState.CurrentRows);

                List<TransactionLineItem> transList = new List<TransactionLineItem>();

                sku = "";

                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---GetTransactionLines Begin------"));
                GetTransactionLines(ref transList);

                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---GetTransactionLines End------"));

                order.TransactionLines = transList;

                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---CreateOrder() Begin------"));
                CreateOrderResult orderResult = client.CreateOrder(order);
                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---CreateOrder() End------"));

                Session["OrderNumber"] = orderResult.OrderNumber.ToString();
                Session["OrderStatus"] = orderResult.OrderStatus.ToString();

                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---GetTax Begin------"));
                GetTax(shipToAddress, true, ref taxableAmount, ref taxAmount);
                HttpContext.Current.Trace.Warn("FormPage_CreateOrder()", string.Format("{0},{1},{2},{3}",
                             DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                             "info",
                             "SubmitLogin()",
                             "---GetTax End------"));

                //IEnumerable<Transaction> trans = client.GetTransactions("211829", null, null);
                //}
                //catch (CommandErrorException ex)
                //{
                //    if (ex.ToString().Contains("An error occurred while processing your credit card"))
                //    {
                //        Static6Messages.Text = "There was an error processing your credit card. Please contact the merchant for further assistance.";
                //    }
                //    else
                //    {
                //        Static6Messages.Text = ex.ToString();
                //    }
                //}
                //catch (Exception ex)
                //{
                //    ErrorLabel.Text += ex.ToString() + sku;
                //}
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = "sku: " + sku + ex.ToString();
            }
        }
示例#16
0
        protected void ContinueShipping(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    Session["FormClicked"] = true;

                    bool isStateValid = false;
                    if (StateLabel3RadComboBox.Visible)
                    {
                        if (StateLabel3RadComboBox.SelectedValue != "-1")
                            isStateValid = true;
                    }
                    else
                    {
                        if (StateLabel3TextBox.Text.Trim() != "")
                            isStateValid = true;
                    }

                    if (isStateValid)
                    {
                        if (Session["UserID"] != null)
                        {

                            Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL();
                            Customer cust = client.GetCustomer(Session["UserID"].ToString());

                            Address adr = new Address();
                            adr.DefaultShipping = true;
                            adr.DefaultBilling = false;
                            adr.DefaultDelivery = false;
                            adr.DefaultAccount = false;

                            Session["formpage"] = "4";

                            Session["ShippingNameLabel"] = CompanyLabel3TextBox.Text;
                            ShippingNameLabel.Text = CompanyLabel3TextBox.Text;

                            Session["ShippingCompanyLabel"] = AttentionLabel2TextBox.Text;
                            ShippingCompanyLabel.Text = AttentionLabel2TextBox.Text;
                            adr.CompanyName = CompanyLabel3TextBox.Text;

                            Session["ShippingResidentialLabel"] = ResidentialCheckBox3.Checked;
                            adr.Residential = ResidentialCheckBox3.Checked;

                            ShippingStateLabel.Text = CityLabel3TextBox.Text;
                            adr.City = CityLabel3TextBox.Text;
                            string state = "";
                            if (StateLabel3RadComboBox.Visible)
                                state = StateLabel3RadComboBox.SelectedItem.Text;
                            else
                                state = StateLabel3TextBox.Text;
                            ShippingStateLabel.Text += ", " + state + " " + ZipLabel3TextBox.Text;
                            Session["ShippingStateLabel"] = state;
                            adr.State = state;

                            Session["ShippingPhoneLabel"] = PhoneLabel3TextBox.Text;
                            Session["ShippingEx"] = ex3TextBox.Text;

                            ShippingPhoneLabel.Text = PhoneLabel3TextBox.Text;
                            adr.Phone = PhoneLabel3TextBox.Text;

                            if (ex3TextBox.Text.Trim() != "")
                            {
                                ShippingPhoneLabel.Text = ShippingPhoneLabel.Text + " x" + ex3TextBox.Text;
                                adr.Phone = adr.Phone + " x" + ex3TextBox.Text;
                            }

                            Session["ShippingCityLabel"] = CityLabel3TextBox.Text;
                            adr.City = CityLabel3TextBox.Text;

                            Session["ShippingAttentionLabel"] = AttentionLabel2TextBox.Text;
                            adr.Attention = AttentionLabel2TextBox.Text;

                            Session["ShippingAddress2Label"] = Address2Label3TextBox.Text;
                            adr.Address2 = Address2Label3TextBox.Text;

                            Session["ShippingAddressLabel"] = Address1Label3TextBox.Text;
                            adr.Address1 = Address1Label3TextBox.Text;

                            Session["ShippingZipLabel"] = ZipLabel3TextBox.Text;
                            adr.Zip = ZipLabel3TextBox.Text;

                            Session["ShippingCountryLabel"] = CountryLabel3RadComboBox.SelectedValue;
                            DataSet dsCount = doQuery("SELECT * FROM Countries WHERE country_name = '" +
                            CountryLabel3RadComboBox.SelectedItem.Text + "'");
                            adr.Country = dsCount.Tables[0].Rows[0]["country_2_code"].ToString();

                            object refAdrs = (object)adr;
                            SaveDynamicFields("3", ref refAdrs);
                            adr = (Address)refAdrs;

                            UpdateAddress(adr, ref cust, AddressTypes.Shipping);

                            client.UpdateCustomer(cust);

                            cust = client.GetCustomer(Session["UserID"].ToString());

                            FillDelivery();
                            if (Session["EditShippingClicked"] != null)
                                if (bool.Parse(Session["EditShippingClicked"].ToString()))
                                {
                                    Session["EditShippingClicked"] = "false";
                                    GoToForm(6, 3);
                                    SetBoxes();
                                    BuildIt(client, cust);
                                }
                                else
                                    GoToForm(4, 3);
                            else
                                GoToForm(4, 3);
                        }
                    }
                    else
                    {
                        ErrorLabelShipping.Text = "State is required";
                    }
                }
                else
                {
                    ErrorLabel.Text = "page is not valid";
                }
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.ToString();
            }
        }