예제 #1
0
        // ------------------------- ValidateLogin ------------------------------
        public virtual AcAccountMasterRow ValidateLogin(
            AcPage InPage,
            string InAccountNbr,
            string InEmailAddress,
            string InPassword)
        {
            AcAccountMasterRow row = null;

            try
            {
                row = Chain(InPage, InAccountNbr);
            }
            catch (AccountMasterException)
            {
                throw(new LoginException("Invalid account"));
            }

            // verify the password.
            if (row.Password != InPassword)
            {
                throw(new LoginException("Incorrect password"));
            }

            return(row);
        }
예제 #2
0
        // ------------------------- GetAccounts ------------------
        // return DataSet containing all the accounts.
        public virtual DataSet GetAccounts(AcPage InPage)
        {
            SqlDataAdapter da       = null;
            SqlCommand     cmd      = null;
            SqlConnection  conn     = null;
            DataSet        accounts = null;

            try
            {
                conn            = InPage.GetDatabaseConnection( );
                cmd             = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;

                cmd.CommandText =
                    "SELECT * " +
                    " FROM " + TableName +
                    " ORDER BY AccountNbr";

                da = new SqlDataAdapter( );
                da.SelectCommand = cmd;

                accounts = new DataSet();
                da.Fill(accounts, "Accounts");
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }

            return(accounts);
        }
예제 #3
0
        // ------------------------- Delete ----------------------------
        // delete account master by AccountNbr
        public virtual void Delete(
            AcPage InPage, string InAccountNbr)
        {
            SqlConnection conn = null;
            SqlCommand    cmd;

            try
            {
                conn = InPage.GetDatabaseConnection( );

                cmd             = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@AccountNbr", InAccountNbr));
                cmd.CommandText =
                    "DELETE " + TableName +
                    " WHERE AccountNbr = @AccountNbr";

                cmd.ExecuteNonQuery( );
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }
        }
예제 #4
0
        // ----------------------- AddNewAccount ---------------------------
        public virtual AcAccountMasterRow AddNewAccount(
            AcPage InPage,
            AcAccountMasterRow InRow)
        {
            AcAccountMasterRow AddRow = null;

            // error check.  ConfirmPassword and Password must match.
            if (InRow.ConfirmPassword != InRow.Password)
            {
                throw(new AccountMasterException("Confirm password mismatch"));
            }

            // do the insert until a unique AccountNbr is assigned.
            while (true)
            {
                AddRow            = NewRowCopy(InRow);
                AddRow.AccountNbr = CalcRandomAccountNbr( );
                AddRow.CreateTs   = DateTime.Now;

                try
                {
                    Add(InPage, AddRow);
                }
                catch (SqlException excp)
                {
                    if (AutoCoder.Common.IsDuplicateKeyExcp(excp) == true)
                    {
                        continue;
                    }
                    throw(excp);
                }
                break;
            }             // end do while duplicate insert key
            return(AddRow);
        }
