Exemplo n.º 1
0
    //function for adding
    void Add()
    {
        clsStockCollection StockBook = new clsAddressCollection();
        //validate the data on the web form
        string Error = StockBook.ThisStock.valid(txtDateOfOrder.Text, txtShipmentDate.Text, txtSupplierID.Text, txtNumberOfOrder.Text, txtNumberShipped.Text, txtCost.Text, txtProductname.Text);

        if (Error == "")
        {
            StockBook.ThisStock.DateOfOrder   = Convert.ToDateTime(txtDateOfOrder.Text);
            StockBook.ThisStock.ShipmentDate  = Convert.ToDateTime(txtShipmentDate.Text);
            StockBook.ThisStock.SupplierID    = Convert.ToInt32(txtSupplierID.Text);
            StockBook.ThisStock.NumberOfOrder = Convert.ToInt32(txtNumberOfOrder.Text);
            StockBook.ThisStock.NumberShipped = Convert.ToInt32(txtNumberShipped.Text);
            StockBook.ThisStock.Cost          = txtCost.Text;
            StockBook.ThisStock.Productname   = txtProductname.Text;
            //Add records
            StockBook.Add();
        }
        else
        {
            //report an error
            lblError.Text = "there is problem with the data" + Error;
        }
    }