Example #1
0
        public void Delete_Department(Params_Delete_Department i_Params_Delete_Department)
        {
            // You should Always create a complex type (Class) which has properties matching parameters

            // 1. Define Your Connection String


            // 2. Create Sql Connection Object
            using (SqlConnection oConn = new SqlConnection(connStr))
            {
                // 3. Open the Connection
                oConn.Open();

                //4 . Prepare Sql Command Object
                using (SqlCommand command = new SqlCommand("UP_DELETE_DEPARTMENT"))
                {
                    //5. Set the Command Type to Stored Procedure
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    //6. Inform the Command on Wich connection it should work
                    command.Connection = oConn;

                    command.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "DEPARTMENT_ID", Value = i_Params_Delete_Department.DEPARTMENT_ID
                    });

                    command.ExecuteNonQuery();
                }
            }
        }
        public List <Employee> Get_Youngest_Employee(Params_Delete_Department i_Params_Delete_Department)
        {
            DALC.DALC oDALC = new DALC.DALC();
            oDALC.connStr = this.connStr;
            List <Employee> oList = oDALC.Get_Youngest_Employee(i_Params_Delete_Department);

            //oList = oList.OrderBy(x => x.NAME).ToList();
            //oList.RemoveAll(x => x.ADDRESS == "Tripoli");
            return(oList);
        }
        //-------------------------------------------------
        public List <Manager> GetAllManagersOfDepartment(Params_Delete_Department i_Params_Delete_Department)
        {
            DALC.DALC oDALC = new DALC.DALC();
            oDALC.connStr = this.connStr;
            List <Manager> oList = oDALC.GetAllManagersOfDepartment(i_Params_Delete_Department);

            //oList = oList.OrderBy(x => x.NAME).ToList();
            //oList.RemoveAll(x => x.ADDRESS == "Tripoli");
            return(oList);
        }
Example #4
0
        public List <Employee> Get_Youngest_Employee(Params_Delete_Department i_Params_Delete_Department)
        {
            List <Employee> oList = new List <Employee>();



            // 2. Create Sql Connection Object
            using (SqlConnection oConn = new SqlConnection(connStr))
            {
                // 3. Open the Connection
                oConn.Open();

                //4 . Prepare Sql Command Object
                using (SqlCommand command = new SqlCommand("UP_GET_YOUNGEST_EMPLOYEE"))
                {
                    //5. Set the Command Type to Stored Procedure
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    //6. Inform the Command on Wich connection it should work
                    command.Connection = oConn;

                    command.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "DEPARTMENT_ID", Value = i_Params_Delete_Department.DEPARTMENT_ID
                    });

                    command.ExecuteNonQuery();
                    // 7. Execute the Command (ExecuteReader)
                    // 8. The Reader is a kind of Hand/Cursor pointing to data retrieved by the Command
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                Employee oEmployee = new Employee();
                                oEmployee.EMPLOYEE_ID   = Convert.ToInt32(reader["EMPLOYEE_ID"]);
                                oEmployee.FIRST_NAME    = Convert.ToString(reader["FIRST_NAME"]);
                                oEmployee.LAST_NAME     = Convert.ToString(reader["LAST_NAME"]);
                                oEmployee.MOBILE        = Convert.ToString(reader["MOBILE"]);
                                oEmployee.AGE           = Convert.ToInt32(reader["AGE"]);
                                oEmployee.SALARY        = Convert.ToDecimal(reader["SALARY"]);
                                oEmployee.DEPARTMENT_ID = Convert.ToInt32(reader["DEPARTMENT_ID"]);
                                oList.Add(oEmployee);
                            }
                        }
                    }
                }
            }



            return(oList);
        }
Example #5
0
        //---------------------------------------------------

        public List <Manager> GetAllManagersOfDepartment(Params_Delete_Department i_Params_Delete_Department)
        {
            List <Manager> oList = new List <Manager>();



            // 2. Create Sql Connection Object
            using (SqlConnection oConn = new SqlConnection(connStr))
            {
                // 3. Open the Connection
                oConn.Open();

                //4 . Prepare Sql Command Object
                using (SqlCommand command = new SqlCommand("UP_GET_MANAGERS_OF_DEPARTMENT"))
                {
                    //5. Set the Command Type to Stored Procedure
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    //6. Inform the Command on Wich connection it should work
                    command.Connection = oConn;

                    command.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "DEPARTMENT_ID", Value = i_Params_Delete_Department.DEPARTMENT_ID
                    });

                    command.ExecuteNonQuery();
                    // 7. Execute the Command (ExecuteReader)
                    // 8. The Reader is a kind of Hand/Cursor pointing to data retrieved by the Command
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                Manager oManager = new Manager();
                                oManager.MANAGER_ID    = Convert.ToInt32(reader["MANAGER_ID"]);
                                oManager.FIRST_NAME    = Convert.ToString(reader["FIRST_NAME"]);
                                oManager.LAST_NAME     = Convert.ToString(reader["LAST_NAME"]);
                                oManager.DEPARTMENT_ID = Convert.ToInt32(reader["DEPARTMENT_ID"]);
                                oList.Add(oManager);
                            }
                        }
                    }
                }
            }



            return(oList);
        }
 public void Delete_Department(Params_Delete_Department i_Params_Delete_Department)
 {
     DALC.DALC oDALC = new DALC.DALC();
     oDALC.connStr = this.connStr;
     oDALC.Delete_Department(i_Params_Delete_Department);
 }
Example #7
0
 public List <Employee> Get_Youngest_Employee(Params_Delete_Department i_Params_Delete_Department)
 {
     BLC.BLC oBLC = new BLC.BLC();
     oBLC.connStr = this.MyConfig["AppSettings:MyDBConnection"];
     return(oBLC.Get_Youngest_Employee(i_Params_Delete_Department));
 }
Example #8
0
 public List <Manager> GetAllManagersOfDepartment(Params_Delete_Department i_Params_Delete_Department)
 {
     BLC.BLC oBLC = new BLC.BLC();
     oBLC.connStr = this.MyConfig["AppSettings:MyDBConnection"];
     return(oBLC.GetAllManagersOfDepartment(i_Params_Delete_Department));
 }
Example #9
0
 public void Delete_Department(Params_Delete_Department i_Params_Delete_Department)
 {
     BLC.BLC oBLC = new BLC.BLC();
     oBLC.connStr = this.MyConfig["AppSettings:MyDBConnection"];
     oBLC.Delete_Department(i_Params_Delete_Department);
 }