Beispiel #1
0
        /// <summary>
        /// Search for tickets by employee
        /// </summary>
        /// <param name="empT">An EmpTick parameter</param>
        /// <returns></returns>
        public List <EmpTick> SearchEmpTicks(EmpTick empT)
        {
            SqlConnection corpcn = new SqlConnection(Settings.Default.cnHelpDesk);

            var sb = new StringBuilder();

            sb.Append("Select EmpID, TickID ");
            sb.Append("From EmpTick ");
            sb.Append("Where EmpID ='").Append(empT.EmpID).Append("';");

            using (corpcn)
            {
                List <EmpTick> empTicks = new List <EmpTick>();
                SqlCommand     corpCmd  = corpcn.CreateCommand();
                corpCmd.CommandType = CommandType.Text;
                corpCmd.CommandText = sb.ToString();
                corpcn.Open();
                SqlDataReader corprdr = corpCmd.ExecuteReader();

                while (corprdr.Read())
                {
                    EmpTick empTick = CreateEmpTick(corprdr);
                    empTicks.Add(empTick);
                }

                corprdr.Close();
                return(empTicks);
            }
        }
Beispiel #2
0
        private EmpTick CreateEmpTick(SqlDataReader dr)
        {
            var e = new EmpTick();

            e.EmpID  = (int)dr["EmpID"];
            e.TickID = (int)dr["TickID"];
            return(e);
        }
Beispiel #3
0
        /// <summary>
        /// Searchs for a list of tickets by employee
        /// </summary>
        /// <param name="empID">Employee ID</param>
        /// <returns></returns>
        public List <int> SearchEmpTicks(int empID)
        {
            ListEmpTicks();
            List <int> empTickList = new List <int>();
            EmpTick    e1          = new EmpTick();

            foreach (EmpTick empT in etsList)
            {
                if (empT.EmpID == empID)
                {
                    empTickList.Add(empT.TickID);
                }
            }
            //Returns the list of Tickets
            return(empTickList);
        }
Beispiel #4
0
        public int SearchForEmp(int tickID)
        {
            int employeeID = 0;

            ListEmpTicks();
            EmpTick e1 = new EmpTick();

            foreach (EmpTick empT in etsList)
            {
                if (empT.TickID == tickID)
                {
                    employeeID = empT.EmpID;
                }
            }
            //Returns the list of Tickets
            return(employeeID);
        }
Beispiel #5
0
        /// <summary>
        /// Add a EmpTick
        /// </summary>
        /// <param name="emp">An EmpTick parameter</param>
        public void InsertEmpTick(EmpTick emp)
        {
            SqlConnection corpcn = new SqlConnection(Settings.Default.cnHelpDesk);

            var sb = new StringBuilder();

            sb.Append("Insert Into [EmpTick]");
            sb.Append(" ([EmpID], [TickID])");
            sb.Append(" Values (");
            sb.Append("'").Append(emp.EmpID).Append("',");
            sb.Append("'").Append(emp.TickID).Append("');");

            using (corpcn)
            {
                SqlCommand corpCmd = corpcn.CreateCommand();
                corpCmd.CommandType = CommandType.Text;
                corpCmd.CommandText = sb.ToString();
                corpcn.Open();
                corpCmd.ExecuteNonQuery();
            }
        }