Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <PartnerDTO> GetPartners()
        {
            List <PartnerDTO> retVal = new List <PartnerDTO>();

            try
            {
                DataSet ds = new ProjectDB(Utility.ConfigurationHelper.GPD_Connection).GetPartners();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        PartnerDTO tempPartnerDTO = new PartnerDTO();
                        tempPartnerDTO.partnerId        = dr["partner_id"].ToString();
                        tempPartnerDTO.Name             = dr["name"].ToString();
                        tempPartnerDTO.URL              = dr["site_url"].ToString();
                        tempPartnerDTO.ShortDescription = dr["short_description"].ToString();
                        tempPartnerDTO.Description      = dr["description"].ToString();
                        tempPartnerDTO.IsActive         = Convert.ToBoolean(dr["active"]);
                        retVal.Add(tempPartnerDTO);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Unable to get partners", ex);
            }
            return(retVal);
        }
Beispiel #2
0
    protected int getQuantity(int id)
    {
        int quantity = 0;

        try
        {
            string        commandText = "SELECT [Quantity] FROM [dbo].[RewardItem] WHERE [RewardID] = @RewardID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@RewardID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                quantity = (int)reader["Quantity"];
            }
            conn.Close();
        }
        catch (Exception)
        {
            error += "<br/>Error Getting Quantity.";
        }
        return(quantity);
    }
Beispiel #3
0
    protected Decimal getPoints(int id)
    {
        Decimal points = 0;

        try
        {
            string        commandText = "SELECT [Points] FROM [dbo].[Employee] WHERE [EmployeeID] = @EmployeeID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@EmployeeID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                points = (Decimal)reader["Points"];
            }
            conn.Close();
        }
        catch (Exception)
        {
        }
        return(points);
    }
Beispiel #4
0
    protected int getLoginID(string userName)
    {
        try
        {
            string        commandText = "SELECT TOP 1 EmpLoginID FROM [DBO].[EMPLOYEELOGIN] WHERE UserName = @UserName";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);
            select.Parameters.AddWithValue("@UserName", userName);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                int empLoginID = (int)reader["EmpLoginID"];
                conn.Close();
                return(empLoginID);
            }
            else
            {
                return(-1);
            }
        }
        catch (Exception ex)
        {
            errorMessage.Text += "\n" + ex;
            return(-1);
        }
    }
Beispiel #5
0
    protected int findEmployeeID(int id)
    {
        int employeeID = -1;

        try
        {
            String        commandText = "Select EmployeeID from [dbo].[EMPLOYEE] WHERE EmpLoginID = @EmpLoginID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@EmpLoginID", id);
            SqlDataReader reader = select.ExecuteReader();
            if (reader.HasRows)
            {
                reader.Read();
                employeeID = (int)reader["EmployeeID"];
            }
            conn.Close();
            return(employeeID);
        }
        catch (Exception)
        {
            error += "<br/>Error Finding EmployeeID";
            return(employeeID);
        }
    }
    //
    protected Transaction findTransaction(int id)
    {
        try
        {
            string        commandText = "SELECT TOP 1 Cost, PurchaseTime, EmployeeID, RewardID FROM [DBO].[TRANSACTION] WHERE TransactionID = @TransactionID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@TransactionID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                Decimal  cost         = (Decimal)reader["Cost"];
                DateTime purchaseTime = (DateTime)reader["PurchaseTime"];
                int      employeeID   = (int)reader["EmployeeID"];
                int      rewardID     = (int)reader["RewardID"];

                Transaction tran = new Transaction(id, cost, purchaseTime, employeeID, rewardID);
                conn.Close();
                return(tran);
            }
        }
        catch (Exception)
        {
            errorMessage.Text += "Error Finding Transaction ";
        }
        errorMessage.Text += "Reached end of transaction";
        return(null);
    }
    protected string findImage(int id)
    {
        string img = "~/Images/DefaultImg.jpg";

        try
        {
            string        commandText = "SELECT TOP 1 ImageURL from [dbo].[Image] WHERE EmployeeID = @EmployeeID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@EmployeeID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                img = reader["ImageURL"].ToString();
            }

            conn.Close();
            return(img);
        }
        catch (Exception)
        {
            errorMessage.Text = "Error Finding Image ";
            return(img);
        }
    }
