Beispiel #1
0
        public bool UpdateRecord(Horario obj, int idHorario)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_Horario_Update", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@IdHorario", idHorario);
            cmd.Parameters.AddWithValue("@HoraIn", obj.HoraIn);
            cmd.Parameters.AddWithValue("@HoraOut", obj.HoraOut);
            cmd.Parameters.AddWithValue("@HoraInMed", obj.HoraInMed);
            cmd.Parameters.AddWithValue("@HoraOutMed", obj.HoraOutMed);
            cmd.Parameters.AddWithValue("@Lunes", obj.Lunes);
            cmd.Parameters.AddWithValue("@Martes", obj.Martes);
            cmd.Parameters.AddWithValue("@Miercoles", obj.Miercoles);
            cmd.Parameters.AddWithValue("@Jueves", obj.Jueves);
            cmd.Parameters.AddWithValue("@Viernes", obj.Viernes);
            cmd.Parameters.AddWithValue("@Sabado", obj.Sabado);
            cmd.Parameters.AddWithValue("@Domingo", obj.Domingo);
            con.Open();

            if (cmd.ExecuteNonQuery() > 0)
            {
                con.Close();
                return true;
            }
            else
            {
                con.Close();
                return false;
            }
        }
Beispiel #2
0
        public string Create(Horario obj)
        {

            CreateDAC objDAC = new CreateDAC();
            if (objDAC.CreateRecord(obj) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
Beispiel #3
0
        public string Update(Horario obj, int idHorario)
        {

            UpdateDAC objDAC = new UpdateDAC();
            if (objDAC.UpdateRecord(obj, idHorario) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
        public SingleHorario(Horario reg)
        {
            InitializeComponent();
            horario = reg;
            this.DataContext = horario;

            btnActualizar.Visibility = Visibility.Visible;
            btnGuardar.Visibility = Visibility.Collapsed;
        }
Beispiel #5
0
        public List<Horario> readHorario()
        {
            List<Horario> horarioList = new List<Horario>();

            using (SqlConnection con = new SqlConnection(Info.sqlSet()))
            {
                SqlCommand cmd = new SqlCommand("SP_Horario_SelectAll", con);
                cmd.CommandType = CommandType.StoredProcedure;

                con.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    // Loop through each record.
                    while (reader.Read())
                    {
                        Horario tmp = new Horario();

                        tmp.IdHorario = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdHorario;
                        tmp.HoraIn = (reader.GetValue(1) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(1)) : tmp.HoraIn;
                        tmp.HoraOut = (reader.GetValue(2) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(2)) : tmp.HoraOut;
                        tmp.HoraInMed = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.HoraInMed;
                        tmp.HoraOutMed = (reader.GetValue(4) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(4)) : tmp.HoraOutMed;
                        tmp.Lunes = (reader.GetValue(5) != DBNull.Value) ? Convert.ToBoolean(reader.GetValue(5)) : tmp.Lunes;
                        tmp.Martes = (reader.GetValue(6) != DBNull.Value) ? Convert.ToBoolean(reader.GetValue(6)) : tmp.Martes;
                        tmp.Miercoles = (reader.GetValue(7) != DBNull.Value) ? Convert.ToBoolean(reader.GetValue(7)) : tmp.Miercoles;
                        tmp.Jueves = (reader.GetValue(8) != DBNull.Value) ? Convert.ToBoolean(reader.GetValue(8)) : tmp.Jueves;
                        tmp.Viernes = (reader.GetValue(9) != DBNull.Value) ? Convert.ToBoolean(reader.GetValue(9)) : tmp.Viernes;
                        tmp.Sabado = (reader.GetValue(10) != DBNull.Value) ? Convert.ToBoolean(reader.GetValue(10)) : tmp.Sabado;
                        tmp.Domingo = (reader.GetValue(11) != DBNull.Value) ? Convert.ToBoolean(reader.GetValue(11)) : tmp.Domingo;

                        horarioList.Add(tmp);
                    }
                }

                con.Close();
            }

            return horarioList;
        }