public SingleDevolucion(Devolucion reg)
        {
            InitializeComponent();
            devolucion = reg;
            this.DataContext = devolucion;

            btnActualizar.Visibility = Visibility.Visible;
            btnGuardar.Visibility = Visibility.Collapsed;
        }
Example #2
0
        public bool CreateRecord(Devolucion obj)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_Devolucion_Insert", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@IdEmpleado", obj.IdEmpleado);
            cmd.Parameters.AddWithValue("@IdArticulo", obj.IdArticulo);
            cmd.Parameters.AddWithValue("@Cantidad", obj.Cantidad);
            cmd.Parameters.AddWithValue("@Nota", obj.Nota);
            cmd.Parameters.AddWithValue("@Fecha", obj.Fecha);
            con.Open();

            if (cmd.ExecuteNonQuery() > 0)
            {
                con.Close();
                return true;
            }
            else
            {
                con.Close();
                return false;
            }
        }
Example #3
0
        public Devolucion readOneDevolucion(int idDevolucion)
        {
            Devolucion devolucion = new Devolucion();

            using (SqlConnection con = new SqlConnection(Info.sqlSet()))
            {
                SqlCommand cmd = new SqlCommand("SP_Devolucion_SelectRow", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@IdDevolucion", idDevolucion);

                con.Open();

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

                        tmp.IdDevolucion = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdDevolucion;
                        tmp.IdEmpleado = (reader.GetValue(1) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(1)) : tmp.IdEmpleado;
                        tmp.IdArticulo = (reader.GetValue(2) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(2)) : tmp.IdArticulo;
                        tmp.Cantidad = (reader.GetValue(3) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(3)) : tmp.Cantidad;
                        tmp.Nota = (reader.GetValue(4) != DBNull.Value) ? Convert.ToString(reader.GetValue(4)) : tmp.Nota;
                        tmp.Fecha = (reader.GetValue(5) != DBNull.Value) ? Convert.ToDateTime(reader.GetValue(5)) : tmp.Fecha;

                        devolucion = tmp;
                    }
                }

                con.Close();
            }

            return devolucion;
        }
Example #4
0
        public string Create(Devolucion obj)
        {

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

            UpdateDAC objDAC = new UpdateDAC();
            if (objDAC.UpdateRecord(obj, idDevolucion) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }