Exemplo n.º 1
0
        /// <summary>
        /// 返回SQLCommand
        /// </summary>
        /// <param name="person"></param>
        /// <returns></returns>
        public static SqlCommand InsertBySQLCommand(Person person,string opertion)
        {
            SqlCommand sqlCommand = new SqlCommand();
            if (opertion == "Delete")
            {
                sqlCommand.CommandText = @"Delete from [Person] Where ID =@ID";
                sqlCommand.Parameters.Add(new SqlParameter("@ID", person.ID));
                return sqlCommand;
            }

            if (opertion == "Insert")
            {
                sqlCommand.CommandText = @"INSERT INTO [Person] (SysVersion, Code, Name, Telphone, Address, PostCode,
            Gender, Disabled, NativePlace, CreatedOn, CreatedBy, UpdatedOn, UpdatedBy, ID)
            VALUES (@SysVersion, @Code, @Name, @Telphone, @Address, @PostCode, @Gender, @Disabled,
            @NativePlace, @CreatedOn, @CreatedBy, @UpdatedOn, @UpdatedBy, @ID)";
            }
            if (opertion == "Update")
            {
                sqlCommand.CommandText = @"Update [Person] Set SysVersion =@SysVersion, Code=@Code, Name=@Name, Telphone=@Telphone,
            Address=@Address, PostCode=@PostCode, Gender=@Gender, Disabled= @Disabled, NativePlace=@NativePlace,
            CreatedOn=@CreatedOn, CreatedBy=@CreatedBy, UpdatedOn=@UpdatedOn, UpdatedBy=@UpdatedBy Where ID=@ID";
            }
            sqlCommand.Parameters.Add(new SqlParameter("@SysVersion", person.SysVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@Code", person.Code));
            sqlCommand.Parameters.Add(new SqlParameter("@Name", person.Name));
            sqlCommand.Parameters.Add(new SqlParameter("@Telphone", person.Telphone));
            sqlCommand.Parameters.Add(new SqlParameter("@Address", person.Address));
            sqlCommand.Parameters.Add(new SqlParameter("@PostCode", person.PostCode));
            sqlCommand.Parameters.Add(new SqlParameter("@Gender", person.Gender));
            sqlCommand.Parameters.Add(new SqlParameter("@Disabled", person.Disabled));
            sqlCommand.Parameters.Add(new SqlParameter("@NativePlace", person.NativePlace));
            sqlCommand.Parameters.Add(new SqlParameter("@CreatedOn", person.CreatedOn));
            sqlCommand.Parameters.Add(new SqlParameter("@CreatedBy", person.CreatedBy));
            sqlCommand.Parameters.Add(new SqlParameter("@UpdatedOn", person.UpdatedOn));
            sqlCommand.Parameters.Add(new SqlParameter("@UpdatedBy", person.UpdatedBy));
            sqlCommand.Parameters.Add(new SqlParameter("@ID", person.ID));
            return sqlCommand;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 创建新的实体
 /// </summary>
 /// <param name="code"></param>
 /// <param name="name"></param>
 /// <param name="disabled"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static Person CreatePerson(string code, String name, bool disabled, Guid id)
 {
     var person = new Person();
     person.Birthday = DateTime.Now;
     person.Telphone = "15264183573";
     person.Address = "济南";
     person.PostCode = "250014";
     person.Gender = true;
     person.Disabled = disabled;
     person.NativePlace = "汉";
     if (id != Guid.Empty)
     {
         person.ID = id;
     }
     person.Code = code;
     person.Name = name;
     person.CreatedOn = DateTime.Now;
     person.CreatedBy = "DS";
     person.UpdatedOn = DateTime.Now;
     person.UpdatedBy = "DS";
     return person;
 }
Exemplo n.º 3
0
 public virtual void RemoveChild(Person child)
 {
     this.Persons.Remove(child);
     child.Department = null;
 }
Exemplo n.º 4
0
 public virtual void AddChild(Person child)
 {
     this.Persons.Add(child);
     child.Department = this;
 }