Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Initialization();
            }
            else
            {
                // after a post back return to the position as before
                Page.MaintainScrollPositionOnPostBack = true;

                // restore value
                if (ViewState["Value"] != null)
                {
                    value = (BPvalues[])ViewState["Value"];
                }
                asi = (Asi)Session["ASI"];
                bp  = (BPconnect)Session["BPconnect"];
            }
        }
Beispiel #2
0
        /* a method that add text and value to the drop down list */
        private void Initialization()
        {
            // initialize grid view
            DataTable table = new DataTable();

            table.Columns.Add("SKU", typeof(string));
            table.Columns.Add("Short Description", typeof(string));
            table.Columns.Add("Gift Box", typeof(bool));
            table.Columns.Add("Quantity", typeof(int));
            table.Columns.Add("Base Price", typeof(double));
            table.Columns.Add("Pricing Tier", typeof(int));
            gridview.DataSource = table;
            gridview.DataBind();
            ViewState["DataTable"] = table;

            #region Drop Down List
            // local field for storing data
            List <ListItem> list = new List <ListItem> {
                new ListItem("")
            };

            // adding SKUs to the dropdown list
            using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.Designcs))
            {
                SqlCommand command = new SqlCommand("SELECT SKU_Ashlin, Short_Description, GiftBox, Base_Price, Pricing_Tier FROM master_SKU_Attributes sku " +
                                                    "INNER JOIN master_Design_Attributes design ON design.Design_Service_Code = sku.Design_Service_Code " +
                                                    "WHERE sku.Active = 'True' and Design_Service_Flag = 'Design'", connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    list.Add(new ListItem(reader.GetString(0), reader.GetString(1) + ';' + reader.GetBoolean(2) + ';' + reader.GetValue(3) + ';' + reader.GetInt32(4)));
                }
            }

            skuDropdownlist.DataSource     = list;
            skuDropdownlist.DataTextField  = "Text";
            skuDropdownlist.DataValueField = "Value";
            skuDropdownlist.DataBind();

            // declare BPconnect object for staff search and reset list
            bp = new BPconnect();
            list.Clear();

            // get staff dictionary
            Dictionary <string, string> dic = bp.GetStaff();

            // put staff into dropboxlist
            list.AddRange(dic.Select(pair => new ListItem(pair.Value, pair.Key)));
            staffDropdownlist.DataSource     = list;
            staffDropdownlist.DataTextField  = "Text";
            staffDropdownlist.DataValueField = "Value";
            staffDropdownlist.DataBind();
            #endregion

            // set default delivery date
            dateDeliveryTextbox.Text = DateTime.Today.AddDays(30).ToString("yyyy-MM-dd");

            // add confirm attribute to buttons
            clearScreenLinkButton.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to clear all the information on the page?');");
            quoteButton.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to create the quote for this order?');this.disabled=true;"
                                       + ClientScript.GetPostBackEventReference(quoteButton, null) + ';');

            #region Session Declaration
            try
            {
                // initialize ASI object and store it
                if (Session["ASI"] == null)
                {
                    Session["ASI"] = new Asi();
                }
            }
            catch (System.Net.WebException ex)
            {
                // the case if there is error from asi -> disable asi function
                asiTextbox.Text       = ((System.Net.HttpWebResponse)ex.Response).StatusDescription;
                asiTextbox.Enabled    = false;
                asiNextButton.Enabled = false;
            }

            // initialize BPconnect object and store it
            if (Session["BPconnect"] == null)
            {
                Session["BPconnect"] = bp;
            }
            #endregion

            // check if the user has cookies login
            if (Request.Cookies["Login"] != null)
            {
                Application["USERNAME"] = Request.Cookies["Login"].Value;
                welcomePopup.Show();
            }
            else
            {
                // the case has no cookies login -> show login panel for login
                loginPopup.Show();
            }
        }