예제 #5
0
        // -------------------------- Update --------------------------
        public virtual void Update(
            AcPage InPage,
            string InLoadId,
            AcLoadMasterRow InNewRow)
        {
            SqlConnection conn = null;
            SqlCommand    cmd  = new SqlCommand( );

            try
            {
                conn            = InPage.GetDatabaseConnection( );
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@WhereLoadId", InLoadId));
                cmd.Parameters.Add(new SqlParameter("@LoadId", InNewRow.LoadId));
                cmd.Parameters.Add(new SqlParameter("@SessionId", InNewRow.SessionId));
                cmd.Parameters.Add(new SqlParameter("@Seqn", InNewRow.Seqn));
                cmd.Parameters.Add(new SqlParameter("@PageName", InNewRow.PageName));
                cmd.Parameters.Add(new SqlParameter("@PageFileName", InNewRow.PageFileName));
                cmd.Parameters.Add(new SqlParameter("@PageDirPath", InNewRow.PageDirPath));
                cmd.Parameters.Add(new SqlParameter("@LoadTs", InNewRow.LoadTs));
                cmd.Parameters.Add(new SqlParameter("@LastPostbackTs", InNewRow.LastPostbackTs));
                cmd.Parameters.Add(new SqlParameter("@PostbackCx", InNewRow.PostbackCx));
                cmd.Parameters.Add(new SqlParameter("@ReferrerLoadId", InNewRow.ReferrerLoadId));
                cmd.Parameters.Add(new SqlParameter("@RawUrl", InNewRow.RawUrl));


                cmd.CommandText =
                    "UPDATE " + TableName +
                    " SET LoadId = @LoadId, " +
                    "SessionId = @SessionId, " +
                    "Seqn = @Seqn, " +
                    "PageName = @PageName, " +
                    "PageFileName = @PageFileName, " +
                    "PageDirPath = @PageDirPath, " +
                    "LoadTs = @LoadTs, " +
                    "LastPostbackTs = @LastPostbackTs, " +
                    "PostbackCx = @PostbackCx, " +
                    "ReferrerLoadId = @ReferrerLoadId, " +
                    "RawUrl = @RawUrl" +
                    " WHERE LoadId = @WhereLoadId";
                cmd.ExecuteNonQuery( );
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }
        }
예제 #6
0
        // -------------------------- Add --------------------------------
        public virtual AcLoadMasterRow Add(
            AcPage InPage,
            AcLoadMasterRow InRow)
        {
            SqlConnection conn = null;

            // assign a LoadId
            if (InRow.LoadId == null)
            {
                InRow.LoadId = System.Guid.NewGuid( ).ToString( );
            }

            try
            {
                conn = InPage.GetDatabaseConnection( );
                SqlCommand cmd = new SqlCommand();

                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@LoadId", InRow.LoadId));
                cmd.Parameters.Add(new SqlParameter("@SessionId", InRow.SessionId));
                cmd.Parameters.Add(new SqlParameter("@Seqn", InRow.Seqn));
                cmd.Parameters.Add(new SqlParameter("@PageName", InRow.PageName));
                cmd.Parameters.Add(new SqlParameter("@PageFileName", InRow.PageFileName));
                cmd.Parameters.Add(new SqlParameter("@PageDirPath", InRow.PageDirPath));
                cmd.Parameters.Add(new SqlParameter("@LoadTs", InRow.LoadTs));
                cmd.Parameters.Add(new SqlParameter("@LastPostbackTs", InRow.LastPostbackTs));
                cmd.Parameters.Add(new SqlParameter("@PostbackCx", InRow.PostbackCx));
                cmd.Parameters.Add(new SqlParameter("@ReferrerLoadId", InRow.ReferrerLoadId));
                cmd.Parameters.Add(new SqlParameter("@RawUrl", InRow.RawUrl));

                cmd.CommandText =
                    "INSERT " + TableName + " ( " +
                    "LoadId, SessionId, Seqn, PageName, PageFileName, PageDirPath, " +
                    "LoadTs, LastPostbackTs, PostbackCx, ReferrerLoadId, RawUrl ) " +
                    "Values( @LoadId, @SessionId, @Seqn, @PageName, @PageFileName, @PageDirPath, " +
                    "@LoadTs, @LastPostbackTs, @PostbackCx, @ReferrerLoadId, @RawUrl )";
                cmd.ExecuteNonQuery();
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }
            return(InRow);
        }
예제 #7
0
        // -------------------------- Add --------------------------------
        public virtual AcVisitorMasterRow Add(
            AcPage InPage,
            AcVisitorMasterRow InRow)
        {
            SqlConnection conn = null;

            try
            {
                conn = InPage.GetDatabaseConnection( );
                SqlCommand cmd = new SqlCommand();

                // assign the VisitorId
                if (InRow.VisitorId == null)
                {
                    InRow.VisitorId = System.Guid.NewGuid( ).ToString( );
                }
                if (InRow.UserId == null)
                {
                    InRow.UserId = "";
                }

                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@VisitorId", InRow.VisitorId));
                cmd.Parameters.Add(new SqlParameter("@UserId", InRow.UserId));

                cmd.CommandText =
                    "INSERT " + TableName + " ( " +
                    "VisitorId, UserId ) " +
                    "Values( @VisitorId, @UserId )";
                cmd.ExecuteNonQuery();
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }
            return(InRow);
        }
