Ejemplo n.º 1
0
        /// <summary>
        /// Correlation component to routing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCorrelationComponentToRouting_Click(
            object sender,
            EventArgs e)
        {
            ///零件和工序文件关联表
            ProcessFileRouting pfr = new ProcessFileRouting();

            pfr.ProcessFileRoutingId = Guid.NewGuid().ToString();
            pfr.OperId          = cbxProcessName.SelectedValue.ToString();
            pfr.RoutingId       = routingId;
            pfr.ProcessFileName = cbxProcessName.Text.Trim();
            pfr.ProcessFilePath = cbxComponentList.SelectedValue.ToString();
            pfr.Sort            = 0;

            try
            {
                ///add process file routing
                rpContext.ProcessFileRoutings.InsertOnSubmit(pfr);
                rpContext.SubmitChanges();

                MessageBox.Show(UIResource.NEWADDPROCESSSUCESS);

                AddComponectToActiveDoc(cbxComponentList.SelectedValue.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(UIResource.NEWADDPROCESSFAILURE + ex.Message + "!");
            }
        }
Ejemplo n.º 2
0
        private void btnComfirm_Click(object sender, EventArgs e)
        {
            var routings = from p in rcontext.ProcessFileRoutinges
                           where p.ProcessFileName == GlobalCache.Instance.ComponetName &&
                           p.RoutingId == cbxProcessLine.SelectedValue.ToString()
                           select p;

            if (routings.Count() > 0)
            {
                MessageBox.Show("该零件已和选中的工艺路线进行了关联!");
                return;
            }

            ProcessFileRouting processFileRouting = new ProcessFileRouting();

            processFileRouting.RoutingId            = cbxProcessLine.SelectedValue.ToString();
            processFileRouting.ProcessFileRoutingId = Guid.NewGuid().ToString();
            processFileRouting.ProcessFileName      = _processFilePath;
            processFileRouting.ProcessFilePath      = _processFilePath;
            processFileRouting.OperId = "";



            try
            {
                rcontext.ProcessFileRoutinges.InsertOnSubmit(processFileRouting);
                rcontext.SubmitChanges();
                MessageBox.Show("关联零件到工艺路线成功!");

                ITaskpaneView pTaskPanView = null;
                if (GlobalCache.Instance.PTaskPanView == null)
                {
                    pTaskPanView = _swApp.CreateTaskpaneView2("", "关联工艺路线");

                    GlobalCache.Instance.PTaskPanView = pTaskPanView;
                }
                else
                {
                    pTaskPanView = GlobalCache.Instance.PTaskPanView;
                }

                ProcessLine frm = null;
                if (ProcessLine.CurrentProcessLine == null)
                {
                    frm = new ProcessLine(
                        _doc,
                        _swApp,
                        new List <string>()
                    {
                        processFileRouting.RoutingId
                    });
                    pTaskPanView.DisplayWindowFromHandle(frm.Handle.ToInt32());
                }
                else
                {
                    ///show in task plane
                    ProcessLine.CurrentProcessLine.AddProcessLine(
                        null,
                        new RoutingEventArgs()
                    {
                        RoutingId   = processFileRouting.RoutingId,
                        RoutingName = ((Routing)cbxProcessLine.SelectedItem).Name
                    });
                }
            }
            catch
            {
                MessageBox.Show("关联零件到工艺路线出错!");
            }



            this.Dispose();
            GC.Collect();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加零件到装配体中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddPartToAssembly_Click(object sender, EventArgs e)
        {
            if (GlobalCache.Instance.RoutingId == null)
            {
                MessageBox.Show(UIResource.NEWADDPROCESSPLEASECHOICEROUTING);
                return;
            }
            if (StringHelper.IsValidEmpty(tbxProcessCode.Text))
            {
                MessageBox.Show(UIResource.PROCESSCODECANOTNULL);
                return;
            }
            if (StringHelper.IsValidEmpty(tbxProcessName.Text))
            {
                MessageBox.Show(UIResource.PROCESSNAMECANOTNULL);
                return;
            }

            if (StringHelper.IsValidEmpty(tbxSelectedComponent.Text))
            {
                MessageBox.Show(UIResource.PLEASESELECTPARTFILE);
                return;
            }

            ///工艺文件
            CProcess cp = new CProcess();

            cp.OperId     = Guid.NewGuid().ToString();
            cp.Name       = tbxProcessName.Text;
            cp.Code       = tbxProcessCode.Text;
            cp.CreateDate = cp.UpdateDate = DateTime.Now.ToString();

            cp.Creator = cp.UpdatePerson = "FFB0AC2D-C1B5-49E2-89B2-F4058523DF18";
            cp.Remark  = string.Empty;


            ///工序和工艺路线关联表
            RoutingProcessRelation rp = new RoutingProcessRelation();

            rp.RelationId      = Guid.NewGuid().ToString();
            rp.RoutingId       = routingId;
            rp.OperId          = cp.OperId;
            rp.Seq             = 2;
            rp.WorkcenterId    = string.Empty;
            rp.Persons         = 1;
            rp.ProcessTime     = 0;
            rp.ProcessTimeUnit = 1;
            rp.ProcessCosts    = "0";
            rp.LaborCosts      = "0";
            rp.OperCosts       = "0";
            rp.Creator         = rp.UpdatePerson = cp.Creator;
            rp.CreateDate      = rp.UpdateDate = cp.CreateDate;

            ///零件和工序文件关联表
            ProcessFileRouting pfr = new ProcessFileRouting();

            pfr.ProcessFileRoutingId = Guid.NewGuid().ToString();
            pfr.RoutingId            = routingId;
            pfr.ProcessFileName      = tbxProcessName.Text.Trim();
            pfr.OperId          = cp.OperId;
            pfr.ProcessFilePath = tbxSelectedComponent.Text.Trim();
            pfr.Sort            = 0;

            try
            {
                //add component to feature tree
                AddComponectToActiveDoc(tbxSelectedComponent.Text.Trim());

                //add process
                rpContext.Processes.InsertOnSubmit(cp);
                //add process and routing relation
                rpContext.RoutingProcessRelation.InsertOnSubmit(rp);
                ///add process file routing
                rpContext.ProcessFileRoutings.InsertOnSubmit(pfr);

                rpContext.SubmitChanges();

                MessageBox.Show(UIResource.NEWADDPROCESSSUCESS);


                AddProcess(sender, new NodeEventArgs()
                {
                    Name   = tbxProcessName.Text.Trim(),
                    OperId = cp.OperId
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(UIResource.NEWADDPROCESSFAILURE + ex.Message + "!");
            }
        }