Ejemplo n.º 1
0
        public Justificante readOneJustificante(int idJustificante)
        {
            Justificante justificante = new Justificante();

            using (SqlConnection con = new SqlConnection(Info.sqlSet()))
            {
                SqlCommand cmd = new SqlCommand("SP_Justificante_SelectRow", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@IdJustificante", idJustificante);

                con.Open();

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

                        tmp.IdJustificante = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdJustificante;
                        tmp.IdIncidente = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdIncidente;
                        tmp.Descripcion = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Descripcion;

                        justificante = tmp;
                    }
                }

                con.Close();
            }

            return justificante;
        }
Ejemplo n.º 2
0
        public string Create(Justificante obj)
        {

            CreateDAC objDAC = new CreateDAC();
            if (objDAC.CreateRecord(obj) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
Ejemplo n.º 3
0
        public string Update(Justificante obj, int idJustificante)
        {

            UpdateDAC objDAC = new UpdateDAC();
            if (objDAC.UpdateRecord(obj, idJustificante) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
Ejemplo n.º 4
0
        public SingleJustificante(Justificante reg)
        {
            InitializeComponent();
            justificante = reg;
            this.DataContext = justificante;

            btnActualizar.Visibility = Visibility.Visible;
            btnGuardar.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 5
0
        public bool CreateRecord(Justificante obj)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_Justificante_Insert", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@IdIncidente", obj.IdIncidente);
            cmd.Parameters.AddWithValue("@Descripcion", obj.Descripcion);
            con.Open();

            if (cmd.ExecuteNonQuery() > 0)
            {
                con.Close();
                return true;
            }
            else
            {
                con.Close();
                return false;
            }
        }
Ejemplo n.º 6
0
        public List<Justificante> readJustificante()
        {
            List<Justificante> justificanteList = new List<Justificante>();

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

                con.Open();

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

                        tmp.IdJustificante = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdJustificante;
                        tmp.IdIncidente = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdIncidente;
                        tmp.Descripcion = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Descripcion;

                        justificanteList.Add(tmp);
                    }
                }

                con.Close();
            }

            return justificanteList;
        }