Beispiel #8
0
    protected int findEmployeeID(int id)
    {
        int employeeID = 0;

        try
        {
            string        commandText = "SELECT TOP 1 EmployeeID FROM [DBO].[EMPLOYEE] WHERE EmpLoginID = @EmpLoginID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@EmpLoginID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();

                employeeID = (int)reader["EmployeeID"];
            }
            conn.Close();
            return(employeeID);
        }
        catch (Exception ex)
        {
            Error.Text += "Error finding employee ID" + ex;
            return(-1);
        }
    }
Beispiel #9
0
    protected int findMax()
    {
        int max = -1;

        try
        {
            string        commandText = "SELECT MAX(AchievementID) as Result FROM [Dbo].[Achievement]";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                max = (int)reader["Result"];
            }
            conn.Close();
            return(max);
        }
        catch (Exception ex)
        {
            Error.Text += "Error finding max achievement ID. " + ex;
            return(-1);
        }
    }
Beispiel #10
0
    /// <summary>
    /// This method inserts the employee information into the database
    /// </summary>
    /// <param name="employee">This is the employee that we are committing to the database</param>
    /// <param name="admin">This is the user logged in</param>
    protected void insertEmployee(Employee employee)
    {
        try
        {
            string commandText = "insert into [dbo].[employee] ([FirstName],[LastName],[Email],[LastUpdatedBy],[LastUpdated],[EmpLoginID],[Points],[Enabled],[CompanyID],[LandingPage],[Nickname],[UseNickname],[UseAnon])" +
                                 "values (@FirstName, @LastName, @Email, @LastUpdatedBy, @LastUpdated, @EmpLoginID, @Points, @Enabled, @CompanyID, @LandingPage, @Nickname, @UseNickname, @UseAnon)";
            SqlConnection conn   = ProjectDB.connectToDB();
            SqlCommand    insert = new SqlCommand(commandText, conn);

            //add the information via parameters
            insert.Parameters.AddWithValue("@FirstName", employee.FirstName);
            insert.Parameters.AddWithValue("@LastName", employee.LastName);
            insert.Parameters.AddWithValue("@Email", employee.Email);
            insert.Parameters.AddWithValue("@LastUpdatedBy", employee.LastUpdatedBy);
            insert.Parameters.AddWithValue("@LastUpdated", employee.LastUpdated);
            insert.Parameters.AddWithValue("@EmpLoginID", employee.Login);
            insert.Parameters.AddWithValue("@Points", employee.Points);
            insert.Parameters.AddWithValue("@Enabled", 1);
            insert.Parameters.AddWithValue("@CompanyID", employee.CompanyID);
            insert.Parameters.AddWithValue("@LandingPage", employee.Landing);
            insert.Parameters.AddWithValue("@Nickname", DBNull.Value);
            insert.Parameters.AddWithValue("@UseNickname", 0);
            insert.Parameters.AddWithValue("@UseAnon", 0);

            //execute the insert statement
            insert.ExecuteNonQuery();
            conn.Close();
        }
        catch (Exception ex)
        {
            //if the insert statement fails then display the message
            errorMessage.Text += "Error Inserting Employee into DB" + ex;
        }
    }
