Esempio n. 1
0
        public AccountVinHold GetAccountVinHoldByID(int hid)
        {
            AccountVinHold hold        = new AccountVinHold();
            string         queryString = "SELECT * FROM dbo.Absences WHERE HID = @hid";

            using (SqlConnection connection = new SqlConnection(GlobalVars.DBConnection["Conn"].ToString()))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.AddWithValue("@hid", hid);

                try
                {
                    connection.Open();

                    DataTable dt = new DataTable();
                    dt.Load(command.ExecuteReader());
                    hold = Setup(dt.Rows[0]);
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    connection.Close();
                }
                return(hold);
            }
        }
Esempio n. 2
0
        public string AccountVinOnHoldReason(Absence absence)
        {
            string holdReason = "";

            AccountVinHold _holdsRepo = new AccountVinHold();

            if (absence.CustomerID != null)
            {
                List <AccountVinHold> holds = _holdsRepo.GetAccountVinHoldsByAccountID(absence.CustomerID);

                if (holds != null && holds.Count() > 0 && absence.Type != 4001)
                {
                    return(holds[0].Description.ToString() + " [" + GetUserByHRESID(holds[0].RequestedByID) + " " + holds[0].RequestedOn + "]");

                    foreach (AccountVinHold hold in holds)
                    {
                        //Dealer Account on Hold
                        if (hold.HoldType == 1)
                        {
                            return("Account on hold");

                            if (absence.CustomerID == hold.AccountNum)
                            {
                                holdReason = hold.Notes;
                                break;
                            }
                        }
                        //VIN on hold
                        else if (hold.HoldType == 2)
                        {
                            return("VIN on hold");

                            if (absence.VIN == hold.VIN)
                            {
                                holdReason = hold.Notes;
                                break;
                            }
                        }
                        //VRA on hold
                        else if (hold.HoldType == 3)
                        {
                            return("VRA on hold");
                            //might have to add VRA to absences in future?
                        }
                    }
                }
            }
            return(holdReason);
        }
Esempio n. 3
0
        public bool IsAccountVinOnHold(Absence absence)
        {
            bool isOnHold = false;

            AccountVinHold _holdsRepo = new AccountVinHold();

            if (absence.CustomerID != null)
            {
                List <AccountVinHold> holds = _holdsRepo.GetAccountVinHoldsByAccountID(absence.CustomerID);

                if (holds != null && holds.Count > 0 && absence.Type != 4001)
                {
                    foreach (AccountVinHold hold in holds)
                    {
                        //check to see if status is not 'released'
                        if (hold.Status == 1 && absence.Status != 3 /* closed */ && absence.Status != 2 /* rejected */)
                        {
                            //Dealer Account on Hold
                            if (hold.HoldType == 1)
                            {
                                if (absence.CustomerID == hold.AccountNum)
                                {
                                    return(true);
                                }
                            }
                            //VIN on hold
                            else if (hold.HoldType == 2)
                            {
                                if (absence.VIN == hold.VIN)
                                {
                                    return(true);
                                }
                            }
                            //VRA on hold
                            else if (hold.HoldType == 3)
                            {
                                //might have to add VRA to absences in future?

                                //return true
                            }
                        }
                    }
                }
            }
            return(isOnHold);
        }
Esempio n. 4
0
        }                               //1 = hold   3 = released

        public AccountVinHold Setup(DataRow r)
        {
            AccountVinHold hold = new AccountVinHold();

            hold.HID           = Convert.ToInt32(r["HID"]);
            hold.Type          = Convert.ToInt32(r["Type"]);
            hold.RequestedByID = Convert.ToInt32(r["EmpID"]);
            hold.RequestedOn   = DBNull.Value.Equals(r["StartDate"]) ? Convert.ToDateTime(r["syscreated"]) : Convert.ToDateTime(r["StartDate"]);
            hold.Description   = DBNull.Value.Equals(r["Description"]) ? null : r["Description"].ToString();
            hold.HoldType      = Convert.ToInt32(r["FreeTextField_02"]);
            hold.HoldReason    = r["FreeTextField_03"].ToString();
            hold.AccountNum    = r["CustomerID"].ToString();
            hold.VIN           = DBNull.Value.Equals(r["FreeTextField_01"]) ? null : r["FreeTextField_01"].ToString();
            hold.VRA           = DBNull.Value.Equals(r["FreeNumberField_01"]) ? -1 : Convert.ToInt32(r["FreeNumberField_01"]);
            hold.Notes         = DBNull.Value.Equals(r["WorkflowComments"]) ? null : r["WorkflowComments"].ToString();
            hold.Status        = Convert.ToInt32(r["Status"]);

            return(hold);
        }