static private SqlCommand CreateSqlCommand(AppointmentImportance appointmentImportance, string commandText)
        {
            SqlCommand command = new SqlCommand(commandText);

            command.Parameters.AddWithValue("@importanceId", appointmentImportance.importanceId);
            command.Parameters.AddWithValue("@importanceName", appointmentImportance.importanceName);

            return(command);
        }
        public static AppointmentImportance ToObject(DataRow reader)
        {
            AppointmentImportance appointmentImportance = new AppointmentImportance();

            appointmentImportance.importanceId   = int.Parse(reader[0].ToString());
            appointmentImportance.importanceName = reader[1].ToString();

            Debug.WriteLine("appointmentImportance: " + appointmentImportance.ToString());
            return(appointmentImportance);
        }
Пример #3
0
        public AppointmentImportance UpdateAppointmentImportance(AppointmentImportance tmpAppointmentImportance)
        {
            DataTable             dt = new DataTable();
            AppointmentImportance appointmentImportance = new AppointmentImportance();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(AppointmentImportanceStrings.UpdateAppointmentImportance(tmpAppointmentImportance));
            }

            foreach (DataRow ms in dt.Rows)
            {
                appointmentImportance = AppointmentImportance.ToObject(ms);
            }

            return(appointmentImportance);
        }
Пример #4
0
        public List <AppointmentImportance> GetAllAppointmentImportances()
        {
            DataTable dt = new DataTable();
            List <AppointmentImportance> arrAppointmentImportances = new List <AppointmentImportance>();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(AppointmentImportanceStrings.GetAllAppointmentImportances());
            }

            foreach (DataRow ms in dt.Rows)
            {
                arrAppointmentImportances.Add(AppointmentImportance.ToObject(ms));
            }

            return(arrAppointmentImportances);
        }
Пример #5
0
        public AppointmentImportance GetOneAppointmentImportance(int appointmentImportanceId)
        {
            if (appointmentImportanceId < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            DataTable             dt = new DataTable();
            AppointmentImportance appointmentImportance = new AppointmentImportance();

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(AppointmentImportanceStrings.GetOneAppointmentImportance(appointmentImportanceId));
            }

            foreach (DataRow ms in dt.Rows)
            {
                appointmentImportance = AppointmentImportance.ToObject(ms);
            }

            return(appointmentImportance);
        }
 static public SqlCommand UpdateAppointmentImportance(AppointmentImportance appointmentImportance)
 {
     return(CreateSqlCommand(appointmentImportance, queryAppointmentImportanceUpdate));
 }
 static public SqlCommand AddAppointmentImportance(AppointmentImportance appointmentImportance)
 {
     return(CreateSqlCommand(appointmentImportance, queryAppointmentImportancePost));
 }