Exemplo n.º 1
0
        public List <Classes.Counsellor> GetCounsellors()
        {
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = Util.GetConnectionString();
            connection.Open();

            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "GetCounsellors";

            List <Classes.Counsellor> counsellors = new List <Classes.Counsellor>();

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Classes.Counsellor counsellor = new Classes.Counsellor()
                {
                    CounsellorID = int.Parse(reader["CounsellorID"].ToString()),
                    Name         = reader["Name"].ToString()
                };
                counsellors.Add(counsellor);
            }

            return(counsellors);
        }
        public IActionResult OnGet()
        {
            string username = GetSessionValue("Username");

            if (username == null || username == string.Empty)
            {
                return(new RedirectToPageResult("Index"));
            }

            int appointmentID = int.Parse(HttpContext.Session.GetString("UpdateAppointmentID"));

            System.Diagnostics.Debug.WriteLine($"UpdateAppointment: Updating appointment: {appointmentID}");

            ResolutionsSystem rs = new ResolutionsSystem();

            Classes.Appointment app = rs.GetAppointment(appointmentID);
            AppointmentID   = app.AppointmentID;
            AppointmentDate = app.AppointmentDate;

            Classes.Client client = rs.GetClient(app.ClientID);
            ClientID = (int)client.ClientID;
            if (client.MiddleName == null)
            {
                ClientFullName = $"{client.FirstName} {client.LastName}";
            }
            else
            {
                ClientFullName = $"{client.FirstName} {client.MiddleName} {client.LastName}";
            }

            Classes.Counsellor counsellor = rs.GetCounsellor(app.CounsellorID);
            CounsellorID   = counsellor.CounsellorID;
            CounsellorName = counsellor.Name;
            //Message = $"Updating appointment {appointmentID}\n" +
            //    $"Date: {app.AppointmentDate}\n" +
            //    $"Client Name: {clientName} ({client.ClientID})\n" +
            //    $"Counsellor: {counsellor.Name} ({counsellor.CounsellorID})";

            System.Diagnostics.Debug.WriteLine($"Updated appointment: {(int)AppointmentID}");
            //PopulateFields(app);

            //counsellors dropdownlist
            //PopulateSelectList();


            //ListOfCounsellors = rs.GetCounsellors();

            //client dropdownlist
            //PopulateSelectListForClient();

            //ListOfClients = rs.GetClients();

            return(Page());
        }
Exemplo n.º 3
0
        public SqlCode UpdateCounsellor(Classes.Counsellor Counsellor)
        {
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = Util.GetConnectionString();
            connection.Open();

            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "UpdateCounsellor";

            SqlParameter parameter = new SqlParameter
            {
                ParameterName = "@CounsellorID",
                SqlDbType     = SqlDbType.Int,
                Direction     = ParameterDirection.Input,
                SqlValue      = Counsellor.CounsellorID
            };

            command.Parameters.Add(parameter);

            parameter = new SqlParameter
            {
                ParameterName = "@Name",
                SqlDbType     = SqlDbType.DateTime,
                Direction     = ParameterDirection.Input,
                SqlValue      = Counsellor.Name
            };
            command.Parameters.Add(parameter);

            int     returnVal;
            SqlCode code;

            try
            {
                returnVal = command.ExecuteNonQuery();
                code      = SqlCode.Success;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine($"e: {e.Message}");
                code = SqlCode.Failure;
            }

            connection.Close();
            return(code);
        }
Exemplo n.º 4
0
        public Classes.Counsellor GetCounsellor(int CounsellorID)
        {
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = Util.GetConnectionString();
            connection.Open();

            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "GetCounsellor";

            SqlParameter parameter = new SqlParameter
            {
                ParameterName = "@CounsellorID",
                SqlDbType     = SqlDbType.Int,
                Direction     = ParameterDirection.Input,
                SqlValue      = CounsellorID
            };

            command.Parameters.Add(parameter);

            Classes.Counsellor counsellor = new Classes.Counsellor();

            SqlDataReader reader = command.ExecuteReader();

            reader.Read();

            if (reader.HasRows)
            {
                counsellor = new Classes.Counsellor()
                {
                    CounsellorID = int.Parse(reader["CounsellorID"].ToString()),
                    Name         = reader["Name"].ToString()
                };
            }

            return(counsellor);
        }