示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_link == null)
                {
                    CreateLinkParams createParams = new CreateLinkParams();

                    createParams.Code = txtLinkCode.Text.Trim();

                    createParams.LeftObject = viewLeftObject.GetFocusedRow() as DomainObjectConfig;
                    createParams.RightObject = viewRightObject.GetFocusedRow() as DomainObjectConfig;

                    createParams.LeftRelation = rgLeftRelation.SelectedIndex == 0 ? eRelation.One : eRelation.Many;
                    createParams.RightRelation = rgRightRelation.SelectedIndex == 0 ? eRelation.One : eRelation.Many;

                    createParams.LeftObjectIdField = txtLeftIdField.Text.Trim();
                    createParams.RightObjectIdField = txtRightIdField.Text.Trim();

                    createParams.LinkTable = txtLinkTableName.Text.Trim();

                    m_link = m_inquiry.CreateLink(createParams);
                }

                EditLinkParams editParams = new EditLinkParams();

                editParams.IsLeftToRightActive = cbIsLeftToRight.Checked;
                editParams.IsRightToLeftActive = cbIsRightToLeft.Checked;

                editParams.LeftCollectionName = txtLeftCollectionName.Text.Trim();
                editParams.RightCollectionName = txtRightCollectionName.Text.Trim();

                editParams.LeftToRightDescription = txtLeftToRightDescription.Text.Trim();
                editParams.RightToLeftDescription = txtRightToLeftDescription.Text.Trim();

                m_inquiry.SaveLink(m_link, editParams);

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }
示例#2
0
 internal void Update(EditLinkParams editParams)
 {
     IsLeftToRightActive = editParams.IsLeftToRightActive;
     IsRightToLeftActive = editParams.IsRightToLeftActive;
     LeftToRightDescription = editParams.LeftToRightDescription;
     RightToLeftDescription = editParams.RightToLeftDescription;
     LeftCollectionName = editParams.LeftCollectionName;
     RightCollectionName = editParams.RightCollectionName;
 }
示例#3
0
        internal DomainLinkConfig(CreateLinkParams createParams, EditLinkParams editParams = null)
        {
            Id = createParams.Id;
            Code = createParams.Code;
            LeftRelation = createParams.LeftRelation;
            RightRelation = createParams.RightRelation;
            LeftObject = createParams.LeftObject;
            RightObject = createParams.RightObject;
            LinkTable = createParams.LinkTable;
            LeftObjectIdField = createParams.LeftObjectIdField;
            RightObjectIdField = createParams.RightObjectIdField;

            if (editParams != null)
                Update(editParams);

            Key = new DomainLinkKey(this);
        }
 public override void SaveLink(DomainLinkConfig link, EditLinkParams editParams)
 {
     throw new NotImplementedException();
 }
示例#5
0
        public override void SaveLink(DomainLinkConfig link, EditLinkParams editParams)
        {
            DbCommonCommand command = m_editLinkCommand.Value;

            command["ID"].Value = link.Id;
            command["IS_LEFT_TO_RIGHT_ACTIVE"].Value = editParams.IsLeftToRightActive;
            command["IS_RIGHT_TO_LEFT_ACTIVE"].Value = editParams.IsRightToLeftActive;
            command["LEFT_COLLECTION_NAME"].Value = editParams.LeftCollectionName;
            command["RIGHT_COLLECTION_NAME"].Value = editParams.RightCollectionName;
            command["LEFT_TO_RIGHT_DESCRIPTION"].Value = editParams.LeftToRightDescription;
            command["RIGHT_TO_LEFT_DESCRIPTION"].Value = editParams.RightToLeftDescription;

            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }
示例#6
0
        public override List<DomainLinkConfig> LoadLink()
        {
            List<DomainLinkConfig> result = new List<DomainLinkConfig>();
            DbCommonCommand command = m_loadLinkCommand.Value;

            using (IDbCommonDataReader reader = command.ExecuteReader(SessionIdentifier.SHARED_SESSION))
            {
                while (reader.Read())
                {
                    CreateLinkParams createParams = new CreateLinkParams();

                    createParams.Id = reader.GetValue<long>(0);
                    createParams.Code = reader.GetValue<String>(1);
                    createParams.LeftRelation = (eRelation)reader.GetValue<Int32>(2);
                    createParams.RightRelation = (eRelation)reader.GetValue<Int32>(3);

                    string leftObjectCode = reader.GetValue<string>(4);
                    createParams.LeftObject = m_objectConfig[leftObjectCode];

                    string rightObjectCode = reader.GetValue<string>(5);
                    createParams.RightObject = m_objectConfig[rightObjectCode];

                    createParams.LinkTable = reader.GetValue<string>(6);
                    createParams.LeftObjectIdField = reader.GetValue<string>(7);
                    createParams.RightObjectIdField = reader.GetValue<string>(8);

                    EditLinkParams editParams = new EditLinkParams();

                    editParams.IsLeftToRightActive = reader.GetValue<bool>(9);
                    editParams.IsRightToLeftActive = reader.GetValue<bool>(10);
                    editParams.LeftToRightDescription = reader.GetValue<string>(11);
                    editParams.RightToLeftDescription = reader.GetValue<string>(12);
                    editParams.LeftCollectionName = reader.GetValue<string>(13);
                    editParams.RightCollectionName = reader.GetValue<string>(14);

                    DomainLinkConfig loadLink = new DomainLinkConfig(createParams, editParams);
                    result.Add(loadLink);
                }
                reader.Close();
            }

            return result;
        }
 public abstract void SaveLink(DomainLinkConfig link, EditLinkParams editParams);
        public void SaveLink(DomainLinkConfig link, EditLinkParams editParams)
        {
            if (!editParams.IsLeftToRightActive && !editParams.IsRightToLeftActive)
                throw new ArgumentException();

            if (!Utils.CheckEnglishString(editParams.LeftCollectionName))
                throw new ArgumentOutOfRangeException("editParams.LeftCollectionName", Resources.OnlyLatinString);

            if (!Utils.CheckEnglishString(editParams.RightCollectionName))
                throw new ArgumentOutOfRangeException("editParams.RightCollectionName", Resources.OnlyLatinString);

            m_provider.SaveLink(link, editParams);

            link.Update(editParams);

            if (EditLinkCompleted != null)
                EditLinkCompleted(this, new EditLinkConfigArgs(link));

            IsModified = true;
        }