Exemple #1
0
        private void buttonAddCategory_Click(object sender, EventArgs e)
        {
            var row = dataGridViewNames.CurrentRow;

            if (row == null)
            {
                return;
            }

            var nameMarkCategory = (NameMarkCategory)row.DataBoundItem;

            var markCategories = dataGridViewMarkCategories.Rows
                                 .OfType <DataGridViewRow>()
                                 .ToList()
                                 .Select(r => r.Tag as MarkCategory)
                                 .ToList();

            var names = markCategories.Select(m => m.Name).ToList();

            if (names.Contains(nameMarkCategory.Name))
            {
                return;
            }

            var id = dataGridViewMarkCategories.RowCount + 1;

            nameMarkCategory.CatId = id;

            var mc = new MarkCategory
            {
                Id             = id,
                Name           = nameMarkCategory.Name,
                PartNumber     = new NumberingSeries("x", 1),
                AssemblyNumber = new NumberingSeries("X", 1000),
                HasPhase       = false,
                HasDash        = false,
                Parts          = new List <RazorPart>()
            };

            markCategories.Add(mc);

            UpdateDataGridView(markCategories);
        }
Exemple #2
0
        private void buttonAddAllCategory_Click(object sender, EventArgs e)
        {
            var rows = dataGridViewNames.Rows;

            var markCategories = dataGridViewMarkCategories.Rows
                                 .OfType <DataGridViewRow>()
                                 .ToList()
                                 .Select(r => r.Tag as MarkCategory)
                                 .ToList();

            var names = markCategories.Select(m => m.Name).ToList();

            var id = dataGridViewMarkCategories.RowCount;

            foreach (DataGridViewRow row in rows)
            {
                var nameMarkCategory = (NameMarkCategory)row.DataBoundItem;

                if (names.Contains(nameMarkCategory.Name))
                {
                    continue;
                }

                id++;

                nameMarkCategory.CatId = id;

                var mc = new MarkCategory
                {
                    Id             = id,
                    Name           = nameMarkCategory.Name,
                    PartNumber     = new NumberingSeries("x", 1),
                    AssemblyNumber = new NumberingSeries("X", 1000),
                    HasPhase       = false,
                    HasDash        = false,
                    Parts          = new List <RazorPart>()
                };

                markCategories.Add(mc);
            }

            UpdateDataGridView(markCategories);
        }
Exemple #3
0
        private void ApplyMarks(List <Part> parts, MarkCategory markCategory, MarkCategoryView markCategoryView)
        {
            if (markCategory == null || markCategoryView == null)
            {
                return;
            }

            parts.ForEach(p =>
            {
                p.GetPhase(out Phase phase);

                var prefix = markCategory.AssemblyNumber.Prefix;

                if (markCategoryView.HasPhase && !markCategoryView.HasDash)
                {
                    prefix = $"{phase.PhaseNumber}{markCategory.AssemblyNumber.Prefix}";
                }

                if (!markCategoryView.HasPhase && markCategoryView.HasDash)
                {
                    prefix = $"{markCategory.AssemblyNumber.Prefix}-";
                }

                if (markCategoryView.HasPhase && markCategoryView.HasDash)
                {
                    prefix = $"{phase.PhaseNumber}{markCategory.AssemblyNumber.Prefix}-";
                }

                p.AssemblyNumber.Prefix      = prefix;
                p.AssemblyNumber.StartNumber = markCategory.AssemblyNumber.StartNumber;

                p.PartNumber = markCategory.PartNumber;
                p.Modify();
            });

            var razorParts = parts.ToJson().FromJson <List <RazorPart> >();

            markCategory.Parts = razorParts;

            UpdateDataGridView(null);
        }
Exemple #4
0
        private void buttonAddMarkCategory_Click(object sender, EventArgs e)
        {
            var mc = new MarkCategory
            {
                Id             = dataGridViewMarkCategories.RowCount + 1,
                Name           = "",
                PartNumber     = new NumberingSeries("x", 1),
                AssemblyNumber = new NumberingSeries("X", 1000),
                HasPhase       = false,
                HasDash        = false,
                Parts          = new List <RazorPart>()
            };

            var markCategories = dataGridViewMarkCategories.Rows
                                 .OfType <DataGridViewRow>()
                                 .ToList()
                                 .Select(r => r.Tag as MarkCategory)
                                 .ToList();

            markCategories.Add(mc);

            UpdateDataGridView(markCategories);
        }