Beispiel #11
0
    private void SearchEmployee()
    {
        if (txtSearchTeamMember.Text != "")
        {
            GVTeamMember.Visible = true;
        }
        SqlConnection conn = ProjectDB.connectToDB();

        using (System.Data.SqlClient.SqlCommand insert = new System.Data.SqlClient.SqlCommand())
        {
            string commandText = "SELECT EmployeeID, (FirstName + ' ' + LastName) as FullName FROM Employee";
            if (!string.IsNullOrEmpty(txtSearchTeamMember.Text.Trim()))
            {
                commandText += " WHERE FirstName LIKE '%' + @FirstName + '%' OR LastName LIKE '%' + @LastName + '%'";
                insert.Parameters.AddWithValue("@FirstName", txtSearchTeamMember.Text.Trim());
                insert.Parameters.AddWithValue("@LastName", txtSearchTeamMember.Text.Trim());
            }
            insert.CommandText = commandText;
            insert.Connection  = conn;
            using (SqlDataAdapter sda = new SqlDataAdapter(insert))
            {
                DataTable dt = new DataTable();
                sda.Fill(dt);
                GVTeamMember.DataSource = dt;
                GVTeamMember.DataBind();
            }


            conn.Close();
        }
    }
Beispiel #12
0
    protected string findEmployeeName(int id)
    {
        string name = "";

        try
        {
            string        commandText = "SELECT TOP 1 [FirstName],[LastName] FROM [dbo].[Employee] WHERE [EmployeeID] = @EmployeeID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@EmployeeID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                string firstName = reader["FirstName"].ToString();
                string lastName  = reader["LastName"].ToString();
                name = firstName + " " + lastName;
            }
            conn.Close();
            return(name);
        }
        catch (Exception ex)
        {
            TopRecieving.Text += " " + ex;
            return(name);
        }
    }
Beispiel #13
0
    protected void ReceivingTop()
    {
        try
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = ConfigurationSettings.AppSettings.
                                   SqlConnection conn = ProjectDB.connectToDB();
            string toprec = "  Select TOP 5(SUM(PointsAmount)) as TotalPoints, RecEmployee FROM Achievement WHERE CompanyID = @CompanyID GROUP BY RecEmployee ORDER BY TotalPoints DESC;";
            System.Data.SqlClient.SqlCommand select = new System.Data.SqlClient.SqlCommand(toprec, conn);
            select.Parameters.AddWithValue("@CompanyID", user.CompanyID);

            SqlDataReader reader      = select.ExecuteReader();
            int           points      = 0;
            int           recEmployee = 0;
            while (reader.Read())
            {
                points             = (int)reader["TotalPoints"];
                recEmployee        = (int)reader["RecEmployee"];
                TopRecieving.Text += "Employee Name: " + findEmployeeName(recEmployee) + Environment.NewLine + "Total Points Recieved:" + points + Environment.NewLine + Environment.NewLine;
            }
            conn.Close();
        }
        catch (Exception)
        {
        }
    }