예제 #8
0
        // -------------------------- Add --------------------------------
        public virtual UserMasterRow Add(
            AcPage InPage,
            UserMasterRow InRow)
        {
            SqlConnection conn = null;

            try
            {
                conn = InPage.GetDatabaseConnection( );
                SqlCommand cmd = new SqlCommand();

                // assign the UserId
                if (InRow.UserId == null)
                {
                    InRow.UserId = System.Guid.NewGuid( ).ToString( );
                }

                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@UserId", InRow.UserId));
                cmd.Parameters.Add(new SqlParameter("@Password", InRow.Password));
                cmd.Parameters.Add(new SqlParameter("@UserName", InRow.UserName));
                cmd.Parameters.Add(new SqlParameter("@EmailAddress", InRow.EmailAddress));

                cmd.CommandText =
                    "Insert " + TableName + " ( " +
                    "UserId, Password, UserName, EmailAddress ) " +
                    "Values( @UserId, @Password, @UserName, @EmailAddress )";
                cmd.ExecuteNonQuery();
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }
            return(InRow);
        }
예제 #9
0
        // -------------------------- Update --------------------------
        public virtual void Update(
            AcPage InPage,
            string InAccountNbr,
            AcAccountMasterRow InNewRow)
        {
            SqlConnection conn = null;
            SqlCommand    cmd  = new SqlCommand( );

            try
            {
                conn            = InPage.GetDatabaseConnection( );
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@WhereAccountNbr", InAccountNbr));
                cmd.Parameters.Add(new SqlParameter("@AccountNbr", InNewRow.AccountNbr));
                cmd.Parameters.Add(new SqlParameter("@AccountName", InNewRow.AccountName));
                cmd.Parameters.Add(new SqlParameter("@Password", InNewRow.Password));
                cmd.Parameters.Add(new SqlParameter("@EmailAddress", InNewRow.EmailAddress));
                cmd.Parameters.Add(new SqlParameter("@CreateTs", InNewRow.CreateTs));

                cmd.CommandText =
                    "UPDATE " + TableName +
                    "SET AccountNbr = @AccountNbr, " +
                    "AccountName = @AccountName, " +
                    "Password = @Password, " +
                    "EmailAddress = @EmailAddress, " +
                    "CreateTs = @CreateTs " +
                    "WHERE AccountNbr = @WhereAccountNbr";
                cmd.ExecuteNonQuery( );
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }
        }
예제 #10
0
        // -------------------------- Add --------------------------------
        public virtual AcAccountMasterRow Add(
            AcPage InPage,
            AcAccountMasterRow InRow)
        {
            SqlConnection conn = null;

            ValidityCheck(InRow);

            try
            {
                conn = InPage.GetDatabaseConnection( );
                SqlCommand cmd = new SqlCommand();

                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@AccountNbr", InRow.AccountNbr));
                cmd.Parameters.Add(new SqlParameter("@AccountName", InRow.AccountName));
                cmd.Parameters.Add(new SqlParameter("@Password", InRow.Password));
                cmd.Parameters.Add(new SqlParameter("@EmailAddress", InRow.EmailAddress));
                cmd.Parameters.Add(new SqlParameter("@CreateTs", InRow.CreateTs));

                cmd.CommandText =
                    "INSERT " + TableName + " ( " +
                    "AccountNbr, AccountName, Password, EmailAddress, CreateTs ) " +
                    "Values( @AccountNbr, @AccountName, @Password, @EmailAddress, @CreateTs )";
                cmd.ExecuteNonQuery();
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }
            return(InRow);
        }