예제 #1
0
    protected void ButtonInsertRecord_Click(object sender, EventArgs e)
    {
        short quantity;

        //If we don't get an OrderID or a number, just return
        if (TextBoxOrderIDInsert.Text.Length == 0 || !short.TryParse(TextBoxQuantity.Text, out quantity))
        {
            return;
        }

        int OrderID, ProductID;

        try
        {
            //Get the integers for IDs
            OrderID   = int.Parse(TextBoxOrderIDInsert.Text);
            ProductID = int.Parse(DropDownListProductList.SelectedValue);
        }
        catch
        {
            //Couldn't parse out the OrderID and the ProductID
            return;
        }
        //Insert the record and update the status bar
        LabelStatusInsert.Text = $"Inserted {NorthwindAccess.InsertOrderDetails(OrderID, ProductID,quantity)} records";
        //Update the gridview
        GridViewOrderDetails.DataBind();
    }
    protected void _Bu_Insert_Click(object sender, EventArgs e)
    {
        int   OID;
        short Qty;

        if (!(int.TryParse(_TB_OrderID.Text, out OID) && short.TryParse(_TB_Qty.Text, out Qty)))
        {
            return;
        }
        _La_Status2.Text = NorthwindAccess.InsertOrderDetails(OID, int.Parse(_DDL_Pro.SelectedValue), Qty);
        _GW_.DataBind();
    }
예제 #3
0
 /// <summary>
 /// Handle insertions, calls northwindaccess static function, handles errors in case it catches an exception
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Part2Button_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Part2TBOrderID.Text) && !string.IsNullOrEmpty(Part2TBQuantity.Text))
     {
         try
         {
             Part2Label.Text = "Status: " + NorthwindAccess.InsertOrderDetails(int.Parse(Part2TBOrderID.Text), int.Parse(Part2DDL.SelectedValue), short.Parse(Part2TBQuantity.Text));
             Part1TB.Text    = Part2TBOrderID.Text;
             Part1GV.DataBind();
         }
         catch (Exception error)
         {
             Part2Label.Text = "Status " + error.Message;
         }
     }
 }