示例#1
0
        public Employee Save()
        {
            bool     result   = true;
            Database database = new Database("Employer");

            database.BeginTransaction();

            if (base.IsNew == true && IsSavable() == true)
            {
                result = Insert(database);
            }
            else if (base.Deleted == true && base.IsDirty == true)
            {
                result = Delete(database);
            }
            else if (base.IsNew == false && IsSavable() == true)
            {
                result = Update(database);
            }

            if (result == true)
            {
                base.IsDirty = false;
                base.IsNew   = false;
            }

            //SAVE THE CHILDREN
            if (result == true && _Phones != null && _Phones.IsSavable() == true)
            {
                result = Phones.Save(database);
            }



            if (result == true)
            {
                database.EndTransaction();
            }
            else
            {
                database.RollBack();
            }
            return(this);
        }
示例#2
0
        public void Save(string businessKey)
        {
            //
            // Create a command object to invoke the stored procedure
            //
            SqlCommand cmd = new SqlCommand("net_businessEntity_contact_save", ConnectionManager.GetConnection());

            cmd.Transaction = ConnectionManager.GetTransaction();
            cmd.CommandType = CommandType.StoredProcedure;

            //
            // Parameters
            //
            cmd.Parameters.Add(new SqlParameter("@businessKey", SqlDbType.UniqueIdentifier)).Direction = ParameterDirection.Input;
            cmd.Parameters.Add(new SqlParameter("@useType", SqlDbType.NVarChar, UDDI.Constants.Lengths.UseType)).Direction       = ParameterDirection.Input;
            cmd.Parameters.Add(new SqlParameter("@personName", SqlDbType.NVarChar, UDDI.Constants.Lengths.PersonName)).Direction = ParameterDirection.Input;
            cmd.Parameters.Add(new SqlParameter("@contactID", SqlDbType.BigInt)).Direction = ParameterDirection.Output;

            //
            // Set parameter values and execute query
            //
            SqlParameterAccessor parmacc = new SqlParameterAccessor(cmd.Parameters);

            parmacc.SetGuidFromString("@businessKey", businessKey);
            parmacc.SetString("@personName", PersonName);
            parmacc.SetString("@useType", UseType);

            cmd.ExecuteScalar();

            //
            // Move out parameters into local variables
            //
            long ContactID = parmacc.GetLong("@contactID");

            //
            // Save sub-objects
            //
            Descriptions.Save(ContactID, EntityType.Contact);
            Phones.Save(ContactID);
            Emails.Save(ContactID);
            Addresses.Save(ContactID);
        }