Esempio n. 1
0
		// ------------------------------------------------------------------

		/// <summary>
		/// Load an object by a given ID.
		/// </summary>
		public static CustomerPerson GetByID(
			int id )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetCustomerPersonByID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@ID", id )
				) );

			if ( row == null )
			{
				return null;
			}
			else
			{
				CustomerPerson o = new CustomerPerson();
				o.Load( row );

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}
Esempio n. 2
0
		/// <summary>
		/// Load all for the given parent.
		/// </summary>
		public static CustomerPerson[] GetForCompany(
			CustomerCompany parentObject )
		{
			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"GetCustomerPersonByCustomerCompanyID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@ID", parentObject.ID )
				) );

			if ( table == null )
			{
				return null;
			}
			else
			{
				ArrayList result = new ArrayList();

				foreach ( DataRow row in table.Rows )
				{
					CustomerPerson o = new CustomerPerson();
					o.Load( row );

					if ( !o.IsEmpty )
					{
						result.Add( o );
					}
				}

				if ( result.Count <= 0 )
				{
					return null;
				}
				else
				{
					return (CustomerPerson[])result.ToArray(
						typeof( CustomerPerson ) );
				}
			}
		}
Esempio n. 3
0
		private void newCustomerPersonButton_Click( 
			object sender, 
			EventArgs e )
		{
			DBObjects.CustomerPerson item =
				customerPersonComboBox.SelectedItem as
				DBObjects.CustomerPerson;

			DBObjects.CustomerCompany selectedCompany =
				customerCompanyComboBox.SelectedItem as
				DBObjects.CustomerCompany;

			DBObjects.CustomerCompany company = item==null?selectedCompany:item.Company;
			DBObjects.CustomerPerson person = new DBObjects.CustomerPerson();

			CustomerPersonEditForm form = new CustomerPersonEditForm( 
				company,
				person );
			if ( form.ShowDialog( this ) == DialogResult.OK )
			{
				FillCustomerPersonList( company );
				FillGroupList( company );
				SelectCustomerPerson( person );
			}
		}
Esempio n. 4
0
		private void newpersonToolStripMenuItem_Click(
			object sender,
			EventArgs e )
		{
			DBObjects.CustomerCompany company =
				customerCompanyTreeView.SelectedNode.Tag as
				DBObjects.CustomerCompany;

			DBObjects.CustomerPerson person =
				new DBObjects.CustomerPerson();

			CustomerPersonEditForm form =
				new CustomerPersonEditForm(
				company,
				person );

			form.ShowDialog( this );
		}
Esempio n. 5
0
		/// <summary>
		/// Load all for the given parent.
		/// </summary>
		public static Ticket[] GetForCustomerPerson(
			CustomerPerson parentObject )
		{
			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"SELECT * FROM [Tickets] WHERE [CustomerPersonID]=@ID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@ID", parentObject.ID )
				) );

			if ( table == null )
			{
				return null;
			}
			else
			{
				ArrayList result = new ArrayList();

				foreach ( DataRow row in table.Rows )
				{
					Ticket o = new Ticket();
					o.Load( row );

					if ( !o.IsEmpty )
					{
						result.Add( o );
					}
				}

				if ( result.Count <= 0 )
				{
					return null;
				}
				else
				{
					return (Ticket[])result.ToArray(
						typeof( Ticket ) );
				}
			}
		}
		private void newToolStripMenuItem_Click( 
			object sender, 
			EventArgs e )
		{
			// Must store parent before adding child.
			Store();

			DBObjects.CustomerPerson person = 
				new DBObjects.CustomerPerson();

			CustomerPersonEditForm form = 
				new CustomerPersonEditForm( item, person );

			if ( form.ShowDialog( this ) == DialogResult.OK )
			{
				FillPersonsList();
			}
		}
Esempio n. 7
0
		public static CustomerPerson GetForCrmPerson(
			Crm.CrmPerson crmPerson )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetCustomerPersonFromCrmPerson",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@PersonID", crmPerson.ID )
				) );

			if ( row == null )
			{
				return null;
			}
			else
			{
				CustomerPerson o = new CustomerPerson();
				o.Load( row );

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}
Esempio n. 8
0
		public static CustomerPerson GetByCrmReplicationUniqueID(
			Guid crmReplicationUniqueID )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetCustomerPersonByCrmReplicationUniqueID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@CrmReplicationUniqueID", crmReplicationUniqueID )
				) );

			if ( row == null )
			{
				return null;
			}
			else
			{
				CustomerPerson o = new CustomerPerson();
				o.Load( row );

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}