Ejemplo n.º 1
0
 public void UpdateCheckSendDate(Acct_check check, int letterStageNum, DateTime dateSend)
 {
     if (check != null)
     {
         CheckSQL.UpdateAcct_checkLetterSendDate(check, letterStageNum, dateSend);
     }
 }
Ejemplo n.º 2
0
        /*  ---------------------------------------------------------------
         *  FUNCTION - UpdateCheck
         *  ---------------------------------------------------------------
         *  update an existing check record
         *
         *  if the new information cannot produce a valid check, return null
         *  otherwise, return the account with its new info
         */
        public Acct_check UpdateCheck(
            string origRoutNum, string origAcctNum, string origCheckNum,
            string newRoutNum, string newAcctNum, string newCheckNum, Decimal newAmount, DateTime newDateWritten, bool newPaidStatus)
        {     //if there is an attempt to change the routing number or account number or check number
            if (origRoutNum != newRoutNum || origAcctNum != newAcctNum || origCheckNum != newCheckNum)
            { //if there was already a check with that routing number and account number and check number
                //  return null to signify failure
                //  since we don't want to update a check's unique info
                //  to another check's unique info
                if (VerifyExistingCheck(newRoutNum, newAcctNum, newCheckNum))
                {
                    return(null);
                }
            }
            //otherwise, pull the orignial check and build an Acct_check object that will have the new information
            Acct_check origCheck    = CheckSQL.SelectAcct_check(origRoutNum, origAcctNum, origCheckNum);
            Acct_check newInfoCheck = BuildNewCheck(newRoutNum, newAcctNum, newAmount, newDateWritten,
                                                    newCheckNum, origCheck.Date_received, newPaidStatus);

            //if we cannot build that object due to bad bank or account info, return null
            if (newInfoCheck == null)
            {
                return(null);
            }
            //otherwise, update the account with the new information and return an Account object with the new info
            else
            {
                CheckSQL.UpdateAcct_checkPaidStatus(newInfoCheck, newPaidStatus);
                return(CheckSQL.UpdateAcct_check(origCheck, newInfoCheck));
            };
        }
Ejemplo n.º 3
0
 /*  -----------------------------------------------------
  *  FUNCTION - GetClient
  *  -----------------------------------------------------
  *  return a Client object corresponding to the
  *      client_id of <check>
  *  ------------------------------------------------------
  */
 public Client GetClient(Acct_check check)
 {
     return((
                from c in cpdb.Clients
                where c.Client_id == check.Client_id
                select c
                ).FirstOrDefault());
 }
Ejemplo n.º 4
0
 /*  -----------------------------------------------------
  *  FUNCTION - GetLastName
  *  -----------------------------------------------------
  *
  * ------------------------------------------------------
  */
 public string GetLastName(Acct_check prmAcctCheck)
 {
     return((
                from ac in cpdb.Acct_checks
                join a in cpdb.Accounts on ac.Account_id equals a.Account_id
                where ac.Acct_check_id == prmAcctCheck.Acct_check_id
                select a.Last_name
                ).FirstOrDefault());
 }
Ejemplo n.º 5
0
 /*  -----------------------------------------------------
  *  FUNCTION - GetRoutingNumber
  *  -----------------------------------------------------
  *
  * ------------------------------------------------------
  */
 public string GetRoutingNumber(Acct_check acctCheck)
 {
     return((
                from ac in cpdb.Acct_checks
                join a in cpdb.Accounts on ac.Account_id equals a.Account_id
                join b in cpdb.Banks on a.Bank_id equals b.Bank_id
                where ac.Acct_check_id == acctCheck.Acct_check_id
                select b.Routing_number
                ).FirstOrDefault());
 }
Ejemplo n.º 6
0
        /*  ---------------------------------------------------------------
         *  FUNCTION - GetClient
         *  ---------------------------------------------------------------
         *  return the Client object corresponding to Client_id of <check>
         *
         *  return null if no check record corresponds to <check>
         *  ---------------------------------------------------------------
         */
        public Client GetClient(Acct_check check)
        {
            Acct_check tstCheck = CheckSQL.SelectAcct_check(check);

            if (tstCheck != null)
            {
                return(CheckSQL.GetClient(tstCheck));
            }
            return(null);
        }
Ejemplo n.º 7
0
        public Acct_check DeleteCheck(Acct_check check)
        {
            Acct_check tstCheck = CheckSQL.SelectAcct_check(check);

            if (tstCheck != null)
            {
                return(CheckSQL.DeleteAcct_check(tstCheck));
            }
            return(null);
        }
Ejemplo n.º 8
0
        /*  ---------------------------------------------------------------
         *  FUNCTION - DeleteCheck
         *  ---------------------------------------------------------------
         *  delete an existing acct_check record with <routNum> and <acctNum> and <checkNum>
         *
         *  if no existing acct_check exists, return a null record
         */
        public Acct_check DeleteCheck(string routNum, string acctNum, string checkNum)
        {
            Acct_check tstCheck = CheckSQL.SelectAcct_check(routNum, acctNum, checkNum);

            if (tstCheck != null)
            {
                return(CheckSQL.DeleteAcct_check(tstCheck));
            }
            return(null);
        }
Ejemplo n.º 9
0
 public void UpdateAcct_checkPaidStatus(Acct_check check, bool isPaid)
 {
     if (isPaid)
     {
         check.Date_paid = DateTime.Today;
     }
     else
     {
         check.Date_paid = null;
     }
     cpdb.SaveChanges();
 }
