/// <summary>
		/// Load for the given parent.
		/// </summary>
		public static CustomerCompanySupportContract GetForCustomerCompany(
			CustomerCompany parentObject )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetCustomerCompanySupportContractByCustomerCompanyCrmReplicationUniqueID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@CrmReplicationUniqueID", parentObject.CrmReplicationUniqueID )
				) );

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

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

		/// <summary>
		/// Load all.
		/// </summary>
		public static CustomerCompany[] GetCustomersWithUnbilledBillableTickets(
			DateTime forMonth )
		{
			DateTime startDate = new DateTime( forMonth.Year, forMonth.Month, 1 );
			DateTime endDate = startDate.AddMonths( 1 );

			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"GetAllCustomerCompaniesWithUnbilledBillableTickets",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@StartDate", startDate ),
				AdoNetSqlParamCollection.CreateParameter( "@EndDate", endDate )
				) );

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

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

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

				if ( result.Count <= 0 )
				{
					return null;
				}
				else
				{
					return (CustomerCompany[])result.ToArray(
						typeof( CustomerCompany ) );
				}
			}
		}
Example #3
0
		/// <summary>
		/// Get all distinct group names of all tickets of one customer.
		/// </summary>
		public static string[] GetDistinctGroupNamesForCustomerCompany(
			CustomerCompany parentObject )
		{
			int companyID = 0;
			if ( parentObject != null )
			{
				companyID = parentObject.ID;
			}

			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"GetDistinctGroupNamesByCustomerCompanyID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@CustomerCompanyID", companyID )
				) );

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

				foreach ( DataRow row in table.Rows )
				{
					string v;
					DBHelper.ReadField( out v, row[0] );

					result.Add( v );
				}

				if ( result.Count <= 0 )
				{
					return null;
				}
				else
				{
					return (string[])result.ToArray(
						typeof( string ) );
				}
			}
		}
Example #4
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 ) );
				}
			}
		}
Example #5
0
		private void newCustomerCompanyButton_Click( 
			object sender, 
			EventArgs e )
		{
			DBObjects.CustomerCompany company = new DBObjects.CustomerCompany();

			CustomerCompanyEditForm form = new CustomerCompanyEditForm( company );
			if ( form.ShowDialog( this ) == DialogResult.OK )
			{
				FillCustomerCompanyList();
				SelectCustomerCompany( company );
			}
		}
Example #6
0
		private void newCustomerCompanyToolStripMenuItem_Click(
			object sender,
			EventArgs e )
		{
			DBObjects.CustomerCompany company = new DBObjects.CustomerCompany();

			CustomerCompanyEditForm form = new CustomerCompanyEditForm( company );
			form.Show( this );
		}
Example #7
0
		/// <summary>
		/// Load all for the given parent.
		/// </summary>
		public static Ticket[] GetForCustomerCompanyAssignedToUser(
			CustomerCompany parentObject,
			User user )
		{
			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"GetTicketsForCustomerCompanyAssignedToUser",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@ID", parentObject.ID ),
				AdoNetSqlParamCollection.CreateParameter( "@UserSamName", user.SamName )
				) );

			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 ) );
				}
			}
		}
Example #8
0
		/// <summary>
		/// Load all for the given parent.
		/// </summary>
		public static Ticket[] GetUnbilledBillableForCustomerCompany(
			CustomerCompany parentObject,
			DateTime forMonth )
		{
			DateTime startDate = new DateTime( forMonth.Year, forMonth.Month, 1 );
			DateTime endDate = startDate.AddMonths( 1 );

			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"GetUnbilledBillableTicketsByCustomerCompanyID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@CustomerCompanyID", parentObject.ID ),
				AdoNetSqlParamCollection.CreateParameter( "@StartDate", startDate ),
				AdoNetSqlParamCollection.CreateParameter( "@EndDate", endDate )
				) );

			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 ) );
				}
			}
		}
		public static CustomerCompany GetByCrmReplicationUniqueID(
			Guid crmReplicationUniqueID )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetCustomerCompanyByCrmReplicationUniqueID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@CrmReplicationUniqueID", crmReplicationUniqueID )
				) );

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

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}
Example #10
0
		public static CustomerCompany GetForCrmAddress( 
			Crm.CrmAddress crmAddress )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetCustomerCompanyFromCrmAddress",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@AddressID", crmAddress.ID )
				) );

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

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}
Example #11
0
		/// <summary>
		/// Load all that have a ticket associated.
		/// </summary>
		/// <param name="getInfo"></param>
		public static CustomerCompany[] Get(
			CustomerCompanyGetInformation getInfo )
		{
			DataTable table = null;

			if ( getInfo.CustomerGetType == 
				CustomerCompanyGetType.CustomersWithTickets )
			{
				table = AdoNetSqlHelper.ExecuteTable(
					"GetAllCustomerCompaniesWithTickets",
					new AdoNetSqlParamCollection(
					AdoNetSqlParamCollection.CreateParameter( "@FilterText", getInfo.IsFilterTextActive?getInfo.FilterText:string.Empty )
					) );
			}
			else if ( getInfo.CustomerGetType ==
				CustomerCompanyGetType.CustomersWithTicketsForOwn )
			{
				table = AdoNetSqlHelper.ExecuteTable(
					"GetAllCustomerCompaniesWithTickets",
					new AdoNetSqlParamCollection(
					AdoNetSqlParamCollection.CreateParameter( "@FilterText", getInfo.IsFilterTextActive ? getInfo.FilterText : string.Empty ),
					AdoNetSqlParamCollection.CreateParameter( "@UserSamName", getInfo.UserSamName )
					) );
			}
			else if ( getInfo.CustomerGetType ==
				CustomerCompanyGetType.AllCustomers )
			{
				table = AdoNetSqlHelper.ExecuteTable(
					"GetAllCustomerCompanies",
					new AdoNetSqlParamCollection(
					AdoNetSqlParamCollection.CreateParameter( "@FilterText",
					getInfo.IsFilterTextActive ? getInfo.FilterText : string.Empty )
					) );
			}
			else
			{
				Debug.Assert( false );
			}

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

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

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

				if ( result.Count <= 0 )
				{
					return null;
				}
				else
				{
					return (CustomerCompany[])result.ToArray(
						typeof( CustomerCompany ) );
				}
			}
		}
Example #12
0
		/// <summary>
		/// Load all that have a ticket associated.
		/// </summary>
		public static CustomerCompany[] GetAllWithTickets()
		{
			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"GetAllCustomerCompaniesWithTickets",
				new AdoNetSqlParamCollection(
				) );

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

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

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

				if ( result.Count <= 0 )
				{
					return null;
				}
				else
				{
					return (CustomerCompany[])result.ToArray(
						typeof( CustomerCompany ) );
				}
			}
		}
Example #13
0
		/// <summary>
		/// Load an object by a given ID.
		/// </summary>
		public static CustomerCompany GetByID(
			int id )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetCustomerCompanyByID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@ID", id )
				) );

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

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