Exemplo n.º 1
0
        private void poHeaderChanged()
        {
            this.adventureWorksDataSet.PurchaseOrderDetail.Clear();

            try
            {
                DataRowView currentDataRowView = (DataRowView)purchaseOrderHeaderBindingSource.Current;
                this.currentPOHeaderRow =
                    (AdventureWorksDataSet.PurchaseOrderHeaderRow)currentDataRowView.Row;
                int purchaseOrderID = currentPOHeaderRow.PurchaseOrderID;
                this.purchaseOrderDetailTableAdapter.FillByPurchaseOrderID(this.adventureWorksDataSet.PurchaseOrderDetail, purchaseOrderID);
                this.calcTotals();
            }
            catch (System.NullReferenceException ex)
            {
                //Ignore
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Error: " +
                                "\nMessage: " + ex.Message,
                                "purchaseOrderHeaderBindingSource_CurrentChanged " + ex.GetType().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " +
                                "\nMessage: " + ex.Message,
                                "purchaseOrderHeaderBindingSource_CurrentChanged " + ex.GetType().ToString());
            }
        }
Exemplo n.º 2
0
        private void purchaseOrderDetailDataGridView_UserAddedRow(object sender, DataGridViewRowEventArgs e)
        {
            DataRowView currentDataRowView = (DataRowView)this.purchaseOrderHeaderBindingSource.Current;

            AdventureWorksDataSet.PurchaseOrderHeaderRow currentPOHeaderRow =
                (AdventureWorksDataSet.PurchaseOrderHeaderRow)currentDataRowView.Row;

            purchaseOrderDetailDataGridView.CurrentRow.Cells[0].Value = currentPOHeaderRow.PurchaseOrderID;
        }
Exemplo n.º 3
0
 private void purchaseOrderHeaderBindingSource_CurrentChanged(object sender, EventArgs e)
 {
     try {
         DataRowView currentDataRowView = (DataRowView)purchaseOrderHeaderBindingSource.Current;
         AdventureWorksDataSet.PurchaseOrderHeaderRow currentPOHeaderRow =
             (AdventureWorksDataSet.PurchaseOrderHeaderRow)currentDataRowView.Row;
         int purchaseOrderID = currentPOHeaderRow.PurchaseOrderID;
         this.purchaseOrderDetailTableAdapter.FillByPurchaseOrderID(this.adventureWorksDataSet.PurchaseOrderDetail, purchaseOrderID);
     }
     catch (System.Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message);
     }
 }
        private void loadSelectedPurchaseOrder()
        {
            this.purchaseOrderHeaderTableAdapter = new PurchaseOrderHeaderTableAdapter();
            this.purchaseOrderHeaderTableAdapter.ClearBeforeFill = true;
            int vendorID = Convert.ToInt32(this.purchaseOrderIDDropDownList.SelectedValue);

            this.purchaseOrderHeaderTableAdapter.FillByPurchaseOrderID(adventureWorksDataSet.PurchaseOrderHeader, vendorID);
            AdventureWorksDataSet.PurchaseOrderHeaderRow purchaseOrderRow =
                this.adventureWorksDataSet.PurchaseOrderHeader.First();

            this.revisionNumberTextBox.Text = purchaseOrderRow.RevisionNumber.ToString();
            this.statusTextBox.Text         = purchaseOrderRow.Status.ToString();
            //this.employeeIDTextBox.Text = purchaseOrderRow.EmployeeID.ToString();
            this.employeeNameDropDownList.SelectedValue = purchaseOrderRow.EmployeeID.ToString();
            this.shipDateTextBox.Text = purchaseOrderRow.ShipDate.ToShortDateString();
            //this.shipMethodIDTextBox.Text = purchaseOrderRow.ShipMethodID.ToString();
            this.shipMethodDropDownList.SelectedValue = purchaseOrderRow.ShipMethodID.ToString();
            this.subtotalLabel.Text  = purchaseOrderRow.SubTotal.ToString("n2");
            this.taxAmtLabel.Text    = purchaseOrderRow.TaxAmt.ToString("n2");
            this.freightTextBox.Text = purchaseOrderRow.Freight.ToString("n2");
            this.totalDueLabel.Text  = purchaseOrderRow.TotalDue.ToString("n2");

            this.loadPurchaseOrderDetails();
        }