Ejemplo n.º 1
0
        public List <Budget> GetBudgetForEMP(Employee employee)
        {
            List <Budget> budgets = new List <Budget>();
            int           CurrentBudget, Minbudget, Maxbudget, projectid;
            string        Projectname;

            using (SqlConnection con = new SqlConnection(connectionstring))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("Spu_Focus_GetBudgetForEID", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@EID", employee.ID));
                    SqlDataReader Reader = cmd.ExecuteReader();



                    if (Reader.HasRows)
                    {
                        while (Reader.Read())
                        {
                            Projectname = Reader["ProjektName"].ToString();
                            projectid   = int.Parse(Reader["ProjektID"].ToString());

                            if (Reader["BudgetMin"] == DBNull.Value)
                            {
                                Minbudget = 0;
                            }
                            else
                            {
                                Minbudget = int.Parse(Reader["BudgetMin"].ToString());
                            }



                            if (Reader["BudgetMax"] == DBNull.Value)
                            {
                                Maxbudget = 0;
                            }
                            else
                            {
                                Maxbudget = int.Parse(Reader["BudgetMax"].ToString());
                            }


                            if (Reader["CurrentBudget"] == DBNull.Value)
                            {
                                CurrentBudget = 0;
                            }
                            else
                            {
                                CurrentBudget = int.Parse(Reader["CurrentBudget"].ToString());
                            }

                            Project project = new Project(Projectname, projectid);
                            Budget  budget  = new Budget(employee, project, CurrentBudget, Minbudget, Maxbudget);
                            budgets.Add(budget);
                        }
                    }
                    // Array.Resize(ref EmpBudget, EmpBudget.Length);

                    return(budgets);
                }

                catch (SqlException e)
                {
                    throw e;
                }
            }
        }
Ejemplo n.º 2
0
        public List <Budget> GetBudgetForProjekt(Project project)
        {
            List <Budget> budgets = new List <Budget>();
            int           EmployeeID, CurrentBudget, Minbudget, Maxbudget;
            string        EmployeeName;

            using (SqlConnection con = new SqlConnection(connectionstring))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("Spu_Focus_GetBudgetForPID", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@ProjectID", project.ProjectID));
                    SqlDataReader Reader = cmd.ExecuteReader();



                    if (Reader.HasRows)
                    {
                        while (Reader.Read())
                        {
                            EmployeeID = int.Parse(Reader["EmployeeID"].ToString());
                            if (Reader["CurrentBudget"] == DBNull.Value)
                            {
                                CurrentBudget = 0;
                            }
                            else
                            {
                                CurrentBudget = int.Parse(Reader["CurrentBudget"].ToString());
                            }

                            EmployeeName = Reader["EmployeeName"].ToString();
                            if (Reader["BudgetMin"] == DBNull.Value)
                            {
                                Minbudget = 0;
                            }
                            else
                            {
                                Minbudget = int.Parse(Reader["BudgetMin"].ToString());
                            }
                            if (Reader["BudgetMax"] == DBNull.Value)
                            {
                                Maxbudget = 0;
                            }
                            else
                            {
                                Maxbudget = int.Parse(Reader["BudgetMax"].ToString());
                            }

                            Employee employee = new Employee(EmployeeName, EmployeeID);
                            Budget   budget   = new Budget(employee, project, CurrentBudget, Minbudget, Maxbudget);
                            budgets.Add(budget);
                        }
                    }
                }

                catch (SqlException e)
                {
                    throw e;
                }
            }
            return(budgets);
        }