Ejemplo n.º 1
0
        /// <summary>
        /// 删除关联
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelRelation_Click(object sender, EventArgs e)
        {
            //tabProduct
            //  MessageBox.Show(this.tabControl2.SelectedTab.Name.ToString());
            if (this.tabControl2.SelectedTab.Name.ToString() == "tabProduct")
            {
                if (this.dGVProduct.CurrentRow == null)
                {
                    MessageBox.Show("当前没有选中任何可以删除的对象,请确认!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    return;
                }
                else
                {
                    ObjectRelation or = new ObjectRelation();

                    IObjectRelationService _orDocProd = ServiceContainer.GetService <ObjectRelationService>();
                    or = _orDocProd.getObjectRelation(DataType.RelationObjectType.Drawing.ToString(), this.document.DOCID, DataType.RelationObjectType.Product.ToString(), this.dGVProduct.CurrentRow.Cells["PRODUCTID"].Value.ToString());
                    if (or != null)
                    {
                        or.DEL_FALG = "Y";
                        or.Save();
                        MessageBox.Show("关联删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        InitialObjectRelation();
                    }
                }
            }
            else if (this.tabControl2.SelectedTab.Name.ToString() == "tabMaterial")
            {
                if (this.dgvMaterial.CurrentRow == null)
                {
                    MessageBox.Show("当前没有选中任何可以删除的对象,请确认!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    return;
                }
                else
                {
                    ObjectRelation or = new ObjectRelation();

                    IObjectRelationService _orDocProd = ServiceContainer.GetService <ObjectRelationService>();
                    // or = _orDocProd.getDocMaterialObjectRelation(this.Document.DOCID, this.dgvMaterial.CurrentRow.Cells["MATERIALID"].Value.ToString());
                    or = _orDocProd.getObjectRelation(DataType.RelationObjectType.Drawing.ToString(), this.document.DOCID, DataType.RelationObjectType.Material.ToString(), this.dgvMaterial.CurrentRow.Cells["MATERIALID"].Value.ToString());
                    if (or != null)
                    {
                        or.DEL_FALG = "Y";
                        or.Save();
                        MessageBox.Show("关联删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        InitialObjectRelation();
                    }
                }
            }
            else
            {
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 新建关联
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRelation_Click(object sender, EventArgs e)
        {
            //    List<PDM_ALL_PRODUCT> pdmAllSelectedProduct = null;
            //    List<PDM_MATERAIL> pdmSelectedMaterial = null;
            //     DataType.RelationObjectType relationObjectType;
            ObjectRelation         or  = new ObjectRelation();
            IObjectRelationService orS = ServiceContainer.GetService <ObjectRelationService>();
            IList <ObjectRelation> listObjectRelation = new List <ObjectRelation>();

            HYPDM.WinUI.Document.ConnectForm frmConnect = new ConnectForm();
            frmConnect.Document = this.Document;
            if (frmConnect.ShowDialog() == DialogResult.OK)
            {
                listObjectRelation = frmConnect.ListObjectRelation;

                try
                {
                    foreach (ObjectRelation objRelation in listObjectRelation)
                    {
                        objRelation.MASTEROBJECTID      = this.Document.DOCID;
                        objRelation.MASTEROBJECTTYPE    = DataType.RelationObjectType.Document.ToString();
                        objRelation.MASTEROBJECTVERSION = this.Document.VERSION;
                        objRelation.Save();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }
                finally
                {
                    InitialObjectRelation();
                }
            }
        }