Beispiel #1
0
 void DisplayStock()
 {
     ClassLibrary.clsStockCollection AllProducts = new ClassLibrary.clsStockCollection();
     lstStockList.DataSource     = AllProducts.mProductList;
     lstStockList.DataValueField = "ProductNo";
     lstStockList.DataTextField  = "ProductName";
     lstStockList.DataBind();
 }
 void DisplayStock()
 {
     ClassLibrary.clsStockCollection Stock = new ClassLibrary.clsStockCollection();
     ListBoxStock.DataSource     = Stock.StockList;
     ListBoxStock.DataValueField = "StockID";
     ListBoxStock.DataTextField  = "ItemName";
     ListBoxStock.DataBind();
 }
Beispiel #3
0
 void DisplayStock()
 {
     ClassLibrary.clsStockCollection stocks = new ClassLibrary.clsStockCollection();
     //set data source to list of stock in collection
     lstStock.DataSource = stocks.StockList;
     // set name of primary key
     lstStock.DataValueField = "ProductId";
     //set data field display
     lstStock.DataTextField = "Name";
     //bind data to list
     lstStock.DataBind();
 }
        protected void btnOK_Click(object sender, EventArgs e)
        {
            //Create a new instance of clsStock
            clsStock SomeStock = new clsStock();

            //Capture the gender
            SomeStock.Gender = txtGender.Text;
            //Capture the size
            SomeStock.Size = txtSize.Text;
            //Capture the description
            SomeStock.Description = txtDescription.Text;
            //Capture the Price
            SomeStock.Price = txtPrice.Text;
            //Capture the stock
            SomeStock.InStock = chkInStock.Text;
            //Capture the date arrived
            SomeStock.DateArrived = Convert.ToDateTime(txtDateArrived.Text);
            //Variable to store any error message
            string Error = "";

            //Validate the data
            Error = SomeStock.Valid(Gender, Size, Description, Price, InStock, DataArrived);
            if (Error == "")
            {
                //capture Active
                SomeStock.Active = chkActive.Checked;
                //Capture gender
                SomeStock.Gender = Gender;
                //capture size
                SomeStock.Size = Size;
                //Capture description
                SomeStock.Description = Description;
                //capture price
                SomeStock.Price = Price;
                //Capture inStock
                SomeStock.InStock = chkInStock.Checked;
                //Capture DateArrived
                SomeStock.DateArrived = Convert.ToDateTime(DateArrived);
                //Create a new instance of the stock collection
                clsStockCollection StockList = new clsStockCollection();

                //if this is a new record i.e. Price = -1 then add the data
                if (Price == -1)
                {
                    //set the ThisStock property
                    StockList.ThisStock = SomeStock;
                    //add the new record
                    StockList.Add();
                }
                //Otherwise it must update
                else
                {
                    //find the record to update
                    StockList.ThisStock.Find(Price);
                    //set the ThisStock property
                    StockList.ThisStock = SomeStock;
                    //update the record
                    StockList.Update();
                }
                //redirect back to the listpage
                Response.Redirect("StockList.aspx");
            }
            else
            {
                //display the error message
                lblError.Text = Error;
            }
            //Some more code that is changed totally

            /*
             * {
             *  //Store the stock in the session object
             *  Session["SomeStock"] = SomeStock;
             *  //redirect to the viewer page
             *  Response.Redirect("StockViewer.aspx");
             * }
             * else
             * {
             *  //display the error message
             *  lblError.Text = Error;
             * }
             */
        }