Esempio n. 1
0
        private void Status_Change(Microsoft.Office.Interop.Excel.Range Target)
        {
            // 获取在“Status”命名范围上设置的状态的 StatusID。
            Debug.Assert((Globals.ThisWorkbook.CustomerOrdersBindingSource.Current as DataRowView) != null);
            DataRowView currentRow = (DataRowView)Globals.ThisWorkbook.CustomerOrdersBindingSource.Current;

            Debug.Assert((currentRow.Row as CompanyData.OrdersRow) != null);
            CompanyData.OrdersRow orderRow = (CompanyData.OrdersRow)currentRow.Row;
            int newStatus = Globals.ThisWorkbook.CurrentCompanyData.Status.FindByStatus(
                this.Status.Value2.ToString()).StatusID;

            // 检查当订单未能真正履行时,状态是否设置为“已满足”。
            // 如果是这样,提醒用户订单无法履行。
            if (newStatus == 0 && orderRow.StatusID != 0 && !this.CanFulfillOrder())
            {
                MessageBox.Show("Order cannot be fulfilled with current inventory levels.");
                this.Status.Value2 = orderRow.StatusRow.Status;
                return;
            }
            else if (newStatus == 0 && orderRow.StatusID != 0)
            {
                // 订单更改为将要履行,因此库存需要
                // 更新以移除发货的数量。
                this.UpdateInventory();
            }

            // 更新订单以反映新状态。
            orderRow.StatusID = newStatus;
        }
        private void Status_Change(Microsoft.Office.Interop.Excel.Range Target)
        {
            // Get the StatusID for the Status just set on the Status named range.
            Debug.Assert((Globals.ThisWorkbook.CustomerOrdersBindingSource.Current as DataRowView) != null);
            DataRowView currentRow = (DataRowView)Globals.ThisWorkbook.CustomerOrdersBindingSource.Current;

            Debug.Assert((currentRow.Row as CompanyData.OrdersRow) != null);
            CompanyData.OrdersRow orderRow = (CompanyData.OrdersRow)currentRow.Row;
            int newStatus = Globals.ThisWorkbook.CurrentCompanyData.Status.FindByStatus(
                this.Status.Value2.ToString()).StatusID;

            // Check to see if the status was set to Fulfilled when it could not
            // actually be fulfilled.  If so, alert the user that the order cannot be fulfilled.
            if (newStatus == 0 && orderRow.StatusID != 0 && !this.CanFulfillOrder())
            {
                MessageBox.Show("Order cannot be fulfilled with current inventory levels.");
                this.Status.Value2 = orderRow.StatusRow.Status;
                return;
            }
            else if (newStatus == 0 && orderRow.StatusID != 0)
            {
                // The order was changed to be fulfilled, so the inventory needs
                // to be updated to remove the quantities that were shipped.
                this.UpdateInventory();
            }

            // Update the order to reflect the new status.
            orderRow.StatusID = newStatus;
        }