Exemple #1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            CProcess cprocess = new CProcess();

            cprocess.OperId       = Guid.NewGuid().ToString();
            cprocess.Name         = tbxProcessName.Text.Trim();
            cprocess.Code         = tbxProcessCode.Text.Trim();
            cprocess.CreateDate   = DateTime.Now.ToString();
            cprocess.Creator      = "FFB0AC2D-C1B5-49E2-89B2-F4058523DF18";
            cprocess.Remark       = "";
            cprocess.UpdateDate   = DateTime.Now.ToString();
            cprocess.UpdatePerson = "FFB0AC2D-C1B5-49E2-89B2-F4058523DF18";

            RoutingProcessRelation routingProcessRelation = new RoutingProcessRelation();

            routingProcessRelation.RelationId      = Guid.NewGuid().ToString();
            routingProcessRelation.OperId          = cprocess.OperId;
            routingProcessRelation.RoutingId       = _routingId;
            routingProcessRelation.Seq             = 1;
            routingProcessRelation.WorkcenterId    = "";
            routingProcessRelation.Persons         = 1;
            routingProcessRelation.ProcessTime     = 0;
            routingProcessRelation.ProcessTimeUnit = 1;
            routingProcessRelation.LaborCosts      = "0";
            routingProcessRelation.OperCosts       = "";
            routingProcessRelation.ProcessCosts    = "0";
            routingProcessRelation.Creator         = "FFB0AC2D-C1B5-49E2-89B2-F4058523DF18";
            routingProcessRelation.CreateDate      = DateTime.Now.ToString();
            routingProcessRelation.UpdateDate      = DateTime.Now.ToString();
            routingProcessRelation.UpdatePerson    = "FFB0AC2D-C1B5-49E2-89B2-F4058523DF18";


            try
            {
                rprConext.Processes.InsertOnSubmit(cprocess);
                rprConext.RoutingProcessRelation.InsertOnSubmit(routingProcessRelation);

                rprConext.SubmitChanges();

                MessageBox.Show("新增工序成功!");
                this.Close();

                /// 新增工序到右边工序树下
                if (ProcessLine.CurrentProcessLine != null)
                {
                    AddProcess += new EventHandler <ProcessEventArgs>(ProcessLine.CurrentProcessLine.CurrentProcess_AddProcess);
                }
                /************************************************************************/

                /* 触发事件
                 * /************************************************************************/
                if (AddProcess != null)
                {
                    AddProcess(this, new ProcessEventArgs()
                    {
                        ProcessName = tbxProcessName.Text.Trim(),
                        ProcessId   = cprocess.OperId
                    });
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
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 + "!");
            }
        }