Exemplo n.º 1
0
        public EditPropertyForm(DomainObjectInquiry inquiry, DomainObjectConfig obj, DomainPropertyConfig prop)
        {
            InitializeComponent();

            m_inquiry = inquiry;
            m_object = obj;
            m_property = prop;

            FillDataType();

            if (m_property != null)
            {
                txtCode.Text = m_property.Code;
                txtCode.Enabled = false;

                txtCodeName.Text = m_property.CodeName;
                txtDescription.Text = m_property.Description;

                txtDataType.SelectedItem = m_property.DataType;
                txtDataType.Enabled = false;

                txtLength.Value = m_property.Size;
                txtLength.Enabled = false;
            }
        }
Exemplo n.º 2
0
 public override void DeleteObjectProperty(DomainPropertyConfig propConfig)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 3
0
        public override void SaveObjectProperty(DomainPropertyConfig propConfig)
        {
            DbCommonCommand command = m_editPropertyCommand.Value;

            command["ID"].Value = propConfig.Id;
            command["CODE_NAME"].Value = propConfig.CodeName;
            command["DESCRIPTION"].Value = propConfig.Description;
            command["DEFAULT_VALUE"].Value = propConfig.DefaultValue;
            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }
Exemplo n.º 4
0
        public override DomainObjectConfigCollection LoadObject()
        {
            DbCommonCommand command = null;
            IDbCommonDataReader reader = null;

            m_objectConfig = new DomainObjectConfigCollection();

            #region Загрузка объектов
            command = m_loadObjectCommand.Value;

            using (reader = command.ExecuteReader(SessionIdentifier.SHARED_SESSION))
            {
                while (reader.Read())
                {
                    long id = reader.GetValue<long>(0);
                    string code = reader.GetValue<String>(1);
                    string description = reader.GetValue<String>(2);
                    string tableName = reader.GetValue<String>(3);
                    string idField = reader.GetValue<String>(4);
                    string codeName = reader.GetValue<String>(5);

                    DomainObjectConfig configObject = new DomainObjectConfig(id, code, description, tableName, idField, codeName);
                    m_objectConfig.Add(configObject);
                }
                reader.Close();
            }
            #endregion

            #region Загрузка свойств
            command = m_loadPropertyCommand.Value;

            using (reader = command.ExecuteReader(SessionIdentifier.SHARED_SESSION))
            {
                while (reader.Read())
                {
                    long id = reader.GetValue<long>(0);
                    string code = reader.GetValue<String>(1);
                    string description = reader.GetValue<String>(2);
                    string ownerCode = reader.GetValue<String>(3);

                    string dataTypeName = reader.GetValue<String>(4);
                    string assemblyFile = reader.GetValue<String>(5);
                    Type dataType = GetValueType(assemblyFile, dataTypeName);

                    string filedName = reader.GetValue<String>(6);
                    object defaultValue = reader.GetValue(7, typeof(object));
                    int length = reader.GetValue<Int32>(8);
                    string codeName = reader.GetValue<String>(9);

                    DomainObjectConfig owner = m_objectConfig[ownerCode];
                    DomainPropertyConfig property = new DomainPropertyConfig(id, code, description, owner, dataType, filedName, defaultValue, length, codeName);

                    owner.Property.Add(property);
                }
                reader.Close();
            }
            #endregion

            return m_objectConfig;
        }
Exemplo n.º 5
0
        public override void DeleteObjectProperty(DomainPropertyConfig propConfig)
        {
            DbCommonCommand command = m_removePropertyCommand.Value;

            command["ID"].Value = propConfig.Id;
            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }
Exemplo n.º 6
0
        public override void CreateObjectProperty(DomainPropertyConfig propConfig)
        {
            DbCommonCommand command = m_createPropertyCommand.Value;

            command["ID"].Value = propConfig.Id;
            command["CODE"].Value = propConfig.Code;
            command["CODE_NAME"].Value = propConfig.CodeName;
            command["DESCRIPTION"].Value = propConfig.Description;
            command["ID_ORM_CONFIG_OBJECT"].Value = propConfig.Owner.Id;
            command["DATA_TYPE"].Value = propConfig.DataType.ToString();
            command["ASSEMBLY_FILE"].Value = propConfig.DataType.Assembly.ManifestModule.Name;
            command["FIELD_NAME"].Value = propConfig.FieldName;
            command["DEFAULT_VALUE"].Value = propConfig.DefaultValue;
            command["FIELD_LENGTH"].Value = propConfig.Size;
            command.ExecuteNonQuery(SessionIdentifier.SHARED_SESSION);
        }