Beispiel #14
0
        public List <GroupDTO> GetGroups()
        {
            List <GroupDTO> retVal = new List <GroupDTO>();

            try
            {
                DataSet ds = new ProjectDB(Utility.ConfigurationHelper.GPD_Connection).GetGroups();

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        retVal.Add(
                            new GroupDTO()
                        {
                            GroupId     = Convert.ToInt32(dr["group_id"].ToString()),
                            Name        = dr["name"].ToString(),
                            Description = dr["description"].ToString(),
                            IsActive    = Convert.ToBoolean(dr["active"])
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Unable to get partners", ex);
            }
            return(retVal);
        }
    /// <summary>
    /// Finds the information related to the specified achievement id
    ///
    /// </summary>
    /// <param name="id">This is the achievement id that you are trying to find</param>
    /// <returns>Returns an array of objects that is equal to the achievement information in the database</returns>
    protected Achievement findAchievement(int id)
    {
        try
        {
            string        commandText = "SELECT TOP 1 Description, Date, PointsAmount, EmployeeID, ValueID, RecEmployee FROM [DBO].[ACHIEVEMENT] WHERE AchievementID = @AchievementID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@AchievementID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                string   description = reader["Description"].ToString();
                DateTime date        = (DateTime)reader["Date"];
                int      points      = (int)reader["PointsAmount"];
                int      employeeID  = (int)reader["EmployeeID"];
                int      valueID     = (int)reader["ValueID"];
                int      recEmployee = (int)reader["RecEmployee"];
                conn.Close();
                Achievement a = new Achievement(id, description, date, points, employeeID, valueID, recEmployee);
                return(a);
            }

            conn.Close(); //remove later
        }
        catch (Exception)
        {
            errorMessage.Text += "Error Finding Achievement ";
        }
        errorMessage.Text += "Reached end of Achievement";
        return(null);
    }
Beispiel #16
0
    protected Decimal totalEarned()
    {
        Decimal funds = 0;

        try
        {
            string        commandText = "SELECT SUM([Points]) as Result FROM [dbo].[Employee] where CompanyID = @CompanyID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);
            select.Parameters.AddWithValue("@CompanyID", user.CompanyID);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                funds = (Decimal)reader["Result"];
            }
            conn.Close();
        }
        catch (Exception)
        {
        }
        return(funds);
    }
    protected string findEmployee(int id)
    {
        string employeeName = "";

        try
        {
            string        commandText = "SELECT TOP 1 FirstName, LastName FROM [DBO].[EMPLOYEE] WHERE EmployeeID = @EmployeeID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@EmployeeID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                string firstName = reader["FirstName"].ToString();
                string lastName  = reader["LastName"].ToString();
                employeeName = firstName + " " + lastName;
                conn.Close();
                return(employeeName);
            }
            conn.Close(); //remove later
        }
        catch (Exception)
        {
            errorMessage.Text += "Error Finding Employee";
        }
        return(employeeName);
    }
Beispiel #18
0
    protected Decimal currentFunds()
    {
        Decimal earned = 0;

        try
        {
            string        commandText = "SELECT SUM([Amount]) as Result FROM [dbo].[Fund] where CompanyID = @CompanyID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);
            select.Parameters.AddWithValue("@CompanyID", user.CompanyID);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                earned = (Decimal)reader["Result"];
            }
            conn.Close();
        }
        catch (Exception)
        {
        }
        return(earned);
    }
    protected int findLikes(int postID)
    {
        int likes = -1;

        try
        {
            string        commandText = "SELECT TOP 1 NumOfLikes FROM [dbo].[FeedInformation] WHERE PostID = @PostID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@PostID", postID);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                likes = (int)reader["NumOfLikes"];
            }
            conn.Close();
            return(likes);
        }
        catch (Exception)
        {
            errorMessage.Text += "Error finding number of likes ";
            return(likes);
        }
    }
Beispiel #20
0
    public void sendItem()
    {
        try
        {
            //calls the method to create the item
            createItem();
            SqlConnection conn = ProjectDB.connectToDB();
            System.Data.SqlClient.SqlCommand insert = new System.Data.SqlClient.SqlCommand();
            insert.Connection = conn;

            insert.CommandText = "insert into [dbo].[RewardItem] values (@name, @description, @price, @startdate, @enddate, @quantity, @lastupdatedby, @lastupdated, @providerid, @categoryid, @companyID)";
            insert.Parameters.AddWithValue("@name", item.Name);
            insert.Parameters.AddWithValue("@description", item.Description);
            insert.Parameters.AddWithValue("@price", item.Price);
            insert.Parameters.AddWithValue("@startdate", item.StartDate);
            insert.Parameters.AddWithValue("@enddate", item.EndDate);
            insert.Parameters.AddWithValue("@quantity", item.Quantity);
            insert.Parameters.AddWithValue("@lastupdatedby", item.LastUpdatedBy);
            insert.Parameters.AddWithValue("@lastupdated", item.LastUpdated);
            insert.Parameters.AddWithValue("@providerid", findProviderID(txtProvider.SelectedValue));
            insert.Parameters.AddWithValue("@categoryid", findCategoryID(txtCategory.SelectedValue));
            insert.Parameters.AddWithValue("@companyID", user.CompanyID);
            insert.ExecuteNonQuery();
            conn.Close();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Reward Added Successfully')", true);
            clearFields();
        }
        //Shows an error message if there is a problem connecting to the database
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('data connection error')", true);
            //Label9.Text += " " + ex;
        }
    }
    protected string getRewardName(int id)
    {
        string name = "";

        try
        {
            string        commandText = "SELECT [Name] FROM [dbo].[RewardItem] WHERE [RewardID] = @RewardID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@RewardID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                name = reader["Name"].ToString();
            }
            conn.Close();
        }
        catch (Exception)
        {
        }
        return(name);
    }
