Exemplo n.º 1
0
        private async void sfDataGrid1_CellButtonClick(object sender, CellButtonClickEventArgs e)
        {
            var r = (Models.Order)sdgOrders.GetRecordAtRowIndex(e.RowIndex);

            if (r == null)
            {
                return;
            }

            var order = await DbContext.Orders.SingleOrDefaultAsync(o => o.Id == r.Id);

            switch (e.Column.HeaderText)
            {
            case "Reject":
                r.OrderStatus = OrderStatus.Rejected;
                break;

            case "Accept":
                r.OrderStatus = OrderStatus.Accepted;
                break;

            case "Delete":
                DbContext.Orders.Remove(r);
                break;
            }

            await DbContext.SaveChangesAsync();

            sdgOrders.Refresh();
        }
Exemplo n.º 2
0
        protected override void addFeature_Click(object sender, CellButtonClickEventArgs e)
        {
            // get the feature from the datagrid
            var feature = this.featureCaptureGrid.SelectedItem as FeatureCapture;

            // if the feature is null then continue
            if (feature != null)
            {
                // create a variable to store the command
                string command;

                // if the active doc is an assembly doc
                if (SolidworksApplication.ActiveDocument.IsAssemblyDoc)
                {
                    // if the feature is pattern type then set to component pattern
                    if (feature.FeatureType.Contains("Pattern"))
                    {
                        command = Commands.PatternActivity;
                    }
                    else
                    {
                        // if the feature is a component then set to component reference
                        if (feature.FeatureType == FeatureSubTypes.Reference)
                        {
                            command = Commands.ComponentActivity;
                        }
                        // set to feature reference
                        else
                        {
                            command = Commands.FeatureActivity;
                        }
                    }
                }
                // set command to feature reference
                else
                {
                    command = Commands.FeatureActivity;
                }

                // write the command in
                _selectedRange.Value = command;

                // set the name of the feature
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 1)}{_selectedRange.Row}"].Value = feature.Name;

                // set the name of the active document
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 2)}{_selectedRange.Row}"].Value = SolidworksApplication.ActiveDocument.Name;

                // if the feature is suppressed then set the value
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 3)}{_selectedRange.Row}"].Value = feature.Suppressed ? "S" : "U";
            }

            // move the selection down to the next cell.
            _workSheet.Range[$"{ ExcelHelpers.GetColumnName(_selectedRange.Column)}{_selectedRange.Row + 1}"].Select();

            base.addFeature_Click(sender, e);
        }
        protected override void addFeature_Click(object sender, CellButtonClickEventArgs e)
        {
            var feature = this.featureCaptureGrid.SelectedItem as FeatureCaptureDto;

            if (feature != null)
            {
                var command = "";

                switch (feature.Type)
                {
                case FeatureCaptureType.Component:
                    command = Commands.ComponentActivity;
                    break;

                case FeatureCaptureType.Feature:
                    command = Commands.FeatureActivity;
                    break;

                case FeatureCaptureType.Pattern:
                    command = Commands.PatternActivity;
                    break;

                case FeatureCaptureType.Constraint:
                    command = Commands.ConstraintActivity;
                    break;

                default:
                    break;
                }

                // write the command in
                _selectedRange.Value = command;

                // set the name of the feature
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 1)}{_selectedRange.Row}"].Value = feature.Name;

                // set the name of the active document
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 2)}{_selectedRange.Row}"].Value = InventorApplication.ActiveDocument.Name;

                // if the feature is suppressed then set the value
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 3)}{_selectedRange.Row}"].Value = feature.Suppressed ? "S" : "U";
            }

            // move the selection down to the next cell.
            _workSheet.Range[$"{ ExcelHelpers.GetColumnName(_selectedRange.Column)}{_selectedRange.Row + 1}"].Select();

            base.addFeature_Click(sender, e);
        }
Exemplo n.º 4
0
        protected override void addDim_Click(object sender, CellButtonClickEventArgs e)
        {
            var dim = this.dimensionCaptureGrid.SelectedItem as DimensionCapture;

            if (dim != null)
            {
                _selectedRange.Value = Commands.Dimension;
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 1)}{_selectedRange.Row}"].Value = dim.Name;
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 2)}{_selectedRange.Row}"].Value = SolidworksApplication.ActiveDocument.Name;
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 3)}{_selectedRange.Row}"].Value = dim.Value;
            }

            _workSheet.Range[$"{ ExcelHelpers.GetColumnName(_selectedRange.Column)}{_selectedRange.Row + 1}"].Select();

            base.addDim_Click(sender, e);
        }
        protected override void addDim_Click(object sender, CellButtonClickEventArgs e)
        {
            var parameter = this.dimensionCaptureGrid.SelectedItem as ParameterCaptureDto;

            if (parameter != null)
            {
                _selectedRange.Value = Commands.Parameter;
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 1)}{_selectedRange.Row}"].Value = parameter.Name;
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 2)}{_selectedRange.Row}"].Value = InventorApplication.ActiveDocument.Name;
                _workSheet.Range[$"{ExcelHelpers.GetColumnName(_selectedRange.Column + 3)}{_selectedRange.Row}"].Value = parameter.Value;
            }

            _workSheet.Range[$"{ ExcelHelpers.GetColumnName(_selectedRange.Column)}{_selectedRange.Row + 1}"].Select();

            base.addDim_Click(sender, e);
        }
 /// <summary>
 /// Adds the selected feature to the selected range on the active sheet.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void addFeature_Click(object sender, CellButtonClickEventArgs e)
 {
 }