public SingleCapacitacion(Capacitacion reg)
        {
            InitializeComponent();
            capacitacion = reg;
            this.DataContext = capacitacion;

            btnActualizar.Visibility = Visibility.Visible;
            btnGuardar.Visibility = Visibility.Collapsed;
        }
Exemplo n.º 2
0
        public string Update(Capacitacion obj, int idCapacitacion)
        {

            UpdateDAC objDAC = new UpdateDAC();
            if (objDAC.UpdateRecord(obj, idCapacitacion) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
Exemplo n.º 3
0
        public string Create(Capacitacion obj)
        {

            CreateDAC objDAC = new CreateDAC();
            if (objDAC.CreateRecord(obj) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
Exemplo n.º 4
0
        public bool UpdateRecord(Capacitacion obj, int idCapacitacion)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_Capacitacion_Update", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@IdCapacitacion", idCapacitacion);
            cmd.Parameters.AddWithValue("@Nombre", obj.Nombre);
            cmd.Parameters.AddWithValue("@Imparte", obj.Imparte);
            cmd.Parameters.AddWithValue("@Fecha", obj.Fecha);
            cmd.Parameters.AddWithValue("@Duracion", obj.Duracion);
            con.Open();

            if (cmd.ExecuteNonQuery() > 0)
            {
                con.Close();
                return true;
            }
            else
            {
                con.Close();
                return false;
            }
        }
Exemplo n.º 5
0
        public List<Capacitacion> readCapacitacion()
        {
            List<Capacitacion> capacitacionList = new List<Capacitacion>();

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

                con.Open();

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

                        tmp.IdCapacitacion = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdCapacitacion;
                        tmp.Nombre = (reader.GetValue(1) != DBNull.Value) ? Convert.ToString(reader.GetValue(1)) : tmp.Nombre;
                        tmp.Imparte = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Imparte;
                        tmp.Fecha = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.Fecha;
                        tmp.Duracion = (reader.GetValue(4) != DBNull.Value) ? Convert.ToSingle(reader.GetValue(4)) : tmp.Duracion;

                        capacitacionList.Add(tmp);
                    }
                }

                con.Close();
            }

            return capacitacionList;
        }
Exemplo n.º 6
0
        public Capacitacion readOneCapacitacion(int idCapacitacion)
        {
            Capacitacion capacitacion = new Capacitacion();

            using (SqlConnection con = new SqlConnection(Info.sqlSet()))
            {
                SqlCommand cmd = new SqlCommand("SP_Capacitacion_SelectRow", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@IdCapacitacion", idCapacitacion);

                con.Open();

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

                        tmp.IdCapacitacion = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdCapacitacion;
                        tmp.Nombre = (reader.GetValue(1) != DBNull.Value) ? Convert.ToString(reader.GetValue(1)) : tmp.Nombre;
                        tmp.Imparte = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Imparte;
                        tmp.Fecha = (reader.GetValue(3) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(3)) : tmp.Fecha;
                        tmp.Duracion = (reader.GetValue(4) != DBNull.Value) ? Convert.ToSingle(reader.GetValue(4)) : tmp.Duracion;

                        capacitacion = tmp;
                    }
                }

                con.Close();
            }

            return capacitacion;
        }