Exemplo n.º 7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string code = txtCode.Text.Trim();
                string codeName = txtCodeName.Text.Trim();

                if (String.IsNullOrEmpty(code))
                {
                    MessageBox.Show(EditPropertyFormLocalization.EnterPropertyCodeMessage);
                    return;
                }

                if (String.IsNullOrEmpty(codeName))
                {
                    MessageBox.Show(EditPropertyFormLocalization.EnterPropertyFieldNameMessage);
                    return;
                }

                if (m_property == null && m_object.Property.Contains(code))
                {
                    MessageBox.Show(GetPropertyAlreadyExistMessage(code));
                    return;
                }

                Type dataType = (Type)txtDataType.SelectedItem;
                string description = txtDescription.Text.Trim();
                object defaultValue = null;
                int length = (int)txtLength.Value;

                try
                {
                    defaultValue = GetDefaultValue();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format(EditPropertyFormLocalization.GetDefaultValueErrorMessage, ex.Message));
                    return;
                }

                if (m_property == null)
                {
                    m_property = m_inquiry.CreateProperty(m_object, code, description, dataType, String.Format("P_{0}", code), defaultValue, length, codeName);
                }
                else
                {
                    m_inquiry.SaveProperty(m_property, codeName, description, defaultValue);
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 8
0
 private void AppendPropertyConfigNode(DomainObjectInquiry inquiry, TreeListNode objPropertiesNode, DomainPropertyConfig prop)
 {
     AppendNode(objPropertiesNode, GetNodeTitle(prop), new ObjectExplorerNodeTag(inquiry, eObjectExplorerNode.ObjectPropertyConfig, prop));
 }
Exemplo n.º 9
0
 public abstract void SaveObjectProperty(DomainPropertyConfig propConfig);
Exemplo n.º 10
0
 public PropertyConfigArgs(DomainPropertyConfig property)
 {
     Property = property;
 }
Exemplo n.º 11
0
 public EditPropertyConfigArgs(DomainPropertyConfig property, string prevCodeName)
     : base(property)
 {
     PrevCodeName = prevCodeName;
 }
Exemplo n.º 12
0
        public void SaveProperty(DomainPropertyConfig property, string newCodeName, string newDescription, object newDefaultValue)
        {
            if (!Utils.CheckEnglishString(newCodeName))
            {
                throw new ArgumentOutOfRangeException("newCodeName", Resources.OnlyLatinString);
            }

            string prevCodeName = property.CodeName;
            property.Update(newCodeName, newDescription, newDefaultValue);

            m_provider.SaveObjectProperty(property);

            if (EditPropertyCompleted != null)
                EditPropertyCompleted(this, new EditPropertyConfigArgs(property, prevCodeName));

            IsModified = true;
        }
Exemplo n.º 13
0
        public void DeleteProperty(DomainPropertyConfig property)
        {
            m_provider.DeleteObjectProperty(property);

            DomainObjectConfig baseObject = AObject[property.Owner.Code];
            Connection.RemoveTableField(baseObject.TableName, property.FieldName);

            baseObject.Property.Delete(property.Code);

            if (DeletePropertyCompleted != null)
                DeletePropertyCompleted(this, new PropertyConfigArgs(property));

            IsModified = true;
        }
Exemplo n.º 14
0
        public DomainPropertyConfig CreateProperty(DomainObjectConfig baseObject, string code, string description, Type dataType, string fieldName, object defaultValue, int length, string codeName)
        {
            if (!Utils.CheckEnglishString(code))
            {
                throw new ArgumentOutOfRangeException("code", Resources.OnlyLatinString);
            }

            if (!Utils.CheckEnglishString(fieldName))
            {
                throw new ArgumentOutOfRangeException("fieldName", Resources.OnlyLatinString);
            }

            if (!Utils.CheckEnglishString(codeName))
            {
                throw new ArgumentOutOfRangeException("codeName", Resources.OnlyLatinString);
            }

            if (baseObject.Property.Contains(code))
                throw new DomainException(String.Format("Свойство с кодом '{0}' уже существует.", code));

            long newId = Connection.NewSequence();
            DomainPropertyConfig property = new DomainPropertyConfig(newId, code, description, baseObject, dataType, fieldName, defaultValue, length, codeName);

            m_provider.CreateObjectProperty(property);

            Connection.AddTableField(baseObject.TableName, fieldName, dataType, length, defaultValue);

            baseObject.Property.Add(property);

            if (CreatePropertyCompleted != null)
                CreatePropertyCompleted(this, new PropertyConfigArgs(property));

            IsModified = true;

            return property;
        }
Exemplo n.º 15
0
        public static string DomainPropertyCode(DomainPropertyConfig propConfig)
        {
            CodeMemberField propertyCodeConst = null;
            CodeMemberProperty prop = null;
            DomainPropertyCode(propConfig, out propertyCodeConst, out prop);

            CodeDomProvider provider = CreateProvider();
            CodeGeneratorOptions createGeneratorOptions = CreateGeneratorOptions();

            StringBuilder resultCode = new StringBuilder();
            using (StringWriter sourceWriter = new StringWriter(resultCode))
            {
                provider.GenerateCodeFromMember(propertyCodeConst, sourceWriter, createGeneratorOptions);
                provider.GenerateCodeFromMember(prop, sourceWriter, createGeneratorOptions);
            }

            return resultCode.ToString();
        }
Exemplo n.º 16
0
        private static void DomainPropertyCode(DomainPropertyConfig propConfig, out CodeMemberField propertyCodeConst, out CodeMemberProperty prop)
        {
            string propConstName = String.Format("Prop{0}", propConfig.CodeName);
            propertyCodeConst = new CodeMemberField
            {
                Attributes = MemberAttributes.Public | MemberAttributes.Const,
                Name = propConstName,
                Type = new CodeTypeReference(typeof(String)),
                InitExpression = new CodePrimitiveExpression(propConfig.Code)
            };

            SetSummaryComment(propertyCodeConst, String.Format("Код свойства '{0}'", propConfig.Description));

            prop = new CodeMemberProperty()
            {
                Name = propConfig.CodeName,
                Attributes = MemberAttributes.Public | MemberAttributes.Final,
                Type = new CodeTypeReference(propConfig.DataType)
            };

            CodeArrayIndexerExpression propIndexer = new CodeArrayIndexerExpression(
                            new CodeVariableReferenceExpression(PropertiesField),
                            new CodeVariableReferenceExpression(propConstName));

            prop.GetStatements.Add(new CodeMethodReturnStatement(new CodeCastExpression(propConfig.DataType, new CodeFieldReferenceExpression(propIndexer, PropertyValueField))));

            prop.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(propIndexer, PropertyValueField), new CodePropertySetValueReferenceExpression()));
            SetSummaryComment(prop, propConfig.Description);
        }
Exemplo n.º 17
0
 public void DeletePropertyConfig(DomainObjectInquiry inquiry, DomainPropertyConfig property)
 {
     if (MessageBox.Show(String.Format(UILocalization.DeleteEntityObjectPropertyQuestion, property.Code), UILocalization.DeleteEntityObjectPropertyCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         inquiry.DeleteProperty(property);
     }
 }
Exemplo n.º 18
0
 private static string GetNodeTitle(DomainPropertyConfig prop)
 {
     return String.Format("{0} ({1})", prop.Code, prop.Description);
 }
Exemplo n.º 19
0
        public void EditPropertyConfig(DomainObjectInquiry inquiry, DomainPropertyConfig property)
        {
            DomainObjectConfig parentObject = inquiry.AObject[property.Owner.Code];

            using (EditPropertyForm form = new EditPropertyForm(inquiry, parentObject, property))
            {
                form.ShowDialog();
            }
        }