Esempio n. 1
0
		public static User GetByID(
			int id )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetUserByID",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@ID", id )
				) );

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

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}
Esempio n. 2
0
		private void UserLoginForm_FormClosing( 
			object sender, 
			FormClosingEventArgs e )
		{
			if ( this.DialogResult == DialogResult.OK )
			{
				DBObjects.User user;

				Cursor = Cursors.WaitCursor;
				try
				{
					user =
						DBObjects.User.GetByUserNameAndPassword(
						textBox1.Text.Trim(),
						textBox2.Text );
				}
				finally
				{
					Cursor = Cursors.WaitCursor;
				}

				if ( user==null )
				{
					MessageBox.Show(
						this,
						"Unknown username or wrong password. Please verify that you entered the correct information and try again.",
						"Error during login",
						MessageBoxButtons.OK,
						MessageBoxIcon.Error );

					this.DialogResult = DialogResult.None;
					e.Cancel = true;
				}
				else
				{
					this.user = user;
				}
			}
		}
Esempio n. 3
0
		public static Ticket[] GetAssignedToUser(
			User user,
			TicketEvent.TicketEventState state )
		{
			if ( user == null )
			{
				return null;
			}
			else
			{
				DataTable table = AdoNetSqlHelper.ExecuteTable(
					"GetTicketsAssignedToUserSamNameWithState",
					new AdoNetSqlParamCollection(
					AdoNetSqlParamCollection.CreateParameter( "@UserSamName", user.SamName ),
					AdoNetSqlParamCollection.CreateParameter( "@State", state.ToString() )
					) );

				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 ) );
					}
				}
			}
		}
Esempio n. 4
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 ) );
				}
			}
		}
Esempio n. 5
0
		public static User GetByUserNameAndPassword(
			string samName,
			string password )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetUserBySamNameAndPassword",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@SamName", samName ),
				AdoNetSqlParamCollection.CreateParameter( "@Password", password )
				) );

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

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}
Esempio n. 6
0
		/// <summary>
		/// Load all.
		/// </summary>
		public static User[] GetAll()
		{
			DataTable table = AdoNetSqlHelper.ExecuteTable(
				"GetAllUsers",
				new AdoNetSqlParamCollection(
				) );

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

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

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

				if ( result.Count <= 0 )
				{
					return null;
				}
				else
				{
					return (User[])result.ToArray(
						typeof( User ) );
				}
			}
		}
Esempio n. 7
0
		public static User GetByEMail(
			string emailAddress )
		{
			DataRow row = AdoNetSqlHelper.ExecuteRow(
				"GetUserByEMailAddress",
				new AdoNetSqlParamCollection(
				AdoNetSqlParamCollection.CreateParameter( "@EMailAddress", emailAddress )
				) );

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

				if ( o.IsEmpty )
				{
					return null;
				}
				else
				{
					return o;
				}
			}
		}
Esempio n. 8
0
		public static User GetBySamName(
			string samName )
		{
			if ( string.IsNullOrEmpty( samName ) )
			{
				return null;
			}
			else
			{
				DataRow row = AdoNetSqlHelper.ExecuteRow(
					"GetUserBySamName",
					new AdoNetSqlParamCollection(
					AdoNetSqlParamCollection.CreateParameter( "@SamName", samName )
					) );

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

					if ( o.IsEmpty )
					{
						return null;
					}
					else
					{
						return o;
					}
				}
			}
		}
Esempio n. 9
0
		public static User GetByRow(
			DataRow row )
		{
			User o = new User();
			o.Load( row );

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