Beispiel #22
0
    //finds the id of the category that was selected
    public int findCategoryID(String categoryName)
    {
        try
        {
            String        commandText = "Select CategoryID from [dbo].[RewardCategory] WHERE Description = @categoryname";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@categoryname", categoryName);
            SqlDataReader reader = select.ExecuteReader();
            if (reader.HasRows)
            {
                reader.Read();
                int categoryID = (int)reader["CategoryID"];
                conn.Close();
                return(categoryID);
            }
        }
        catch (Exception)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('error finding categoryID')", true);
            return(-1);
        }
        return(-1);
    }
Beispiel #23
0
    protected void SubmitMoney_Click(object sender, EventArgs e)
    {
        SqlConnection conn        = ProjectDB.connectToDB();
        string        commandText = "iNSERT INTO Points (PointDeposit, Date, Updated By)";

        System.Data.SqlClient.SqlCommand insert = new System.Data.SqlClient.SqlCommand(commandText, conn);
    }
Beispiel #24
0
    /// <summary>
    /// Finds the max employee login id to be used to enter the next
    /// </summary>
    /// <returns>Returns the max employee login id</returns>
    protected int findMaxLoginID()
    {
        int max = -1;

        try
        {
            string        commandText = "SELECT MAX(EmpLoginID) as Result FROM [DBO].[EMPLOYEELOGIN]";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                max = (int)reader["Result"];
            }
            conn.Close();
        }
        catch (Exception ex)
        {
            errorMessage.Text += "Error Finding Max " + ex;
        }
        return(max);
    }
Beispiel #25
0
    protected int findRecentTransaction()
    {
        int a = -1;

        try
        {
            string        commandText = "SELECT MAX(TransactionID) as Result FROM [dbo].[Transaction]";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                a = (int)reader["Result"];
            }
            conn.Close();
        }
        catch (Exception)
        {
            error += "<br/>Error Finding Recent Transactions.";
        }
        return(a);
    }
Beispiel #26
0
    /// <summary>
    /// This method inserts the employee information into the database
    /// </summary>
    /// <param name="employee">This is the employee that we are committing to the database</param>
    /// <param name="admin">This is the user logged in</param>
    protected void insertEmployee(Employee employee)
    {
        try
        {
            string commandText = "INSERT INTO [DBO].[EMPLOYEE] ([FIRSTNAME],[LASTNAME],[EMAIL],[LASTUPDATEDBY],[LASTUPDATED],[EMPLOGINID],[POINTS]) " +
                                 "VALUES (@FirstName, @LastName, @Email, @LastUpdatedBy, @LastUpdated, @EmpLoginID, @Points)";
            SqlConnection conn   = ProjectDB.connectToDB();
            SqlCommand    insert = new SqlCommand(commandText, conn);

            //add the information via parameters
            insert.Parameters.AddWithValue("@FirstName", employee.FirstName);
            insert.Parameters.AddWithValue("@LastName", employee.LastName);
            insert.Parameters.AddWithValue("@Email", employee.Email);
            insert.Parameters.AddWithValue("@LastUpdatedBy", user.FirstName + " " + user.LastName);
            insert.Parameters.AddWithValue("@LastUpdated", DateTime.Now);
            insert.Parameters.AddWithValue("@EmpLoginID", findMaxLoginID());
            insert.Parameters.AddWithValue("@Points", 0);

            //execute the insert statement
            insert.ExecuteNonQuery();
            conn.Close();
        }
        catch (Exception ex)
        {
            //if the insert statement fails then display the message
            errorMessage.Text += "Error Inserting Employee into DB" + ex;
        }
    }