Ejemplo n.º 10
0
        public bool VerifyExistingCheck(string routNum, string acctNum, string checkNum)
        {
            Acct_check tstCheck = CheckHand.SelectCheck(routNum, acctNum, checkNum);

            if (tstCheck == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 11
0
        /*  -----------------------------------------------------
         *  FUNCTION - UpdateAcct_check
         *  -----------------------------------------------------
         *
         * ------------------------------------------------------
         */
        public Acct_check UpdateAcct_check(Acct_check origCheck, Acct_check newInfoCheck)
        {
            origCheck.Account_id    = newInfoCheck.Account_id;
            origCheck.Amount        = newInfoCheck.Amount;
            origCheck.Check_number  = newInfoCheck.Check_number;
            origCheck.Date_written  = newInfoCheck.Date_written;
            origCheck.Date_received = newInfoCheck.Date_received;
            origCheck.Date_paid     = newInfoCheck.Date_paid;
            origCheck.Amount_paid   = newInfoCheck.Amount_paid;

            cpdb.SaveChanges();

            return(SelectAcct_check(origCheck.Acct_check_id));
        }
Ejemplo n.º 12
0
 /*  -----------------------------------------------------
  *  FUNCTION - SelectAcct_check
  *  -----------------------------------------------------
  *  attempts to SELECT from the database an acct_check of
  *      <prmAcctCheck>
  *      <routNum> and <acctNum> and <checkNum>
  *      <acctCheckID>
  * ------------------------------------------------------
  */
 public Acct_check SelectAcct_check(Acct_check prmAcctCheck)
 {
     if (prmAcctCheck == null)
     {
         return(null);
     }
     else
     {
         return((
                    from ac in cpdb.Acct_checks
                    where ac.Acct_check_id == prmAcctCheck.Acct_check_id
                    select ac
                    ).FirstOrDefault());
     }
 }
Ejemplo n.º 13
0
        /*  -----------------------------------------------------
         *  FUNCTION - DeleteAcct_check
         *  -----------------------------------------------------
         *  attempts to delete a database acct_check record that
         *      corresponds to <prmAcctCheck> Acct_check object
         *  if there was no corresponding record,
         *      return null
         *      and utilize that knowledge accordingly
         * ------------------------------------------------------
         */
        public Acct_check DeleteAcct_check(Acct_check acctCheck)
        {
            Acct_check tstAcct_check = (
                from ac in cpdb.Acct_checks
                where ac.Acct_check_id == acctCheck.Acct_check_id
                select ac
                ).FirstOrDefault();

            if (tstAcct_check != null)
            {
                cpdb.Acct_checks.Remove(tstAcct_check);
                cpdb.SaveChanges();
            }

            return(tstAcct_check);
        }
Ejemplo n.º 14
0
        public void UpdateAcct_checkLetterSendDate(Acct_check check, int letterStageNum, DateTime dateSent)
        {
            switch (letterStageNum)
            {
            case 1:
                check.Letter1_send_date = dateSent;
                break;

            case 2:
                check.Letter2_send_date = dateSent;
                break;

            case 3:
                check.Letter3_send_date = dateSent;
                break;

            default:
                break;
            }
            cpdb.SaveChanges();
        }
Ejemplo n.º 15
0
        /*  -----------------------------------------------------
         *  FUNCTION - InsertAcct_check
         *  -----------------------------------------------------
         *
         *  -----------------------------------------------------
         */
        public Acct_check InsertAcct_check(Acct_check prmAcctCheck)
        {
            var tstAcct_check = (
                from ac in cpdb.Acct_checks
                where ac.Acct_check_id == prmAcctCheck.Acct_check_id
                select ac
                ).FirstOrDefault();

            Acct_check newAcctCheck;

            if (tstAcct_check == null)
            {
                newAcctCheck = cpdb.Acct_checks.Add(prmAcctCheck);
                cpdb.SaveChanges();
            }
            else
            {
                newAcctCheck = tstAcct_check;
            }

            return(newAcctCheck);
        }
Ejemplo n.º 16
0
        /*  ---------------------------------------------------------------
         *  FUNCTION - InsertCheck
         *  ---------------------------------------------------------------
         *  insert a new account record
         *      after validating that a record with the <routNum> and <acctNum>
         *      does not already exist
         *
         *  if there already was a record with those unique identifiers,
         *      return null to show that no account was added
         */
        public Acct_check InsertCheck(string routNum, string acctNum, Decimal amount, DateTime dateWritten, string checkNum)
        {     //if no check already exists
            if (!VerifyExistingCheck(routNum, acctNum, checkNum))
            { //attempt to build account; if the routing number does not have a bank to connect to, it will return null
                Acct_check newCheck = BuildNewCheck(routNum, acctNum, amount, dateWritten, checkNum, DateTime.Today, false);

                //if a new Acct_check object could not be built, return null
                if (newCheck == null)
                {
                    return(null);
                }
                else
                {   //otherwise, insert a new account record with that new information and return the newly created account
                    return(CheckSQL.InsertAcct_check(newCheck));
                }
            }
            //otherwise, return null to signify that no check was inserted
            else
            {
                return(null);
            }
        }
Ejemplo n.º 17
0
 public void UpdateCheckPaidStatus(Acct_check check, bool isPaid)
 {
     UpdateCheckPaidStatus(check, isPaid);
 }