Beispiel #27
0
    protected string findImage(int id)
    {
        string img = "https://s3.amazonaws.com/484imagescourtney/default.jpg";

        try
        {
            string        commandText = "SELECT TOP 1 ImageURL from [dbo].[Image] WHERE RewardID = @RewardID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@RewardID", id);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                img = reader["ImageURL"].ToString();
            }

            conn.Close();
            return(img);
        }
        catch (Exception ex)
        {
            errorMessage.Text = "Error Finding Image " + ex;
            return(img);
        }
    }
Beispiel #28
0
    /// <summary>
    /// Commit the changes made to the text boxes populated after the gridview is selected
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void commitChanges(object sender, EventArgs e)
    {
        try
        {
            //establish connection
            string        commandText = "UPDATE [DBO].[EMPLOYEE] set [FirstName] = @FirstName, [LastName] = @LastName, [Email] = @Email WHERE [EmployeeID] = @EmployeeID";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    update      = new SqlCommand(commandText, conn);

            //add values to the parameters
            update.Parameters.AddWithValue("@FirstName", txtEditFirstName.Text);
            update.Parameters.AddWithValue("@LastName", txtEditLastName.Text);
            update.Parameters.AddWithValue("@Email", txtEditEmail.Text);
            update.Parameters.AddWithValue("@EmployeeID", employeeID);

            //execute query, close connection, and refresh the gridview
            update.ExecuteNonQuery();
            conn.Close();
            employeeGrid.DataBind();
            selectMode();
        }
        catch (Exception ex)
        {
            errorMessage.Text += "Error committing edited user to the database. " + ex;
        }
    }
Beispiel #29
0
    protected int countRewards()
    {
        int count = 0;

        try
        {
            string        commandText = "SELECT COUNT(RewardID) as Result FROM [dbo].[RewardItem] WHERE [EndDate] >= @EndDate AND [StartDate] <= @StartDate AND [Quantity] > @Quantity";
            SqlConnection conn        = ProjectDB.connectToDB();
            SqlCommand    select      = new SqlCommand(commandText, conn);

            select.Parameters.AddWithValue("@EndDate", DateTime.Now);
            select.Parameters.AddWithValue("@StartDate", DateTime.Now);
            select.Parameters.AddWithValue("@Quantity", 0);

            SqlDataReader reader = select.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                count = (int)reader["Result"];
            }
            conn.Close();
        }
        catch (Exception)
        {
            error += "<br/>There are no reward available.";
        }
        return(count);
    }
Beispiel #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <UserRoleDTO> GetUserRoles(int userId)
        {
            List <UserRoleDTO> retVal = new List <UserRoleDTO>();

            try
            {
                DataSet ds = new ProjectDB(Utility.ConfigurationHelper.GPD_Connection).GetUserRoles(userId);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        UserRoleDTO tempUserRole = new UserRoleDTO();
                        tempUserRole.UserId      = userId;
                        tempUserRole.GroupId     = Convert.ToInt32(dr["group_id"].ToString());
                        tempUserRole.GroupName   = dr["GroupName"].ToString();
                        tempUserRole.PartnerId   = dr["partner_id"].ToString();
                        tempUserRole.PartnerName = dr["PartnerName"].ToString();
                        retVal.Add(tempUserRole);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Unable to Actctivate/Dactivate user for userId: " + userId, ex);
            }
            return(retVal);
        }